From 7c895105cd86a752fcd43f1ca5ab41a7e8a16368 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:45:02 +0000 Subject: [PATCH 01/61] integration: slice-2 (length->count) + marker derives --- dsl/extdeps/version/semver.dag | 16 ++++++++-------- dsl/std/realization_schedule.dag | 26 +++++++++++++------------- src/v1/05_emit_rust.dag | 16 ++++++++++++++-- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/dsl/extdeps/version/semver.dag b/dsl/extdeps/version/semver.dag index 9432c9de734..9e51d5156c6 100644 --- a/dsl/extdeps/version/semver.dag +++ b/dsl/extdeps/version/semver.dag @@ -60,10 +60,10 @@ fn semver_compare_identifier(a: SemVerIdentifier, b: SemVerIdentifier) -> Orderi } fn semver_compare_identifiers(a: List, b: List) -> Ordering { - if a.length() == 0 && b.length() == 0 { Equal } + if a.count() == 0 && b.count() == 0 { Equal } // semver.org §11.4.4: when all preceding identifiers are equal, the longer set wins. - else if a.length() == 0 { Less } - else if b.length() == 0 { Greater } + else if a.count() == 0 { Less } + else if b.count() == 0 { Greater } else { match semver_compare_identifier(a: a.first(), b: b.first()) { Equal => @@ -77,9 +77,9 @@ fn semver_compare_identifiers(a: List, b: List, b: List) -> Ordering { - if a.length() == 0 && b.length() == 0 { Equal } - else if a.length() == 0 { Greater } - else if b.length() == 0 { Less } + if a.count() == 0 && b.count() == 0 { Equal } + else if a.count() == 0 { Greater } + else if b.count() == 0 { Less } else { semver_compare_identifiers(a: a, b: b) } } @@ -114,12 +114,12 @@ fn semver_version_label(v: SemVerVersion) -> String { to_string(v.major), concat(".", concat(to_string(v.minor), concat(".", to_string(v.patch)))) ) - let with_pre = if v.pre_release.length() == 0 { + let with_pre = if v.pre_release.count() == 0 { core } else { concat(core, concat("-", semver_identifiers_label(ids: v.pre_release))) } - if v.build.length() == 0 { + if v.build.count() == 0 { with_pre } else { concat(with_pre, concat("+", semver_identifiers_label(ids: v.build))) diff --git a/dsl/std/realization_schedule.dag b/dsl/std/realization_schedule.dag index da33cd8a4b8..23266b1cc6f 100644 --- a/dsl/std/realization_schedule.dag +++ b/dsl/std/realization_schedule.dag @@ -135,14 +135,14 @@ fn schedule_lens_violation_diagnostic( } fn schedule_lens_verdict_for_ci_floor(plan: RealizationPlan, compile_gate_fn: String) -> LensVerdict { - if plan.schedule.length() == 0 { + if plan.schedule.count() == 0 { Violation { diagnostic: schedule_lens_violation_diagnostic( kind: EmptySchedule, compile_gate_fn: compile_gate_fn ) } - } else if plan.schedule.length() < 2 { + } else if plan.schedule.count() < 2 { Violation { diagnostic: schedule_lens_violation_diagnostic( kind: SingleBatchOnly, @@ -151,7 +151,7 @@ fn schedule_lens_verdict_for_ci_floor(plan: RealizationPlan, compile_gate_ } } else { let batch0 = plan.schedule.first() - if batch0.length() != 1 { + if batch0.count() != 1 { Violation { diagnostic: schedule_lens_violation_diagnostic( kind: CompileGateNotFirst { expected: compile_gate_fn }, @@ -174,7 +174,7 @@ fn schedule_lens_verdict_for_ci_floor(plan: RealizationPlan, compile_gate_ } } else { let batch1 = plan.schedule.skip(n: 1).first() - if batch1.length() < 2 { + if batch1.count() < 2 { Violation { diagnostic: schedule_lens_violation_diagnostic( kind: SingleBatchOnly, @@ -189,7 +189,7 @@ fn schedule_lens_verdict_for_ci_floor(plan: RealizationPlan, compile_gate_ } fn schedule_generates_same_batch_count(left: RealizationPlan, right: RealizationPlan) -> Bool { - left.schedule.length() == right.schedule.length() + left.schedule.count() == right.schedule.count() } fn schedule_witness_entry_eq(a: ScheduleWitnessEntry, b: ScheduleWitnessEntry) -> Bool { @@ -197,9 +197,9 @@ fn schedule_witness_entry_eq(a: ScheduleWitnessEntry, b: ScheduleWitnessEntry) - } fn string_list_eq(left: List, right: List) -> Bool { - if left.length() != right.length() { + if left.count() != right.count() { false - } else if left.length() == 0 { + } else if left.count() == 0 { true } else if left.first() != right.first() { false @@ -209,9 +209,9 @@ fn string_list_eq(left: List, right: List) -> Bool { } fn schedule_witness_entry_list_eq(left: List, right: List) -> Bool { - if left.length() != right.length() { + if left.count() != right.count() { false - } else if left.length() == 0 { + } else if left.count() == 0 { true } else if !schedule_witness_entry_eq(a: left.first(), b: right.first()) { false @@ -238,9 +238,9 @@ fn runnable_eq(left: Runnable, right: Runnable) -> Bool { } fn runnable_batch_eq(left: List, right: List) -> Bool { - if left.length() != right.length() { + if left.count() != right.count() { false - } else if left.length() == 0 { + } else if left.count() == 0 { true } else if !runnable_eq(left: left.first(), right: right.first()) { false @@ -250,9 +250,9 @@ fn runnable_batch_eq(left: List, right: List) -> Bool { } fn schedule_eq(left: Schedule, right: Schedule) -> Bool { - if left.length() != right.length() { + if left.count() != right.count() { false - } else if left.length() == 0 { + } else if left.count() == 0 { true } else if !runnable_batch_eq(left: left.first(), right: right.first()) { false diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 399633b943c..2c2e7ee89c0 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1224,13 +1224,25 @@ fn rust_render_type_leaf_name(name: String, variant_to_enum: Map } } +// Phantom ZST type-tag markers (enum variants used as type-level kinds, e.g. the +// Quantity/Scale tags Memory/One/Power in Measure) must derive the +// same trait set as the carriers that mention them (Measure derives Debug/Clone/ +// PartialEq + serde), or those derives fail closed (E0277 Memory: !Debug, E0369 == on +// Measure, E0392 unused param). Single authority for the marker definition. +fn rust_phantom_zst_marker_def(vname: String) -> String { + concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]\n", + rust_visibility_prefix(), rust_items().struct_keyword, " ", vname, ";" + ) +} + fn emit_phantom_zst_markers_for_enum(children: List, env: TypeEnv) -> String { let markers = children |> filter(child => child.children |> count == 0) |> filter(child => is_phantom_unit_variant_type_arg(env: env, variant_name: authored_name(env: env, node: child))) |> map(child => let vname = authored_name(env: env, node: child) - concat(rust_visibility_prefix(), rust_items().struct_keyword, " ", vname, ";") + rust_phantom_zst_marker_def(vname: vname) ) |> join(separator: "\n") markers @@ -1253,7 +1265,7 @@ fn collect_phantom_zst_marker_names(items: List, env: TypeEnv) -> List, env: TypeEnv) -> String { collect_phantom_zst_marker_names(items: items, env: env) - |> map(vname => concat(rust_visibility_prefix(), rust_items().struct_keyword, " ", vname, ";")) + |> map(vname => rust_phantom_zst_marker_def(vname: vname)) |> join(separator: "\n") } From ad440dee1e56bc0168808b5af5722a761dfe42b6 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:46:21 +0000 Subject: [PATCH 02/61] integration: + bright-badger Measure (04_infer+05_emit) + eager-boar MachineWidth (05_emit) --- src/v1/04_infer.dag | 16 +- src/v1/05_emit_rust.dag | 162 ++++++++++++++++++-- src/v1/tests/src/width_nat_type_arg_test.rs | 37 +++++ 3 files changed, 203 insertions(+), 12 deletions(-) diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index 19d91715131..9095c06ca80 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -1474,7 +1474,21 @@ fn infer_expr(texpr: Node, scope: InferScope, expected: Node?) -> InferResult { let field_type_lookup = lookup_field_type_node(n: resolved_base, field_name: field_name, source_indices: scope.type_env.source_indices) match field_type_lookup { Present { value: field_type } => - let field_summary = field_summary_for_type(base_type: base_rt, env: scope.type_env, field: field_name) + // The field TYPE was found via `resolved_base` (the alias-chain- + // expanded structural record, G3). Derive the FieldSummary from the + // SAME expansion so the two stay consistent: `field_summary_for_type` + // peels with `resolve_scrutinee_type_node` alone, which does not + // chase the structural-name hop a cross-module / multi-hop alias + // needs (e.g. `Gibibyte` -> `Measure` -> the + // `Measure { count }` struct). Try the authored type first (keeps the + // optional `.value` fast-path unchanged) and fall back to the + // expanded record only when the authored type yields no summary -- + // otherwise emission fails closed to `compile_error!("field access + // missing reconcile summary ...")`. + let field_summary = match field_summary_for_type(base_type: base_rt, env: scope.type_env, field: field_name) { + Present { value: s } => Present { value: s } + Absent => field_summary_for_type(base_type: resolved_base, env: scope.type_env, field: field_name) + } let fa_texpr = make_named_expr_node( name: field_name, expr_data: ExprFieldAccess { summary: field_summary }, diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 2c2e7ee89c0..e1b650271e0 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -106,7 +106,8 @@ import v1.compiler.infer { build_params_scope, extend_scope, build_emit_graph_info, expr_span, - resolved_type_name + resolved_type_name, + expand_type_for_field_access } import v1.compiler.infer_emit_info { EmitGraphInfo, TypeSummary, StructRepr, EnumRepr, @@ -114,7 +115,7 @@ import v1.compiler.infer_emit_info { variant_belongs_to_enum, variant_summary_key } import v1.compiler.resolve { get_exported_names } -import v1.compiler.infer_resolve { lookup_unit_variant_phantom_type } +import v1.compiler.infer_resolve { 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 std.induction { SubValueUnknown } @@ -309,6 +310,37 @@ fn rust_normalize_partial_function_field_type_text(rendered: String) -> String { ) } +// MachineWidth<8> etc.: phantom width-nat args ground to () in Rust, not empty <> (E0107). +fn is_parametric_opaque_type_by_name(env: TypeEnv, type_name: String) -> Bool { + match lookup_type_by_name(env: env, name: type_name) { + Present { value: item } => is_parametric_opaque_type_decl_item(item: item, source_indices: env.source_indices) + Absent => false + } +} + +fn is_parametric_opaque_type_base(type_name: String, def_mod_filename: String, typed_modules: List, source_indices: Map, module_index: ModuleIndex) -> Bool { + match type_item_by_name_in_module_filename(rhs_name: type_name, mod_filename: def_mod_filename, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) { + Present { value: item } => is_parametric_opaque_type_decl_item(item: item, source_indices: source_indices) + Absent => false + } +} + +fn render_rust_phantom_opaque_applied_type_arg(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { + if is_width_nat_type_literal(n: n) { + "()" + } else { + render_rust_alias_rhs_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) + } +} + +fn render_rust_phantom_opaque_applied_decl_arg(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { + if is_width_nat_type_literal(n: n) { + "()" + } else { + render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + } +} + fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { match n.inferred { Present { value: TypeVariable { id: tv } } => tv @@ -317,11 +349,19 @@ fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shar } fn render_rust_applied_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - let base = rust_named_type_base(name: authored_name_at(source_indices: source_indices, node: n), source_indices: source_indices) + let base_name = authored_name_at(source_indices: source_indices, node: n) + let base = rust_named_type_base(name: base_name, source_indices: source_indices) if n.children |> count == 0 { base } else { - let args = n.children |> map(arg => render_rust_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) |> join(separator: ", ") + let peel = is_parametric_opaque_type_by_name(env: env, type_name: base_name) + let args = n.children |> map(arg => + if peel { + render_rust_phantom_opaque_applied_decl_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + } else { + render_rust_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + } + ) |> join(separator: ", ") concat(base, "<", args, ">") } } @@ -365,7 +405,14 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) } else { let base = rust_named_type_base(name: name, source_indices: source_indices) - let args = n.children |> map(arg => render_rust_decl_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) |> join(separator: ", ") + let peel = is_parametric_opaque_type_by_name(env: env, type_name: name) + let args = n.children |> map(arg => + if peel { + render_rust_phantom_opaque_applied_decl_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + } else { + render_rust_decl_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + } + ) |> join(separator: ", ") let applied_ty = concat(base, "<", args, ">") render_rust_shared_type_if_needed(type_name: name, rendered: applied_ty, shared_types: shared_types) } @@ -454,7 +501,14 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } else { name } - let args = n.children |> map(arg => render_rust_alias_rhs_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum)) |> join(separator: ", ") + let peel = is_parametric_opaque_type_base(type_name: name, def_mod_filename: def_mod, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) + let args = n.children |> map(arg => + if peel { + render_rust_phantom_opaque_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) + } else { + render_rust_alias_rhs_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) + } + ) |> join(separator: ", ") let applied_ty = concat(base, "<", args, ">") if set_contains(shared_types, name) && !rust_type_is_rc_wrapped(type_name: applied_ty) { wrap_shared_type(target: Rust, inner: applied_ty) @@ -3122,6 +3176,46 @@ fn emit_type_def_from_connective(item: Node, recursive_types: Set, share } +// True iff the type node `n` (or any nested child) names `target` -- the +// structural "does this field type mention this generic param" test. +fn type_node_mentions_name(n: Node, target: String, source_indices: Map) -> Bool { + if authored_name_at(source_indices: source_indices, node: n) == target { + true + } else { + n.children |> any(c => type_node_mentions_name(n: c, target: target, source_indices: source_indices)) + } +} + +// A struct generic param that no field's type references is UNUSED -- Rust +// rejects it (E0392 "parameter is never used"). The phantom dimensional tags on +// `Measure` (only `M` reaches the `count` field; `Q`/`S` tag the +// dimension) are the canonical case. Such params must be carried in a +// `PhantomData` field for the emitted struct to be well-formed, and every +// construction must then populate that field (see emit_typed_record_lit). +fn struct_unused_param_names(generic_param_names: List, children: List, source_indices: Map) -> List { + generic_param_names |> filter(p => + !(children |> any(child => type_node_mentions_name(n: field_node_type_expr(n: child), target: p, source_indices: source_indices))) + ) +} + +// The `<...>` arg of the synthetic `PhantomData` carrier for a struct's unused +// params: a single param bare (`PhantomData`), several as a tuple +// (`PhantomData<(Q, S)>`) so one field "uses" them all. +fn rust_phantom_marker_inner(unused: List) -> String { + if unused |> count == 1 { + match unused |> first { + Present { value: u } => u + Absent => "()" + } + } else { + concat("(", unused |> join(separator: ", "), ")") + } +} + +// The unused-param `PhantomData` field name -- single authority shared by the +// struct definition and every construction so they always agree. +fn rust_phantom_field_name() -> String { "_phantom" } + fn emit_struct_from_children(name: String, type_params: String, generic_param_names: List, children: List, recursive_types: Set, shared_types: Set, env: TypeEnv, emit_info: EmitGraphInfo) -> String { let has_fn_fields = match map_get(emit_info.type_summaries, name) { Present { value: ts } => ts.has_fn_fields @@ -3140,7 +3234,16 @@ fn emit_struct_from_children(name: String, type_params: String, generic_param_na concat(derives, "\n", rust_visibility_prefix(), rust_items().struct_keyword, " ", name, type_params, ";") } else { let field_lines = children |> map(child => emit_struct_field_from_child(struct_name: name, child: child, generic_param_names: generic_param_names, recursive_types: recursive_types, shared_types: shared_types, env: env, emit_info: emit_info)) - let fields_str = field_lines |> join(separator: "\n") + // E0392: carry any generic param unused by the fields in a PhantomData + // field (`Measure`'s phantom `Q`/`S`). The `#[derive]` on the + // struct adds the standard `Q: Trait` bounds, satisfied by the concrete + // marker tags at every instantiation; serde special-cases PhantomData and + // adds no Serialize/Deserialize bound. + let unused_params = struct_unused_param_names(generic_param_names: generic_param_names, children: children, source_indices: env.source_indices) + let all_field_lines = if unused_params |> count > 0 { + concat(field_lines, [concat(" ", rust_visibility_prefix(), rust_phantom_field_name(), ": std::marker::PhantomData<", rust_phantom_marker_inner(unused: unused_params), ">,")]) + } else { field_lines } + let fields_str = all_field_lines |> join(separator: "\n") concat(derives, "\n", rust_visibility_prefix(), rust_items().struct_keyword, " ", name, type_params, " {\n", fields_str, "\n}") } } @@ -4827,15 +4930,35 @@ fn emit_rust_expr_record_lit(expr: Node, registry: Map, scope: ExprRecordLit { parent_enum: parent_enum } => let tn = record_lit_type_name_at(texpr: expr, source_indices: scope.type_env.source_indices) let fs = expr.children - let raw = emit_typed_record_lit(type_name: tn, fields: fs, parent_enum: parent_enum, resolved_type: resolved_type(n: expr), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) + // Peel a struct-alias literal to its underlying concrete struct before + // emission. `Gibibyte { count: x }` (where `type Gibibyte = + // Measure`) leaves `resolved_type` a bare alias leaf, + // so the emitter would name the alias (E0560: `Rc` has no field + // `count`), skip `Box`-wrapping the field, and skip the `Rc::new` share + // wrap. Expanding the alias chain to the `Measure { count }` struct + // (G3, same machinery the field-access TYPE lookup uses) makes the struct + // NAME, the field `Box` boxing, and the shared-type `Rc::new` all + // resolve exactly as the direct `Measure { .. }` literal already does. + // For a non-alias literal `resolved_type` is already the concrete record, + // and the expansion returns it unchanged. + let resolved_rt = resolved_type(n: expr) + let expanded_rt = expand_type_for_field_access(n: resolved_rt, env: scope.type_env, module_name: scope.module_name) + let raw = emit_typed_record_lit(type_name: tn, fields: fs, parent_enum: parent_enum, resolved_type: expanded_rt, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) let si = scope.type_env.source_indices let variant_name = match tn { Present { value: n } => n Absent => "" } let rc_name = match parent_enum { Present { value: en } => en Absent => - match contextual_variant_parent(variant_name: variant_name, parent_enum: parent_enum, resolved_type: resolved_type(n: expr), emit_info: emit_info, source_indices: si) { + match contextual_variant_parent(variant_name: variant_name, parent_enum: parent_enum, resolved_type: expanded_rt, emit_info: emit_info, source_indices: si) { Present { value: p } => p - Absent => variant_name + Absent => + // Share-wrap on the peeled concrete struct (`Measure`) when the + // literal was written through an alias whose own name is not a + // shared type; falls back to the written name otherwise. + let expanded_name = authored_name_at(source_indices: si, node: expanded_rt) + if expanded_rt.ident_span != none && expanded_name != "" && expanded_name != variant_name && set_contains(shared_types, expanded_name) { + expanded_name + } else { variant_name } } } if rc_name != "" && set_contains(shared_types, rc_name) { @@ -6300,7 +6423,24 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St } else { [] } Absent => [] } - let all_field_strs = concat(field_strs, default_strs) + // Populate the synthetic PhantomData field (E0392) whenever the target + // struct carries unused generic params -- the construction counterpart + // of the phantom field appended in emit_struct_from_children. Keyed on + // the concrete struct decl (`tn` is the peeled struct name after the + // alias-peel above), so it fires for `Measure`/its aliases and stays + // silent for every fully-used-param struct and for enum variants. + let phantom_strs = match lookup_type_by_name(env: scope.type_env, name: tn) { + Present { value: struct_decl } => + let is_struct = struct_decl.connective == Conj + let pnames = struct_decl.params |> map(p => generic_param_name_at(n: p, source_indices: si)) + let unused = struct_unused_param_names(generic_param_names: pnames, children: struct_decl.children, source_indices: si) + let has_unused = (unused |> count) > 0 + if is_struct && has_unused { + [concat(" ", rust_phantom_field_name(), ": std::marker::PhantomData,")] + } else { [] } + Absent => [] + } + let all_field_strs = concat(concat(field_strs, default_strs), phantom_strs) let fields_str = all_field_strs |> join(separator: "\n") let raw = concat(display_tn, " {\n", fields_str, "\n}") raw diff --git a/src/v1/tests/src/width_nat_type_arg_test.rs b/src/v1/tests/src/width_nat_type_arg_test.rs index 966a76b9797..0d202acaf6c 100644 --- a/src/v1/tests/src/width_nat_type_arg_test.rs +++ b/src/v1/tests/src/width_nat_type_arg_test.rs @@ -78,6 +78,43 @@ fn v1_std_float_dag_resolves_with_literal_machine_width() { ); } +#[test] +fn machine_width_phantom_arg_rust_emit_peels_literal_width_to_unit() { + use v1_compiler::cli_run; + use v1_compiler::v1_compiler_artifact::RenderTarget; + use v1_compiler::v1_compiler_compile::compile_sources; + + let roots: Vec = crate::helpers::source_roots() + .iter() + .map(|p| p.to_string_lossy().to_string()) + .collect(); + let entry = crate::helpers::workspace_root() + .join("dsl/std/integer.dag") + .to_string_lossy() + .to_string(); + let sources = cli_run::load_sources_for_entry(&roots, &entry) + .unwrap_or_else(|e| panic!("failed to load {entry}: {e}")); + let result = compile_sources(std::rc::Rc::new(sources), RenderTarget::Rust); + let integer_rs = result + .files + .iter() + .find(|f| f.path.contains("std_integer.rs")) + .map(|f| f.content.as_str()) + .unwrap_or(""); + assert!( + integer_rs.contains("MachineWidth<()>"), + "literal MachineWidth should peel to MachineWidth<()> in Rust emit, got:\n{integer_rs}" + ); + assert!( + !integer_rs.contains("MachineWidth<>"), + "peeled MachineWidth must not emit empty angle brackets (E0107), got:\n{integer_rs}" + ); + assert!( + integer_rs.contains("MachineWidth"), + "PointerWidth token should stay as a type argument, got:\n{integer_rs}" + ); +} + #[test] fn machine_width_use_site_resolves_without_unresolved_type() { let source = r#" From 8b8fbb9579ac818c5852b19a909b3e07c3362864 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:11:06 +0000 Subject: [PATCH 03/61] =?UTF-8?q?emit(import-completeness):=20authored=20i?= =?UTF-8?q?mports=20for=20emitter-rendered=20symbols=20(empty=5Fintern=5Ft?= =?UTF-8?q?able,=20InductiveField,=20is=5Fbare=5Fleaf=5Fitem,=20SemVerCons?= =?UTF-8?q?traint)=20=E2=80=94=20clears=20E0425=20from=20peeled/turbofish?= =?UTF-8?q?=20types=20not=20in=20source=20import=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dsl/extdeps/rust/cargo.dag | 1 + src/v1/05_emit_rust.dag | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dsl/extdeps/rust/cargo.dag b/dsl/extdeps/rust/cargo.dag index d8f6c82fba4..b19a82ebf9d 100644 --- a/dsl/extdeps/rust/cargo.dag +++ b/dsl/extdeps/rust/cargo.dag @@ -11,6 +11,7 @@ module extdeps.cargo import extdeps.cargo_version { CargoPackageVersion, CargoVersionRequirement, CargoToolVersionFloor } +import extdeps.version.semver { SemVerConstraint } import std.types { FilePathParts } // -- Edition ------------------------------------------------------- diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index e1b650271e0..62dc16332c5 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -61,7 +61,8 @@ import v1.std.core { make_span, with_required_cardinality, Connective, Conj, Disj, NoConnective, Cardinality, Required, CardOptional, - is_rest_transport, is_shell_transport, is_file_transport + is_rest_transport, is_shell_transport, is_file_transport, + empty_intern_table } import v1.compiler.artifact { RenderTarget, Rust } @@ -117,7 +118,7 @@ import v1.compiler.infer_emit_info { import v1.compiler.resolve { get_exported_names } import v1.compiler.infer_resolve { 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 std.induction { SubValueUnknown } +import std.induction { SubValueUnknown, InductiveField } import v1.compiler.emit { BlockEmitState, TcoFrame, TcoReassignInput, InterpPart, @@ -153,7 +154,8 @@ import v1.compiler.emit_core_support { is_type_alias_return_node, is_service_item, is_type_def_item, is_type_alias_item, is_type_decl_item, is_function_item, is_data_def_item, is_service_def_item, - is_resource_def_item, has_mock_prefix, extract_test_projections + is_resource_def_item, has_mock_prefix, extract_test_projections, + is_bare_leaf_item } fn render_rust_type(n: Node, shared_types: Set, source_indices: Map) -> String { From c840cc6f5928741b4e2cc507c38889effcc7e1c1 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:17:02 +0000 Subject: [PATCH 04/61] integration: bring #5325 regen_stage0.rs languages_consumer_census mod-injection patch (clears E0433 x6 in bootstrap) --- src/v1/stage0/src/bin/regen_stage0.rs | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index acd3748e6a4..80b4867a9f0 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -216,6 +216,9 @@ fn run() -> Result<(), String> { time_phase(&mut phases, "patch_bootstrap_dag_collect", || { patch_bootstrap_dag_collect(&fresh_dir.join("src")) })?; + time_phase(&mut phases, "patch_languages_consumer_census_mod", || { + patch_languages_consumer_census_mod(&fresh_dir.join("src")) + })?; time_phase(&mut phases, "assert_bootstrap_emit_core_support", || { assert_bootstrap_emit_core_support(&fresh_dir.join("src")) })?; @@ -742,6 +745,39 @@ fn patch_bootstrap_dag_collect(src_dir: &Path) -> Result<(), String> { Ok(()) } +/// Declare the hand-maintained `languages_consumer_census` module in the +/// generated `lib.rs`. +/// +/// `languages_consumer_census.rs` is a hand-maintained v1 seed module (the v2 +/// authority is the lens `src/v2/lens/languages_consumer_census.dag`); it is +/// copied into the fresh crate by `copy_hand_maintained_support` and consumed by +/// `v1_interpreter.rs`. Unlike its sibling lens/projection modules, it is +/// uniquely absent from the emitter's `all_module_files`, so +/// `emit_lib_rs_from_files` (src/v1/05_emit_rust.dag) does not write a +/// `pub mod languages_consumer_census;` for it and the fresh crate fails to +/// resolve `crate::languages_consumer_census::*`. Inject the declaration here, +/// mirroring `patch_bootstrap_dag_collect`. +/// +/// DISSOLUTION: remove this patch once 05_emit_rust.dag's `all_module_files` +/// (or its `hand_maintained_mods` emission path) includes +/// `languages_consumer_census`, so the emitter declares it directly (single +/// authority — the §3 parallel-ledger note on `HAND_MAINTAINED_STAGE0_FILES`). +fn patch_languages_consumer_census_mod(src_dir: &Path) -> Result<(), String> { + let lib_path = src_dir.join("lib.rs"); + let mut lib_text = + fs::read_to_string(&lib_path).map_err(|e| format!("read {}: {e}", lib_path.display()))?; + if !lib_text.contains("pub mod languages_consumer_census;") { + // Insert after import_resolution_project so `cargo fmt` module order + // matches the committed lib.rs (emitter emits mods in sorted order). + lib_text = lib_text.replace( + "pub mod import_resolution_project;\n", + "pub mod import_resolution_project;\npub mod languages_consumer_census;\n", + ); + } + fs::write(&lib_path, lib_text).map_err(|e| format!("write {}: {e}", lib_path.display()))?; + Ok(()) +} + fn assert_no_local_delegated_fns(text: &str) -> Result<(), String> { let mut duplicates = Vec::new(); for symbol in DELEGATED_DAG_COLLECT_SYMBOLS { From d6b4c39689baca3decdc011d5bc452e42c23104e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:27:15 +0000 Subject: [PATCH 05/61] =?UTF-8?q?emit(List=20seed=20carrier):=20render=20L?= =?UTF-8?q?ist=20nominal=20as=20host=20Vec=20in=20seed=20branch=20(option?= =?UTF-8?q?=20d,=20container=20analogue=20of=20String/Nat)=20=E2=80=94=20g?= =?UTF-8?q?uarded,=20List-only,=20at=20the=202=20preserve-nominal=20sites;?= =?UTF-8?q?=20clears=20E0425/E0432=20for=20newly-enrolled=20std=20files=20?= =?UTF-8?q?(realization=5Fschedule=20Schedule,=20std=5Ftypes=20list=5Fleng?= =?UTF-8?q?th).=20v2-target=20faithful=20FreeMonoid=20untouched.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/v1/05_emit_rust.dag | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 62dc16332c5..529fd9f4278 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -288,6 +288,21 @@ fn rust_seed_host_numeric_alias(name: String, source_indices: Maphost / Nat->i64): in the v1-seed +// branch the List nominal renders as the HOST CONTAINER the v1_rt Vec ops already +// use, so the nominal resolves (E0425/E0432) in the type-rendering paths that +// preserve nominals (render_rust_applied_type fn-sigs, render_rust_alias_rhs_type). +// Carrier-specific (List only) and GUARDED — does NOT touch the general +// preserve-nominal alias-RHS policy for non-container nominals (FreeMonoid/Box) or +// the v2-TARGET faithful FreeMonoid representation. List ops stay Vec-based. +fn rust_seed_host_container_base(name: String, source_indices: Map) -> String? { + if name == "List" && rust_corpus_includes_v1_compiler(source_indices: source_indices) { + Present { value: "Vec" } + } else { + none + } +} + fn rust_named_type_base(name: String, source_indices: Map) -> String { if name == "Witness" || name == "witness" { "Witness" @@ -352,7 +367,10 @@ fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shar fn render_rust_applied_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let base_name = authored_name_at(source_indices: source_indices, node: n) - let base = rust_named_type_base(name: base_name, source_indices: source_indices) + let base = match rust_seed_host_container_base(name: base_name, source_indices: source_indices) { + Present { value: host } => host + Absent => rust_named_type_base(name: base_name, source_indices: source_indices) + } if n.children |> count == 0 { base } else { @@ -498,10 +516,13 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } else if n.connective == NoConnective && n.children |> count > 0 { let local_mod = module_to_filename(name: module_name) let def_mod = alias_rhs_rust_qualify_module_filename(name: name, alias_module: module_name, imports: imports, scope: scope, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) - let base = if def_mod != local_mod { - concat("crate::", def_mod, "::", name) - } else { - name + let base = match rust_seed_host_container_base(name: name, source_indices: source_indices) { + Present { value: host } => host + Absent => if def_mod != local_mod { + concat("crate::", def_mod, "::", name) + } else { + name + } } let peel = is_parametric_opaque_type_base(type_name: name, def_mod_filename: def_mod, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) let args = n.children |> map(arg => From 239ff284d507015329c68a7319fed64e6e62ed2f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:30:25 +0000 Subject: [PATCH 06/61] =?UTF-8?q?emit(Int=20generic-arg=20seed=20carrier):?= =?UTF-8?q?=20apply=20rust=5Fseed=5Fhost=5Fnumeric=5Falias=20at=20the=20ba?= =?UTF-8?q?re-nominal=20alias-RHS=20branch=20so=20Int/Nat=20as=20a=20gener?= =?UTF-8?q?ic=20ARG=20(Measure<...,Int>)=20lowers=20to=20i64=20in=20the=20?= =?UTF-8?q?seed,=20consistent=20with=20the=20type=20Int=20=3D=20i64=20alia?= =?UTF-8?q?s=20def=20=E2=80=94=20clears=20the=20std=5Fmeasure=20Int=20E042?= =?UTF-8?q?5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/v1/05_emit_rust.dag | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 529fd9f4278..95548474a12 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -502,6 +502,9 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name } else if n.connective == NoConnective && n.children |> count == 0 { + match rust_seed_host_numeric_alias(name: name, source_indices: source_indices) { + Present { value: host } => host + Absent => if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { render_rust_text_carrier(shared_types: shared_types) } else { @@ -513,6 +516,7 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } } } + } } else if n.connective == NoConnective && n.children |> count > 0 { let local_mod = module_to_filename(name: module_name) let def_mod = alias_rhs_rust_qualify_module_filename(name: name, alias_module: module_name, imports: imports, scope: scope, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) From a33c5aeaed1d94da72c4ea86932a5f740eec8427 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 20:34:44 +0000 Subject: [PATCH 07/61] Merge origin/main into emitter/seed-green-integration (resolve emitter conflicts) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolved 4 conflicts in src/v1/05_emit_rust.dag and 1 in width_nat_type_arg_test.rs: - render_rust_applied_type: keep branch's rust_seed_host_container_base (List->host Vec) - rust_phantom_marker_inner: take main's join() simplification (equivalent, supersedes Optional-peel) - emit_rust_expr_record_lit: take main's peeled_type_name refactor (branch lines were superseded duplicates) - phantom-field comment: take main's wording (matches the refactor) - machine_width test: keep active (un-ignore) — this branch carries the #5325 emitter fix the ignore waited on Co-Authored-By: Claude Opus 4.8 (1M context) --- src/v1/05_emit_rust.dag | 13 ------------- src/v1/tests/src/width_nat_type_arg_test.rs | 4 ---- 2 files changed, 17 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 5cb11492354..4e11c403b20 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -4993,12 +4993,6 @@ fn emit_rust_expr_record_lit(expr: Node, registry: Map, scope: // resolve exactly as the direct `Measure { .. }` literal already does. // For a non-alias literal `resolved_type` is already the concrete record, // and the expansion returns it unchanged. -<<<<<<< HEAD - let resolved_rt = resolved_type(n: expr) - let expanded_rt = expand_type_for_field_access(n: resolved_rt, env: scope.type_env, module_name: scope.module_name) - let raw = emit_typed_record_lit(type_name: tn, fields: fs, parent_enum: parent_enum, resolved_type: expanded_rt, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) -======= ->>>>>>> origin/main let si = scope.type_env.source_indices let resolved_rt = resolved_type(n: expr) let expanded_rt = expand_type_for_field_access(n: resolved_rt, env: scope.type_env, module_name: scope.module_name) @@ -6506,18 +6500,11 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St } // Populate the synthetic PhantomData field (E0392) whenever the target // struct carries unused generic params -- the construction counterpart -<<<<<<< HEAD - // of the phantom field appended in emit_struct_from_children. Keyed on - // the concrete struct decl (`tn` is the peeled struct name after the - // alias-peel above), so it fires for `Measure`/its aliases and stays - // silent for every fully-used-param struct and for enum variants. -======= // of the phantom field appended in emit_struct_from_children. `tn` here // is the CONCRETE struct name (the caller passes the peeled // `expanded_rt` name as type_name, not the alias), so this lookup hits // the `Measure` decl (connective==Conj) and fires for Measure/its // aliases, staying silent for every fully-used-param struct and variant. ->>>>>>> origin/main let phantom_strs = match lookup_type_by_name(env: scope.type_env, name: tn) { Present { value: struct_decl } => let is_struct = struct_decl.connective == Conj diff --git a/src/v1/tests/src/width_nat_type_arg_test.rs b/src/v1/tests/src/width_nat_type_arg_test.rs index 11a015b4fe6..0d202acaf6c 100644 --- a/src/v1/tests/src/width_nat_type_arg_test.rs +++ b/src/v1/tests/src/width_nat_type_arg_test.rs @@ -79,10 +79,6 @@ fn v1_std_float_dag_resolves_with_literal_machine_width() { } #[test] -<<<<<<< HEAD -======= -#[ignore = "emitter seed on main lacks dag fix until #5325 co-land; E0107 10→0 verified via 2-stage bootstrap"] ->>>>>>> origin/main fn machine_width_phantom_arg_rust_emit_peels_literal_width_to_unit() { use v1_compiler::cli_run; use v1_compiler::v1_compiler_artifact::RenderTarget; From 0a069ec0ef32286a30a4772bf63638472630a39d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 21:12:56 +0000 Subject: [PATCH 08/61] Re-ignore machine_width emit test: committed seed not yet regenerated The test runs compile_sources against the in-process lib (committed stage0 seed), whose emit_rust.rs does not yet carry this branch's .dag peel fix (branch updated 05_emit_rust.dag only, not the committed seed mirror). So it must stay #[ignore]d until the seed regen lands (Track A step 3 / 2-stage bootstrap). Reverts an over-eager un-ignore from the main merge. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/v1/tests/src/width_nat_type_arg_test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/v1/tests/src/width_nat_type_arg_test.rs b/src/v1/tests/src/width_nat_type_arg_test.rs index 0d202acaf6c..e71e7867c1d 100644 --- a/src/v1/tests/src/width_nat_type_arg_test.rs +++ b/src/v1/tests/src/width_nat_type_arg_test.rs @@ -79,6 +79,7 @@ fn v1_std_float_dag_resolves_with_literal_machine_width() { } #[test] +#[ignore = "fix is in the .dag emitter (05_emit_rust) on this branch, but the in-process lib (committed stage0 seed) is not yet regenerated, so compile_sources here still uses the un-peeled emitter; un-ignore after the seed regen lands (2-stage bootstrap), per Track A step 3"] fn machine_width_phantom_arg_rust_emit_peels_literal_width_to_unit() { use v1_compiler::cli_run; use v1_compiler::v1_compiler_artifact::RenderTarget; From 2018cd879a6ff92e28e888df33e4580725e1e5dd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 21:23:05 +0000 Subject: [PATCH 09/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- dsl/std/measure.dag | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dsl/std/measure.dag b/dsl/std/measure.dag index 851f2563e25..54247aea4dd 100644 --- a/dsl/std/measure.dag +++ b/dsl/std/measure.dag @@ -392,7 +392,7 @@ fn gibibyte(count: Nat) -> Gibibyte { } fn gibibyte_count(g: Gibibyte) -> Nat { - g.count + measure_count(g) } fn gibibyte_to_byte_size(g: Gibibyte) -> ByteSize { @@ -444,7 +444,7 @@ fn watt(count: Nat) -> Watt { } fn watt_count(w: Watt) -> Nat { - w.count + measure_count(w) } fn celsius(count: Int) -> Celsius { @@ -452,7 +452,7 @@ fn celsius(count: Int) -> Celsius { } fn celsius_count(c: Celsius) -> Int { - c.count + measure_count(c) } fn rpm(count: Nat) -> RevolutionsPerMinute { @@ -460,7 +460,7 @@ fn rpm(count: Nat) -> RevolutionsPerMinute { } fn rpm_count(r: RevolutionsPerMinute) -> Nat { - r.count + measure_count(r) } // --- MoneyAmount: price magnitude carrier ------------------------------ @@ -509,7 +509,7 @@ fn money_amount_micro(count: Nat) -> MoneyAmountMicro { } fn money_amount_micro_count(m: MoneyAmountMicro) -> Nat { - m.count + measure_count(m) } fn byte_size(count: Nat) -> ByteSize { @@ -517,7 +517,7 @@ fn byte_size(count: Nat) -> ByteSize { } fn byte_size_count(b: ByteSize) -> Nat { - b.count + measure_count(b) } fn bit_width(count: Nat) -> BitWidth { @@ -525,7 +525,7 @@ fn bit_width(count: Nat) -> BitWidth { } fn bit_width_count(b: BitWidth) -> Nat { - b.count + measure_count(b) } fn hertz(count: Nat) -> Hertz { @@ -533,7 +533,7 @@ fn hertz(count: Nat) -> Hertz { } fn hertz_count(h: Hertz) -> Nat { - h.count + measure_count(h) } fn hardware_thread_count(count: Nat) -> HardwareThreadCount { @@ -541,5 +541,5 @@ fn hardware_thread_count(count: Nat) -> HardwareThreadCount { } fn hardware_thread_count_value(t: HardwareThreadCount) -> Nat { - t.count + measure_count(t) } From 9cf103f1dfe3d4d1e6e52f2d28b24849a2064f3d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 21:33:38 +0000 Subject: [PATCH 10/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 86 +++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 28 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 4e11c403b20..406a4423802 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -2973,35 +2973,65 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map count) == 0 && rust_nominal_identity_carrier_type_eligible(type_name: item_text) { rust_nominal_identity_carrier_def(name: item_text) - } else if is_emittable_parametric_type_alias_item(item: item, item_text: item_text, source_indices: env.source_indices, module_name: module_name, imports: imports, scope: scope, registry: registry, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index) { - let type_params = emit_type_params(params: item.params, source_indices: env.source_indices) - let generic_names = item_generic_param_names(item: item, source_indices: env.source_indices) - concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword, - " ", - item_text, - type_params, - " = ", - render_rust_alias_rhs_type( - n: resolved_type(n: item), - generic_param_names: generic_names, - shared_types: shared_types, - source_indices: env.source_indices, - scope: scope, - imports: imports, - registry: registry, - module_name: module_name, - export_sets: export_sets, - typed_modules: typed_modules, - module_index: module_index, - variant_to_enum: emit_info.variant_to_enum), - ";" - ) - } else if is_parametric_opaque_type_decl_item(item: item, source_indices: env.source_indices) { - emit_parametric_phantom_opaque_struct(item: item, source_indices: env.source_indices) } else { - "" + // Seed corpus: a canonical container decl (`type List = + // FreeMonoid`) is NOT emittable-parametric (its FreeMonoid RHS + // shell has no Rust nominal authority), so it would skip to `""` and leave + // `List` undefined while the seed still references it (`list_length`'s + // `Rc>` sig, consumers' `use crate::std_types::List`). Emit it as a + // host-container alias (`pub type List = Vec`) so every + // `List` reference + import resolves. Corpus-gated via + // `rust_seed_host_container_base` (List-only, v1-compiler seed only); the + // faithful v2-target emit keeps the FreeMonoid algebra (Absent → existing + // path). Dissolves with the seed. + match rust_seed_host_container_base(name: item_text, source_indices: env.source_indices) { + Present { value: host } => + let type_params = emit_type_params(params: item.params, source_indices: env.source_indices) + let generic_names = item_generic_param_names(item: item, source_indices: env.source_indices) + concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword, + " ", + item_text, + type_params, + " = ", + host, + "<", + generic_names |> join(separator: ", "), + ">;" + ) + Absent => + if is_emittable_parametric_type_alias_item(item: item, item_text: item_text, source_indices: env.source_indices, module_name: module_name, imports: imports, scope: scope, registry: registry, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index) { + let type_params = emit_type_params(params: item.params, source_indices: env.source_indices) + let generic_names = item_generic_param_names(item: item, source_indices: env.source_indices) + concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword, + " ", + item_text, + type_params, + " = ", + render_rust_alias_rhs_type( + n: resolved_type(n: item), + generic_param_names: generic_names, + shared_types: shared_types, + source_indices: env.source_indices, + scope: scope, + imports: imports, + registry: registry, + module_name: module_name, + export_sets: export_sets, + typed_modules: typed_modules, + module_index: module_index, + variant_to_enum: emit_info.variant_to_enum), + ";" + ) + } else if is_parametric_opaque_type_decl_item(item: item, source_indices: env.source_indices) { + emit_parametric_phantom_opaque_struct(item: item, source_indices: env.source_indices) + } else { + "" + } + } } } else if is_function_item(item: item) { let fn_movable = match map_get(emit_info.ownership_index, qualified_name) { From cb921c139e7bdf801dbaca44ff0b7bdd5c057ecd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 21:54:40 +0000 Subject: [PATCH 11/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/probe_emit_interp.dag | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/v1/probe_emit_interp.dag diff --git a/src/v1/probe_emit_interp.dag b/src/v1/probe_emit_interp.dag new file mode 100644 index 00000000000..9ecb99f61b7 --- /dev/null +++ b/src/v1/probe_emit_interp.dag @@ -0,0 +1,28 @@ +// TEMPORARY PROBE (not floor-enrolled): answers parent's ONE FACT — +// can the v2 interpreter RUN 05_emit_rust.dag's emit fold so a .dag emitter +// fix verifies BY INTERPRETATION (no seed-mirror regen)? +// +// Run: gunbc run --source-root src/v1 --source-root dsl \ +// --entry src/v1/probe_emit_interp.dag --function probe_list_alias_peels_to_vec --claim-run +// +// The inline source path carries "src/v1" so rust_corpus_includes_v1_compiler +// fires, exercising my branch's `type List = FreeMonoid` -> +// `pub type List = Vec` emitter change. If the interpreter +// produces "Vec", emitter fixes ARE interpretation-verifiable. +module v1.probe.emit_interp + +import v1.compiler.compile { compile_sources, SourceFile } +import v1.compiler.artifact { RenderTarget, Rust } + +fn probe_source() -> SourceFile { + SourceFile { + path: "src/v1/probe_list.dag", + content: "module v1.probe.list\ntype FreeMonoid {\n empty: FreeMonoid\n}\ntype List = FreeMonoid\n" + } +} + +fn probe_list_alias_peels_to_vec() -> Bool { + let result = compile_sources(sources: [probe_source()], target: Rust) + let emitted = result.files |> map(f => f.content) |> join(separator: "\n") + contains(emitted, "Vec") +} From eeec49ef2d5a4b3195b789d8db3b25d769c51ffa Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 22:05:11 +0000 Subject: [PATCH 12/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/stage0/src/v1_interpreter.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index 30a1ad0c925..0a078039a7d 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -3677,6 +3677,17 @@ fn eval_algebra_method( Ok(Value::Str(strs.join(&sep))) } + // chars(s) -> List: decompose a String into single-character + // strings (primitives.dag `chars_contract`). Free-call `chars(source)` + // desugars to receiver-style method dispatch here; the lexer + // (01_tokenize) drives it, so the interpreter must implement it to run + // the full compile/emit fold. + "chars" => { + let s = expect_str(Some(&receiver), "chars")?; + let items: Vec = s.chars().map(|c| Value::Str(c.to_string())).collect(); + Ok(list_value(items)) + } + // Map key lookup is checked BEFORE the FreeMonoid list path: a String IS a // FreeMonoid, but `.get` on a String is not char-list indexing (ctrl#1476 B1; // same Str-representation rule as `index` / `slice` / `contains`). @@ -5319,6 +5330,16 @@ fn eval_builtin( } } + // chars(s: String) -> List: decompose into single-character + // strings (primitives.dag `chars_contract`). Mirrors the emitted + // `v1_rt` char iteration; the lexer (01_tokenize) drives this, so it + // must exist for the interpreter to run the full compile/emit fold. + "chars" => { + let s = expect_str(positional.first().copied(), "chars")?; + let items: Vec = s.chars().map(|c| Value::Str(c.to_string())).collect(); + Ok(Some(list_value(items))) + } + "concat" => { // Variadic string concat (common in .dag code) if positional.len() >= 2 && positional.iter().all(|v| matches!(v, Value::Str(_))) { From 65e1f83cdb64847258ab6c0927d8252013615f83 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 22:15:39 +0000 Subject: [PATCH 13/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/stage0/src/v1_interpreter.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index 0a078039a7d..37f9d29fe78 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -3677,14 +3677,15 @@ fn eval_algebra_method( Ok(Value::Str(strs.join(&sep))) } - // chars(s) -> List: decompose a String into single-character - // strings (primitives.dag `chars_contract`). Free-call `chars(source)` - // desugars to receiver-style method dispatch here; the lexer - // (01_tokenize) drives it, so the interpreter must implement it to run - // the full compile/emit fold. + // chars(s) -> List: decompose a String into its Unicode code + // points (Ints), matching the emitted Rust template in + // languages.dag (`{recv}.chars().map(|c| c as i64).collect()`) and the + // lexer's `source_chars: List` consumer (01_tokenize). Free-call + // `chars(source)` desugars to receiver-style method dispatch here; the + // interpreter must implement it to run the full compile/emit fold. "chars" => { let s = expect_str(Some(&receiver), "chars")?; - let items: Vec = s.chars().map(|c| Value::Str(c.to_string())).collect(); + let items: Vec = s.chars().map(|c| Value::Int(c as i64)).collect(); Ok(list_value(items)) } @@ -5330,15 +5331,12 @@ fn eval_builtin( } } - // chars(s: String) -> List: decompose into single-character - // strings (primitives.dag `chars_contract`). Mirrors the emitted - // `v1_rt` char iteration; the lexer (01_tokenize) drives this, so it - // must exist for the interpreter to run the full compile/emit fold. - "chars" => { - let s = expect_str(positional.first().copied(), "chars")?; - let items: Vec = s.chars().map(|c| Value::Str(c.to_string())).collect(); - Ok(Some(list_value(items))) - } + // Source-char cost metering primitive (runtime_rust.dag): a zero-arg + // side-effecting host fn the lexer (01_tokenize) calls directly. The + // compiled seed records a counter; the interpreter has no such counter, + // so it is a no-op returning unit. Needed for the interpreter to run + // the full compile/emit fold. + "record_source_chars_index_lookup" => Ok(Some(Value::Unit)), "concat" => { // Variadic string concat (common in .dag code) From c0f35e09553d313294af6d4d776a39547ddcae87 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 22:21:41 +0000 Subject: [PATCH 14/61] Add lexer-layer host builtins to v2 interpreter (chars/chars_to_string/metering) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So `gunbc run` can interpret the live .dag compile/emit fold (compile_sources) WITHOUT regenerating the seed mirror — making a .dag emitter fix verifiable BY INTERPRETATION (DESIGN §5 green-by-execution, §7 self-host). Additive only (fills previously-erroring builtin cases; cannot regress existing behavior). Proven by execution: the interpreter now resolves the source closure and runs the full lexer (tokenize) over a probe source, advancing into parse/resolve. Remaining gaps are deeper interpreter semantics (e.g. raw_map_lookup on a plain Record), not missing builtins. - chars(s) -> List: code points (matches languages.dag emit template + lexer source_chars: List), method dispatch. - chars_to_string(List, start, end) -> String: code-point slice -> token text, free-fn dispatch. - record_source_chars_index_lookup(): no-op unit metering stub. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/v1_interpreter.rs | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index 37f9d29fe78..f113a2d3893 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -5323,6 +5323,39 @@ fn eval_builtin( _ => Ok(None), }, + // chars_to_string(chars: List, start, end) -> String: slice a + // code-point list [start, end) into a String (v1_rt::chars_to_string / + // languages.dag). The lexer builds token text this way, so the + // interpreter needs it to run the full compile/emit fold. + "chars_to_string" => { + let cps = match positional.first().copied() { + Some(v) => free_monoid_to_vec(v).ok_or_else(|| InterpError::TypeError { + msg: "chars_to_string expects a list of code points".to_string(), + })?, + None => { + return Err(InterpError::TypeError { + msg: "chars_to_string requires a code-point list".to_string(), + }) + } + }; + let len = cps.len() as i64; + let start = expect_int(positional.get(1).copied(), "chars_to_string start")? + .max(0) + .min(len); + let end = expect_int(positional.get(2).copied(), "chars_to_string end")? + .max(0) + .min(len) + .max(start); + let s: String = cps[start as usize..end as usize] + .iter() + .filter_map(|v| match v { + Value::Int(cp) => char::from_u32(*cp as u32), + _ => None, + }) + .collect(); + Ok(Some(Value::Str(s))) + } + "parse_int" => { let s = expect_str(positional.first().copied(), "parse_int")?; match s.parse::() { From 4a8afddf703a2f244ee37a6d5632e7d7e07d086d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 22:26:48 +0000 Subject: [PATCH 15/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/stage0/src/v1_interpreter.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index f113a2d3893..cb2b06bcdab 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -6514,12 +6514,17 @@ fn raw_map_lookup( Some(ck) => Ok(m.get(&ck).cloned().unwrap_or(Value::Null)), None => Ok(Value::Null), }, - Value::Record { fields, .. } | Value::Variant { fields, .. } => { + Value::Record { fields, type_name, .. } | Value::Variant { fields, variant_name: type_name, .. } => { let lookup_sym = ctx.sym("lookup"); let lookup = fields .get(&lookup_sym) .ok_or_else(|| InterpError::TypeError { - msg: format!("raw_map_lookup expects Map, got {}", map.type_label()), + msg: format!( + "raw_map_lookup expects Map, got {} (type={}, key={})", + map.type_label(), + resolve_sym(*type_name), + key + ), })?; match lookup { Value::Closure { .. } => apply_closure(lookup, &[key.clone()], env, ctx), From 63eba0e40a5f6539a2f29500ec09a8702a1296a0 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 22:36:49 +0000 Subject: [PATCH 16/61] Interpreter spike: additive record-form-map + list_push method dispatch Bounded spike (parent-approved) toward running the emit fold by interpretation. Both additive / non-regressing (fill previously-erroring cases): - raw_map_lookup: a Record without a callable `lookup` field is now treated as a record-form map (key looked up as a field name; miss -> Null -> Violates via the existing Witness bridge). Unblocks `data x: Map = { ... }` literals, which the interpreter builds as Records. (Deeper root: literals are never built as type-directed Maps; this handles it at the consumption site.) - list_push: dedicated method-dispatch arm (was free-fn only). Pushes the arg as a single element, unlike concat/append/push which merge a list-valued arg. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/v1_interpreter.rs | 63 ++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index cb2b06bcdab..ef4acb8f3ec 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -3524,6 +3524,33 @@ fn eval_algebra_method( }) } + // list_push(list, item): append the argument as a SINGLE element, even + // when it is itself a list (unlike concat/append/push below, which merge + // a list-valued arg). Mirrors the free-function list_push so the same op + // resolves through method dispatch too; the lexer drives it. Additive. + "list_push" => { + if matches!(&receiver, Value::Str(_)) { + return Err(InterpError::TypeError { + msg: "list_push not supported on String".to_string(), + }); + } + let item = args.first().cloned().unwrap_or(Value::Null); + match value_to_list_carrier(&receiver) { + Some((items, copied)) => { + let mut counters = ctx.mutation_counters.borrow_mut(); + counters.list_push_calls += 1; + counters.list_push_items_copied += copied; + drop(counters); + let mut result = (*items).clone(); + result.push_back(item); + Ok(list_value(result)) + } + None => Err(InterpError::TypeError { + msg: format!("list_push on non-list: {}", receiver.type_label()), + }), + } + } + "concat" | "append" | "push" => { // String concat preserves the String representation: a String IS a // FreeMonoid, but its canonical value form is Value::Str — concat must @@ -6514,27 +6541,33 @@ fn raw_map_lookup( Some(ck) => Ok(m.get(&ck).cloned().unwrap_or(Value::Null)), None => Ok(Value::Null), }, - Value::Record { fields, type_name, .. } | Value::Variant { fields, variant_name: type_name, .. } => { + Value::Record { fields, .. } | Value::Variant { fields, .. } => { let lookup_sym = ctx.sym("lookup"); - let lookup = fields - .get(&lookup_sym) - .ok_or_else(|| InterpError::TypeError { - msg: format!( - "raw_map_lookup expects Map, got {} (type={}, key={})", - map.type_label(), - resolve_sym(*type_name), - key - ), - })?; - match lookup { - Value::Closure { .. } => apply_closure(lookup, &[key.clone()], env, ctx), - Value::Fn { node } => { + match fields.get(&lookup_sym) { + // A lookup-table abstraction carries a callable `lookup` field. + Some(lookup @ Value::Closure { .. }) => { + apply_closure(lookup, &[key.clone()], env, ctx) + } + Some(Value::Fn { node }) => { let named = vec![(None, key.clone())]; call_function(ctx, node, &named, env) } - _ => Err(InterpError::TypeError { + Some(_) => Err(InterpError::TypeError { msg: "Map.lookup field is not callable".to_string(), }), + // Record-form map (a `data x: Map = { ... }` literal, which + // the interpreter builds as a Record): look the key up as a + // field name. A miss yields Null, which the Witness/Optional + // bridge projects to Violates/Absent (see eval_match_pattern's + // record-form empty_map handling). Additive: this case + // previously errored. + None => match key { + Value::Str(s) => { + let k = ctx.sym(s); + Ok(fields.get(&k).cloned().unwrap_or(Value::Null)) + } + _ => Ok(Value::Null), + }, } } _ => Err(InterpError::TypeError { From 5f9d24c9f883853587bdd3e42c4769ed86075ec5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sun, 21 Jun 2026 22:49:19 +0000 Subject: [PATCH 17/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- dsl/product/compute_fabric.dag | 6 +++++- dsl/product/hardware_selection.dag | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dsl/product/compute_fabric.dag b/dsl/product/compute_fabric.dag index a3ef95c61c6..160793d80ad 100644 --- a/dsl/product/compute_fabric.dag +++ b/dsl/product/compute_fabric.dag @@ -42,6 +42,7 @@ import std.measure { HardwareThreadCount, byte_size, byte_size_count, + measure_count, hardware_thread_count, hardware_thread_count_value, hertz, @@ -151,7 +152,10 @@ fn money_micros(count: Nat) -> MoneyMicros { } fn money_micros_count(m: MoneyMicros) -> Nat { - m.count + // Cross-module Measure alias (MoneyAmount): `.count` only peels where + // Measure is local, so route through the generic std.measure.measure_count + // accessor (same pattern as bandwidth_count in hardware_selection). + measure_count(m: m) } type ProviderIdentity = NonEmptyStr where brand("ProviderIdentity") diff --git a/dsl/product/hardware_selection.dag b/dsl/product/hardware_selection.dag index 08d31925673..5be7de40518 100644 --- a/dsl/product/hardware_selection.dag +++ b/dsl/product/hardware_selection.dag @@ -76,7 +76,10 @@ fn milliwatt(count: Nat) -> Milliwatt { } fn milliwatt_count(w: Milliwatt) -> Nat { - w.count + // Cross-module Measure alias (Measure): `.count` only peels + // where Measure is local, so route through the generic std.measure.measure_count + // accessor (same pattern as bandwidth_count below). + measure_count(m: w) } // === The decision point: five grounded axes ============================== From dd81e676d88c7d8557dfc93db19f9205c98dfc79 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 01:27:02 +0000 Subject: [PATCH 18/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 406a4423802..f1dd6a3628b 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -7106,7 +7106,12 @@ fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: L Absent => concat(log_line, "\ncompile_error!(\"mock property list was non-empty but first() returned None\")") } } else { - concat(log_line, "\ncompile_error!(\"no mock data available for dry-run operation: ", op_name, "\")") + // Missing dry-run fixture is a RUNTIME condition (is_dry_run() && no mock + // data), not a compile-time one — emitting compile_error! here gated a + // runtime state at compile time (§5 category error), making the whole + // emitted crate fail to build whenever any service op lacks a fixture. + // Fail closed at runtime instead: a loud panic on the unprovisioned path. + concat(log_line, "\npanic!(\"no mock data available for dry-run operation: ", op_name, "\")") } } From 2d0df5e7e1fd025068fcb9ce3bfe804dd15025b1 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 01:37:30 +0000 Subject: [PATCH 19/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/probe_emit_interp.dag | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/v1/probe_emit_interp.dag diff --git a/src/v1/probe_emit_interp.dag b/src/v1/probe_emit_interp.dag deleted file mode 100644 index 9ecb99f61b7..00000000000 --- a/src/v1/probe_emit_interp.dag +++ /dev/null @@ -1,28 +0,0 @@ -// TEMPORARY PROBE (not floor-enrolled): answers parent's ONE FACT — -// can the v2 interpreter RUN 05_emit_rust.dag's emit fold so a .dag emitter -// fix verifies BY INTERPRETATION (no seed-mirror regen)? -// -// Run: gunbc run --source-root src/v1 --source-root dsl \ -// --entry src/v1/probe_emit_interp.dag --function probe_list_alias_peels_to_vec --claim-run -// -// The inline source path carries "src/v1" so rust_corpus_includes_v1_compiler -// fires, exercising my branch's `type List = FreeMonoid` -> -// `pub type List = Vec` emitter change. If the interpreter -// produces "Vec", emitter fixes ARE interpretation-verifiable. -module v1.probe.emit_interp - -import v1.compiler.compile { compile_sources, SourceFile } -import v1.compiler.artifact { RenderTarget, Rust } - -fn probe_source() -> SourceFile { - SourceFile { - path: "src/v1/probe_list.dag", - content: "module v1.probe.list\ntype FreeMonoid {\n empty: FreeMonoid\n}\ntype List = FreeMonoid\n" - } -} - -fn probe_list_alias_peels_to_vec() -> Bool { - let result = compile_sources(sources: [probe_source()], target: Rust) - let emitted = result.files |> map(f => f.content) |> join(separator: "\n") - contains(emitted, "Vec") -} From be5255989352b9d2b41dd6c0824952980dff4708 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 01:51:00 +0000 Subject: [PATCH 20/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 8588f1532c4..c504a0bc41b 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -18390,11 +18390,18 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } } } else { + // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single + // authority): compile_error! -> panic! in the dry-run missing-fixture branch. + // Applied by hand because regen-fixpoint is temporarily broken (§7 hole, routed + // to the lockstep lane snappy-swift-91 / #5325). DISSOLUTION: when regen-fixpoint + // is restored, a clean regen reproduces this line from the .dag — delete this + // hand-patch; the dissolution check is regen-output == this mirror modulo + // HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( log_line, - "\ncompile_error!(\"no mock data available for dry-run operation: " + "\npanic!(\"no mock data available for dry-run operation: " .to_string(), ), op_name.clone(), From 23015bb61cbe4bed4b8871f670e2edb328050aa4 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 01:53:49 +0000 Subject: [PATCH 21/61] Route-A class 1/6: correct splice dissolution pointer to adhoc-1bdd0259-2e3 The HAND-APPLIED-REGEN-MIRROR-SYNC mark previously pointed at snappy-swift-91 / #5325 (done-but-re-drifted, unreachable). The live dissolution lane is bright-stag's adhoc-1bdd0259-2e3: re-repair the 18-error regen-fixpoint hole + add a regen-equals-committed CI drift-gate so a main-merge can never silently re-drift the fixpoint. Comment-only; the panic! splice (code) is unchanged. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index c504a0bc41b..7ab128cb294 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -18392,11 +18392,11 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } else { // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single // authority): compile_error! -> panic! in the dry-run missing-fixture branch. - // Applied by hand because regen-fixpoint is temporarily broken (§7 hole, routed - // to the lockstep lane snappy-swift-91 / #5325). DISSOLUTION: when regen-fixpoint - // is restored, a clean regen reproduces this line from the .dag — delete this - // hand-patch; the dissolution check is regen-output == this mirror modulo - // HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. + // Applied by hand because regen-fixpoint is temporarily broken (§7 hole). + // DISSOLUTION lane: bright-stag's adhoc-1bdd0259-2e3 (re-repair the hole + add a + // regen-equals-committed CI drift-gate). When it lands, a clean regen reproduces + // this line from the .dag — delete this hand-patch; the dissolution check is + // regen-output == this mirror modulo HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( From ffb12b46848352bf1148ede0fd4a42e066c4655a Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 02:01:33 +0000 Subject: [PATCH 22/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 6 +++++- src/v1/stage0/src/v1_compiler_emit_rust.rs | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index f1dd6a3628b..26916fa93c3 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1580,7 +1580,11 @@ fn emit_lib_rs_from_files(all_module_files: List, has_compiler_tests: } let shared_types = emit_non_empty_wrappers() let content = concat("// Generated by v1 compiler -- do not edit.\n\n", - "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n\n", + "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n", + // serde_json::json! expands recursively (json_internal! TT-munching); larger emitted + // test literals exceed rustc's default macro recursion_limit of 128. Raise it crate-wide + // -- serde_json's own documented fix, a crate-config attribute, not a per-literal change. + "#![recursion_limit = \"256\"]\n\n", mod_decls |> join(separator: "\n"), hand_maintained_mods, "\n\n", shared_types, diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 7ab128cb294..e01454edf8c 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -2762,7 +2762,10 @@ pub fn emit_lib_rs_from_files( "".to_string() }; let shared_types = emit_non_empty_wrappers(); - let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); + // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (single authority): + // crate-root #![recursion_limit = "256"] added (serde_json::json! recursion fix). + // DISSOLUTION lane adhoc-1bdd0259-2e3; a clean regen reproduces this from the .dag. + let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), "lib".to_string()), From fc5a9ecaba60747d3164d952f59ce65b73a7c7b2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 02:18:32 +0000 Subject: [PATCH 23/61] Route-A: rustfmt the fixture-lever mirror splice (CI fmt gate) The compile_error! -> panic! mirror splice shortened the string literal, so rustfmt joins it onto one line (the original was split for the longer compile_error! form). Hand-edit fmt-drift; cargo fmt --all applied. No code change -- the splice is identical, only formatting. Restores rust_monolith_gate fmt --all --check green on #5481. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index e01454edf8c..2f8f22d77f7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -18404,8 +18404,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con v1_rt::concat( v1_rt::concat( log_line, - "\npanic!(\"no mock data available for dry-run operation: " - .to_string(), + "\npanic!(\"no mock data available for dry-run operation: ".to_string(), ), op_name.clone(), ), From 751dfa94bfb367bfc2efe93f761d0eec3a88e83d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 02:42:01 +0000 Subject: [PATCH 24/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/04_emit_info.dag | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/v1/04_emit_info.dag b/src/v1/04_emit_info.dag index 36eb082824a..e9e385f05f1 100644 --- a/src/v1/04_emit_info.dag +++ b/src/v1/04_emit_info.dag @@ -41,6 +41,20 @@ type TypeSummary { has_fn_fields: Bool } +// RustCorpusRepr: which container/text REALIZATION HANDLER the Rust emitter +// selects for the WHOLE corpus. The spec is unchanged (List = FreeMonoid +// at std/types.dag; String) — this names WHICH of the §2 N handlers realizes it. +// It is a whole-CORPUS property, computed ONCE at the emit boundary +// (rust_corpus_repr in 05_emit_rust.dag) and threaded down as an individual +// emit-info field (like shared_types), never decided per-module: a corpus that +// bundles any v1 seed source (src/v1) emits the HOST representation end-to-end +// (§7 — the bootstrap seed is host: List→Vec, String, Nat/Int→i64); a pure v2 +// target keeps the faithful FreeMonoid carrier. Selecting once and threading the +// selection makes per-module divergence UNWRITABLE (§5 construction-not-check). +// §6-TRANSITIONAL: HostNative dissolves when src/v1 is deleted (seed→0 ⇒ no seed +// source ⇒ rust_corpus_repr is FaithfulFreeMonoid uniformly). +type RustCorpusRepr = HostNative | FaithfulFreeMonoid + // EmitGraphInfo: the reconcile→emit boundary contract. // // Invariant: emit never calls back into infer. All data the emitter needs @@ -78,6 +92,12 @@ type EmitGraphInfo { // (no Consumed) and fan-out > 1. These can be passed by borrow (&Rc). read_only_params_index: Map> read_only_params: Set + // Corpus-global Rust container/text realization handler (§2 one-spec-N-handlers). + // Computed ONCE at the emit boundary (rust_corpus_repr) and read by the + // type-renderers' leaf gates (rust_seed_host_container_base / _numeric_alias / + // rust_named_type_base) so every module emits the SAME representation — the + // single authority for the host-vs-faithful selection. §6-transitional. + corpus_repr: RustCorpusRepr } type EmitInfoBuildState { @@ -100,7 +120,10 @@ fn empty_emit_graph_info() -> EmitGraphInfo { variant_to_enum: empty_map(), owned_bindings: empty_set(), read_only_params_index: empty_map(), - read_only_params: empty_set() + read_only_params: empty_set(), + // Default to the faithful v2-target carrier; emit_rust overrides to HostNative + // for a corpus that bundles v1 seed source (rust_corpus_repr, computed once). + corpus_repr: FaithfulFreeMonoid } } From f5bef4afcf0e4b214164a55af354514adb0b023c Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 02:47:19 +0000 Subject: [PATCH 25/61] WIP class-3 computation layer: corpus_repr single authority (inert, .dag-only) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foundational half of the class-3 corpus-representation-coherence fix (the realization-layer handler-selection root behind the 26 List + 15 generic-syntax census errors). Adds the named selector RustCorpusRepr = HostNative | FaithfulFreeMonoid (04_emit_info.dag, auto-committed) and computes it ONCE as the single authority in build_emit_graph_info (rust_corpus_repr over the whole module corpus), threading it as the corpus_repr field through all 7 EmitGraphInfo construction sites (each COPIES the field, never recomputes — quick-seal's field=authority/param=read invariant). INERT checkpoint: the type-renderer leaf gates still read the old per-module rust_corpus_includes_v1_compiler/rust_emit_faithful_text_carrier, so emitted output is byte-unchanged. Typechecks clean via the existing binary (0 diagnostics, 410 files emitted). The gate-switch + ~15-fn corpus_repr threading + leaf-fn param swap + dead-gate deletion + exact mirror transcription land in the next pass, then the full-loop census oracle. Realization-layer coherence fix, not a model change (List=FreeMonoid at std/types.dag:227 untouched). Carrier B-home, idiom-threaded (per quick-seal). adhoc-1bdd0259-2e3 dissolution lane. #5481. Co-Authored-By: Claude Opus 4.8 --- src/v1/04_infer.dag | 17 ++++++++++++++++- src/v1/05_emit_rust.dag | 15 ++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index f57bef1be86..3de73f94237 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -6384,6 +6384,20 @@ fn build_positional_payload_variants(modules: List, type_summaries: ) } +// Corpus-global Rust representation selector (§2 handler selection). HostNative +// iff the corpus bundles any v1 seed source (src/v1) — then the whole crate emits +// the host representation (List→Vec, String, Nat/Int→i64) so the bootstrap seed +// compiles (§7); otherwise the faithful v2-target FreeMonoid carrier. Computed +// ONCE here (the single authority on EmitGraphInfo.corpus_repr); every emit site +// COPIES the field and the type-renderers READ it — never recomputed downstream, +// which is what makes per-module representation divergence unwritable (§5). +// §6-transitional: collapses to FaithfulFreeMonoid when src/v1 is deleted. +fn rust_corpus_repr(modules: List) -> RustCorpusRepr { + let has_seed = modules |> any(m => + map_keys(m.type_env.source_indices) |> any(k => contains(k, "/v1/") || contains(k, "src/v1"))) + if has_seed { HostNative } else { FaithfulFreeMonoid } +} + fn build_emit_graph_info(modules: List) -> EmitGraphInfo { let init = EmitInfoBuildState { type_summaries: empty_map() @@ -6412,7 +6426,8 @@ fn build_emit_graph_info(modules: List) -> EmitGraphInfo { variant_to_enum: vtoe, owned_bindings: empty_set(), read_only_params_index: empty_map(), - read_only_params: empty_set() + 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 26916fa93c3..a4074a82d99 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1496,7 +1496,8 @@ fn emit_rust(typed: ResolvedGraph) -> EmitResult { variant_to_enum: base_info.variant_to_enum, owned_bindings: empty_set(), read_only_params_index: ownership.read_only_params_index, - read_only_params: empty_set() + read_only_params: empty_set(), + corpus_repr: base_info.corpus_repr } let shared_types = emit_info.shared_types let registry = typed.item_registry @@ -1612,7 +1613,8 @@ fn emit_module(typed_module: TypedModule, registry: Map) -> Te variant_to_enum: base_info.variant_to_enum, owned_bindings: empty_set(), read_only_params_index: base_info.read_only_params_index, - read_only_params: empty_set() + read_only_params: empty_set(), + corpus_repr: base_info.corpus_repr } let shared_types = emit_info.shared_types let export_sets = build_module_export_sets(modules: [typed_module]) @@ -3060,7 +3062,8 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map emit_info } @@ -5716,7 +5720,8 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod variant_to_enum: emit_info.variant_to_enum, owned_bindings: emit_info.owned_bindings, read_only_params_index: emit_info.read_only_params_index, - read_only_params: emit_info.read_only_params + read_only_params: emit_info.read_only_params, + corpus_repr: emit_info.corpus_repr } Absent => emit_info } From aeb61f68adcb95c90b08d78e777639c285480e02 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 03:13:27 +0000 Subject: [PATCH 26/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index a4074a82d99..aa152d4d6a5 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -280,8 +280,8 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // i64, so the alias-RHS override alone clears them and the Nat-as-number consumers // (E0277/E0369). DISSOLUTION: remove when the numeric tower gains a faithful // host-realization seam mirroring the text carrier (emit_rust_host_to_dag_string_via_seam). -fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { - if (name == "Nat" || name == "Int") && rust_corpus_includes_v1_compiler(source_indices: source_indices) { +fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> String? { + if (name == "Nat" || name == "Int") && corpus_repr == HostNative { Present { value: "i64" } } else { none @@ -295,18 +295,18 @@ fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { - if name == "List" && rust_corpus_includes_v1_compiler(source_indices: source_indices) { +fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> String? { + if name == "List" && corpus_repr == HostNative { Present { value: "Vec" } } else { none } } -fn rust_named_type_base(name: String, source_indices: Map) -> String { +fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { if name == "Witness" || name == "witness" { "Witness" - } else if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { + } else if name == "String" && corpus_repr == FaithfulFreeMonoid { "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) From e5b0ca0f7627e50f4c8ef6192d9c95150295f21e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 03:16:21 +0000 Subject: [PATCH 27/61] Revert "WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra" This reverts commit aeb61f68adcb95c90b08d78e777639c285480e02. --- src/v1/05_emit_rust.dag | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index aa152d4d6a5..a4074a82d99 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -280,8 +280,8 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // i64, so the alias-RHS override alone clears them and the Nat-as-number consumers // (E0277/E0369). DISSOLUTION: remove when the numeric tower gains a faithful // host-realization seam mirroring the text carrier (emit_rust_host_to_dag_string_via_seam). -fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> String? { - if (name == "Nat" || name == "Int") && corpus_repr == HostNative { +fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { + if (name == "Nat" || name == "Int") && rust_corpus_includes_v1_compiler(source_indices: source_indices) { Present { value: "i64" } } else { none @@ -295,18 +295,18 @@ fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> St // Carrier-specific (List only) and GUARDED — does NOT touch the general // preserve-nominal alias-RHS policy for non-container nominals (FreeMonoid/Box) or // the v2-TARGET faithful FreeMonoid representation. List ops stay Vec-based. -fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> String? { - if name == "List" && corpus_repr == HostNative { +fn rust_seed_host_container_base(name: String, source_indices: Map) -> String? { + if name == "List" && rust_corpus_includes_v1_compiler(source_indices: source_indices) { Present { value: "Vec" } } else { none } } -fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { +fn rust_named_type_base(name: String, source_indices: Map) -> String { if name == "Witness" || name == "witness" { "Witness" - } else if name == "String" && corpus_repr == FaithfulFreeMonoid { + } else if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) From 6cf05a78050430771a1c1e92f31fa7d3d52ce8af Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 03:39:02 +0000 Subject: [PATCH 28/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index a4074a82d99..aa152d4d6a5 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -280,8 +280,8 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // i64, so the alias-RHS override alone clears them and the Nat-as-number consumers // (E0277/E0369). DISSOLUTION: remove when the numeric tower gains a faithful // host-realization seam mirroring the text carrier (emit_rust_host_to_dag_string_via_seam). -fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { - if (name == "Nat" || name == "Int") && rust_corpus_includes_v1_compiler(source_indices: source_indices) { +fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> String? { + if (name == "Nat" || name == "Int") && corpus_repr == HostNative { Present { value: "i64" } } else { none @@ -295,18 +295,18 @@ fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { - if name == "List" && rust_corpus_includes_v1_compiler(source_indices: source_indices) { +fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> String? { + if name == "List" && corpus_repr == HostNative { Present { value: "Vec" } } else { none } } -fn rust_named_type_base(name: String, source_indices: Map) -> String { +fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { if name == "Witness" || name == "witness" { "Witness" - } else if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { + } else if name == "String" && corpus_repr == FaithfulFreeMonoid { "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) From dee71b392863dac53999b01ddb50fe207a0f5abd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 03:48:14 +0000 Subject: [PATCH 29/61] Revert "WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra" This reverts commit 6cf05a78050430771a1c1e92f31fa7d3d52ce8af. --- src/v1/05_emit_rust.dag | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index aa152d4d6a5..a4074a82d99 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -280,8 +280,8 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // i64, so the alias-RHS override alone clears them and the Nat-as-number consumers // (E0277/E0369). DISSOLUTION: remove when the numeric tower gains a faithful // host-realization seam mirroring the text carrier (emit_rust_host_to_dag_string_via_seam). -fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> String? { - if (name == "Nat" || name == "Int") && corpus_repr == HostNative { +fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { + if (name == "Nat" || name == "Int") && rust_corpus_includes_v1_compiler(source_indices: source_indices) { Present { value: "i64" } } else { none @@ -295,18 +295,18 @@ fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> St // Carrier-specific (List only) and GUARDED — does NOT touch the general // preserve-nominal alias-RHS policy for non-container nominals (FreeMonoid/Box) or // the v2-TARGET faithful FreeMonoid representation. List ops stay Vec-based. -fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> String? { - if name == "List" && corpus_repr == HostNative { +fn rust_seed_host_container_base(name: String, source_indices: Map) -> String? { + if name == "List" && rust_corpus_includes_v1_compiler(source_indices: source_indices) { Present { value: "Vec" } } else { none } } -fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { +fn rust_named_type_base(name: String, source_indices: Map) -> String { if name == "Witness" || name == "witness" { "Witness" - } else if name == "String" && corpus_repr == FaithfulFreeMonoid { + } else if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) From 8f95dc3372aefff1012c8a537f5a9d62b172e251 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 04:15:03 +0000 Subject: [PATCH 30/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index a4074a82d99..aa152d4d6a5 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -280,8 +280,8 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // i64, so the alias-RHS override alone clears them and the Nat-as-number consumers // (E0277/E0369). DISSOLUTION: remove when the numeric tower gains a faithful // host-realization seam mirroring the text carrier (emit_rust_host_to_dag_string_via_seam). -fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { - if (name == "Nat" || name == "Int") && rust_corpus_includes_v1_compiler(source_indices: source_indices) { +fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> String? { + if (name == "Nat" || name == "Int") && corpus_repr == HostNative { Present { value: "i64" } } else { none @@ -295,18 +295,18 @@ fn rust_seed_host_numeric_alias(name: String, source_indices: Map) -> String? { - if name == "List" && rust_corpus_includes_v1_compiler(source_indices: source_indices) { +fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> String? { + if name == "List" && corpus_repr == HostNative { Present { value: "Vec" } } else { none } } -fn rust_named_type_base(name: String, source_indices: Map) -> String { +fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { if name == "Witness" || name == "witness" { "Witness" - } else if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { + } else if name == "String" && corpus_repr == FaithfulFreeMonoid { "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) From 86f71b06583f90e35274ce09fd5e401ad29a1ed6 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 04:25:33 +0000 Subject: [PATCH 31/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 210 ++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 104 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index aa152d4d6a5..8133e050f6f 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -158,25 +158,25 @@ import v1.compiler.emit_core_support { is_bare_leaf_item } -fn render_rust_type(n: Node, shared_types: Set, source_indices: Map) -> String { +fn render_rust_type(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { match n.inferred { Present { value: TypeVariable { id: tv } } => tv _ => match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { Present { value: applied } => if applied.children |> count > 0 { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) + render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } else { - render_rust_type_without_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type_without_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } - Absent => render_rust_type_without_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) + Absent => render_rust_type_without_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } } -fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, source_indices: Map) -> String { +fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { - render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) + render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } else if node_is_set_collection(n: n, source_indices: source_indices) { match n.children |> first { Present { value: elem_child } => @@ -194,7 +194,7 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, } } else { let tn = authored_name_at(source_indices: source_indices, node: n) - if tn == "String" && n.children |> count == 0 && rust_emit_faithful_text_carrier(source_indices: source_indices) { + if tn == "String" && n.children |> count == 0 && corpus_repr == FaithfulFreeMonoid { render_rust_text_carrier(shared_types: shared_types) } else { render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) @@ -342,34 +342,34 @@ fn is_parametric_opaque_type_base(type_name: String, def_mod_filename: String, t } } -fn render_rust_phantom_opaque_applied_type_arg(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { +fn render_rust_phantom_opaque_applied_type_arg(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { if is_width_nat_type_literal(n: n) { "()" } else { - render_rust_alias_rhs_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) + render_rust_alias_rhs_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } } -fn render_rust_phantom_opaque_applied_decl_arg(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn render_rust_phantom_opaque_applied_decl_arg(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { if is_width_nat_type_literal(n: n) { "()" } else { - render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } } -fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { match n.inferred { Present { value: TypeVariable { id: tv } } => tv - _ => render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + _ => render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } } -fn render_rust_applied_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn render_rust_applied_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let base_name = authored_name_at(source_indices: source_indices, node: n) - let base = match rust_seed_host_container_base(name: base_name, source_indices: source_indices) { + let base = match rust_seed_host_container_base(name: base_name, corpus_repr: corpus_repr) { Present { value: host } => host - Absent => rust_named_type_base(name: base_name, source_indices: source_indices) + Absent => rust_named_type_base(name: base_name, corpus_repr: corpus_repr) } if n.children |> count == 0 { base @@ -377,9 +377,9 @@ fn render_rust_applied_type(n: Node, generic_param_names: List, shared_t let peel = is_parametric_opaque_type_by_name(env: env, type_name: base_name) let args = n.children |> map(arg => if peel { - render_rust_phantom_opaque_applied_decl_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_phantom_opaque_applied_decl_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } else { - render_rust_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } ) |> join(separator: ", ") concat(base, "<", args, ">") @@ -393,15 +393,15 @@ fn render_rust_shared_type_if_needed(type_name: String, rendered: String, shared } // Single authority: shared_types decides Rc<> on rendered Rust type shells. -fn render_rust_applied_type_shared(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - let rendered = render_rust_applied_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) +fn render_rust_applied_type_shared(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { + let rendered = render_rust_applied_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) let type_name = authored_name_at(source_indices: source_indices, node: n) render_rust_shared_type_if_needed(type_name: type_name, rendered: rendered, shared_types: shared_types) } // Generic type-param leaves compose with the canonical renderer (else arm); // direct self-recursion on type-arg children keeps regen_stage0 stacker guard. -fn render_rust_decl_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn render_rust_decl_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let applied_prop = find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) let applied_overlay = match applied_prop { Present { value: applied } => @@ -410,12 +410,12 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type } match applied_overlay { Present { value: applied } => - render_rust_applied_type_shared(n: applied, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_applied_type_shared(n: applied, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) Absent => let name = authored_name_at(source_indices: source_indices, node: n) if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name - } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { + } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && name == "String" && corpus_repr == FaithfulFreeMonoid { render_rust_text_carrier(shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && set_contains(shared_types, name) { let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) @@ -424,20 +424,20 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type if !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) } else { - let base = rust_named_type_base(name: name, source_indices: source_indices) + let base = rust_named_type_base(name: name, corpus_repr: corpus_repr) let peel = is_parametric_opaque_type_by_name(env: env, type_name: name) let args = n.children |> map(arg => if peel { - render_rust_phantom_opaque_applied_decl_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_phantom_opaque_applied_decl_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } else { - render_rust_decl_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_decl_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } ) |> join(separator: ", ") let applied_ty = concat(base, "<", args, ">") render_rust_shared_type_if_needed(type_name: name, rendered: applied_ty, shared_types: shared_types) } } else { - render_rust_type_with_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type_with_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } } @@ -465,20 +465,20 @@ fn rust_fn_sig_peel_closed_alias(env: TypeEnv, n: Node) -> Bool { (binding.params |> count) == 0 } -fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let name = authored_name_at(source_indices: source_indices, node: n) - if n.connective == NoConnective && n.children |> count == 0 && name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { + if n.connective == NoConnective && n.children |> count == 0 && name == "String" && corpus_repr == FaithfulFreeMonoid { render_rust_text_carrier(shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) } else if generic_param_names |> count > 0 { - render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } else { - render_rust_fn_sig_type_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices, env: env) + render_rust_fn_sig_type_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, env: env) } } -fn render_rust_fn_sig_type_applied_binding(n: Node, shared_types: Set, source_indices: Map, env: TypeEnv) -> String { +fn render_rust_fn_sig_type_applied_binding(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, env: TypeEnv) -> String { match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { Present { value: applied } => if applied.children |> count > 0 { @@ -486,26 +486,26 @@ fn render_rust_fn_sig_type_applied_binding(n: Node, shared_types: Set, s if outer_name != "" && n.connective == NoConnective && (n.children |> count) == 0 && rust_fn_sig_peel_closed_alias(env: env, n: n) { render_rust_shared_type_if_needed(type_name: outer_name, rendered: outer_name, shared_types: shared_types) } else { - render_rust_type_with_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type_with_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } else { - render_rust_type_with_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type_with_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } - Absent => render_rust_type_with_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) + Absent => render_rust_type_with_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } // Alias RHS: preserve nominal DAG type names (FreeMonoid, Box) — no container coercion. // Qualify bases from defining modules when RHS type lives outside the alias module. -fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { +fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { let name = authored_name_at(source_indices: source_indices, node: n) if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name } else if n.connective == NoConnective && n.children |> count == 0 { - match rust_seed_host_numeric_alias(name: name, source_indices: source_indices) { + match rust_seed_host_numeric_alias(name: name, corpus_repr: corpus_repr) { Present { value: host } => host Absent => - if name == "String" && rust_emit_faithful_text_carrier(source_indices: source_indices) { + if name == "String" && corpus_repr == FaithfulFreeMonoid { render_rust_text_carrier(shared_types: shared_types) } else { match rust_opaque_kernel_alias_carrier(name: name) { @@ -520,7 +520,7 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } else if n.connective == NoConnective && n.children |> count > 0 { let local_mod = module_to_filename(name: module_name) let def_mod = alias_rhs_rust_qualify_module_filename(name: name, alias_module: module_name, imports: imports, scope: scope, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) - let base = match rust_seed_host_container_base(name: name, source_indices: source_indices) { + let base = match rust_seed_host_container_base(name: name, corpus_repr: corpus_repr) { Present { value: host } => host Absent => if def_mod != local_mod { concat("crate::", def_mod, "::", name) @@ -531,9 +531,9 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared let peel = is_parametric_opaque_type_base(type_name: name, def_mod_filename: def_mod, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) let args = n.children |> map(arg => if peel { - render_rust_phantom_opaque_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) + render_rust_phantom_opaque_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } else { - render_rust_alias_rhs_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) + render_rust_alias_rhs_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } ) |> join(separator: ", ") let applied_ty = concat(base, "<", args, ">") @@ -543,7 +543,7 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared applied_ty } } else { - render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } @@ -2957,7 +2957,7 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map concat(rust_visibility_prefix(), rust_items().type_alias_keyword, " ", item_text, " = ", host, ";") Absent => @@ -2965,6 +2965,7 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map let type_params = emit_type_params(params: item.params, source_indices: env.source_indices) let generic_names = item_generic_param_names(item: item, source_indices: env.source_indices) @@ -3021,6 +3022,7 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map, source_indices: Map) -> String { +fn render_rust_type_with_applied_binding(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { Present { value: applied } => if applied.children |> count > 0 { @@ -3324,28 +3326,28 @@ fn render_rust_type_with_applied_binding(n: Node, shared_types: Set, sou } else if set_contains(shared_types, outer_name) { render_rust_shared_type_if_needed(type_name: outer_name, rendered: outer_name, shared_types: shared_types) } else { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) + render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } } else { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) + render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } } else { - render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } - Absent => render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices) + Absent => render_rust_type(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } -fn render_rust_field_type_with_applied_binding(field: Node, shared_types: Set, source_indices: Map) -> String { +fn render_rust_field_type_with_applied_binding(field: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { let authored_type = field_node_type_expr(n: field) if find_property(props: field.properties, prop_name: "__applied_type_args", source_indices: source_indices) != none { - render_rust_type_with_applied_binding(n: field, shared_types: shared_types, source_indices: source_indices) + render_rust_type_with_applied_binding(n: field, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } else if find_property(props: authored_type.properties, prop_name: "__applied_type_args", source_indices: source_indices) != none { - render_rust_type_with_applied_binding(n: authored_type, shared_types: shared_types, source_indices: source_indices) + render_rust_type_with_applied_binding(n: authored_type, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } else if authored_type.connective == NoConnective && authored_type.children |> count > 0 { - render_rust_type(n: authored_type, shared_types: shared_types, source_indices: source_indices) + render_rust_type(n: authored_type, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } else { - render_rust_type_with_applied_binding(n: resolved_type(n: field), shared_types: shared_types, source_indices: source_indices) + render_rust_type_with_applied_binding(n: resolved_type(n: field), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } @@ -3355,11 +3357,11 @@ fn emit_struct_field_from_child(struct_name: String, child: Node, generic_param_ let ty = if generic_param_names |> count > 0 { render_node_type(n: rt_child, target: Rust, shared_types: shared_types, source_indices: env.source_indices) } else if find_property(props: child.properties, prop_name: "__applied_type_args", source_indices: env.source_indices) != none { - render_rust_type_with_applied_binding(n: child, shared_types: shared_types, source_indices: env.source_indices) + render_rust_type_with_applied_binding(n: child, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } else if find_property(props: authored_child_type.properties, prop_name: "__applied_type_args", source_indices: env.source_indices) != none { - render_rust_type_with_applied_binding(n: authored_child_type, shared_types: shared_types, source_indices: env.source_indices) + render_rust_type_with_applied_binding(n: authored_child_type, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } else if find_property(props: rt_child.properties, prop_name: "__applied_type_args", source_indices: env.source_indices) != none { - render_rust_type_with_applied_binding(n: rt_child, shared_types: shared_types, source_indices: env.source_indices) + render_rust_type_with_applied_binding(n: rt_child, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } else if is_product_type(n: rt_child) && rt_child.ident_span != none && rt_child.children |> count > 2 { let rt_child_name = authored_name_at(source_indices: env.source_indices, node: rt_child) match lookup_type_by_name(env: env, name: rt_child_name) { @@ -3370,12 +3372,12 @@ fn emit_struct_field_from_child(struct_name: String, child: Node, generic_param_ let with_params = concat(base, "<", param_names |> join(separator: ", "), ">") render_rust_shared_type_if_needed(type_name: rt_child_name, rendered: with_params, shared_types: shared_types) } else { - render_rust_type(n: rt_child, shared_types: shared_types, source_indices: env.source_indices) + render_rust_type(n: rt_child, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } - Absent => render_rust_type(n: rt_child, shared_types: shared_types, source_indices: env.source_indices) + Absent => render_rust_type(n: rt_child, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } } else { - render_rust_type(n: rt_child, shared_types: shared_types, source_indices: env.source_indices) + render_rust_type(n: rt_child, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } let generic_ty = if struct_name == "PartialFunction" { rust_normalize_partial_function_field_type_text(rendered: rust_normalize_witness_type_text(rendered: ty)) @@ -3457,7 +3459,7 @@ fn emit_enum_shared_accessors(name: String, type_params: String, children: List< let shared = all_shared |> filter(fname => let types = fielded |> map(variant => match variant.children |> filter(f => authored_name(env: env, node: f) == fname) |> first { - Present { value: f } => render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, source_indices: env.source_indices) + Present { value: f } => render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) Absent => "" } ) @@ -3470,7 +3472,7 @@ fn emit_enum_shared_accessors(name: String, type_params: String, children: List< if shared |> count == 0 { return "" } let accessor_fns = shared |> map(fname => let ty = match first_fielded.children |> filter(f => authored_name(env: env, node: f) == fname) |> first { - Present { value: f } => render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, source_indices: env.source_indices) + Present { value: f } => render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) Absent => "compile_error!(\"enum shared accessor missing field metadata\")" } let arms = children |> map(child => @@ -3651,14 +3653,14 @@ fn enum_variant_field_type_node(env: TypeEnv, enum_name: String, variant_name: S } } -fn render_variant_payload_type(n: Node, shared_types: Set, source_indices: Map) -> String { +fn render_variant_payload_type(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { if n.connective == NoConnective && n.children |> count > 0 { let tn = authored_name_at(source_indices: source_indices, node: n) - let args = n.children |> map(c => render_rust_type(n: child_type_node(ch: c), shared_types: shared_types, source_indices: source_indices)) + let args = n.children |> map(c => render_rust_type(n: child_type_node(ch: c), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices)) let spec = language_spec(target: Rust) concat(coerce_primitive_type(target: Rust, dag_name: tn), spec.type_arg_open, args |> join(separator: ", "), spec.type_arg_close) } else { - render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices) + render_rust_type(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } @@ -3689,11 +3691,11 @@ fn emit_variant_from_child(child: Node, enum_name: String, recursive_types: Set< enum_variant_field_type_node(env: env, enum_name: enum_name, variant_name: child_text, field_name: "0", fallback: fallback, source_indices: env.source_indices) } else { fallback } let raw_ty = if positional_payload { - render_variant_payload_type(n: type_node, shared_types: shared_types, source_indices: env.source_indices) + render_variant_payload_type(n: type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } else { - render_rust_type(n: type_node, shared_types: shared_types, source_indices: env.source_indices) + render_rust_type(n: type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } - let ty = if find_property(props: type_node.properties, prop_name: "__applied_type_args", source_indices: env.source_indices) != none { render_rust_type_with_applied_binding(n: type_node, shared_types: shared_types, source_indices: env.source_indices) } else { raw_ty } + let ty = if find_property(props: type_node.properties, prop_name: "__applied_type_args", source_indices: env.source_indices) != none { render_rust_type_with_applied_binding(n: type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) } else { raw_ty } let final_ty = if needs_box_wrapping(n: type_node, recursive_types: recursive_types, shared_types: shared_types, source_indices: env.source_indices) { concat("Box<", ty, ">") } else { ty } @@ -3703,7 +3705,7 @@ fn emit_variant_from_child(child: Node, enum_name: String, recursive_types: Set< } else { let field_lines = child.children |> map(f => let rt_f = resolved_type(n: f) - let ty = render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, source_indices: env.source_indices) + let ty = render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) let final_ty = if needs_box_wrapping(n: rt_f, recursive_types: recursive_types, shared_types: shared_types, source_indices: env.source_indices) { concat("Box<", ty, ">") } else { ty } @@ -3715,7 +3717,7 @@ fn emit_variant_from_child(child: Node, enum_name: String, recursive_types: Set< } else { let field_lines = child.children |> map(f => let rt_f = resolved_type(n: f) - let ty = render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, source_indices: env.source_indices) + let ty = render_rust_field_type_with_applied_binding(field: f, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: env.source_indices) let final_ty = if needs_box_wrapping(n: rt_f, recursive_types: recursive_types, shared_types: shared_types, source_indices: env.source_indices) { concat("Box<", ty, ">") } else { ty } @@ -3752,14 +3754,14 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg } let type_params_str = emit_type_params(params: type_params, source_indices: si) let generic_param_names = type_params |> map(p => generic_param_name_at(n: p, source_indices: si)) - let params_str = emit_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) - let ret_str = emit_inferred(inferred: inferred, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) + let params_str = emit_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: si, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) + let ret_str = emit_inferred(inferred: inferred, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: si, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) let body_scope = build_params_scope(scope: scope, params: value_params) let depth = 0 let use_tco = is_tco_eligible(name: name, body: body, registry: registry, source_indices: si) let needs_stacker = is_self_recursive(name: name, body: body, registry: registry, source_indices: si) && use_tco == false if use_tco { - let tco_params_str = emit_tco_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) + let tco_params_str = emit_tco_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: si, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) let body_str = emit_typed_tco_body(texpr: body, fn_name: name, params: value_params, registry: registry, scope: body_scope, depth: depth + 1, shared_types: shared_types, emit_info: emit_info) let kw = rust_items().func_keyword concat(rust_visibility_prefix(), kw, " ", emit_ident(name: name, target: Rust), type_params_str, "(", tco_params_str, ")", ret_str, " {\n", @@ -3817,8 +3819,8 @@ fn emit_func_def( Present { value: info } => info.service_names Absent => [] } - let params_str = emit_func_params(params: params, uses: uses, service_names: service_names, shared_types: shared_types, source_indices: scope.type_env.source_indices, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) - let ret_str = emit_func_inferred(inferred: inferred, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let params_str = emit_func_params(params: params, uses: uses, service_names: service_names, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) + let ret_str = emit_func_inferred(inferred: inferred, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let body_scope = build_params_scope(scope: scope, params: params) let si = scope.type_env.source_indices let body_scope = fold(uses, init: body_scope, f: (s, u) => @@ -3875,25 +3877,25 @@ fn emit_func_body(body: Node, registry: Map, scope: InferScope // Tail-Call Optimization (TCO) -- Rust rendering // ========================================================================= -fn emit_tco_params(params: List, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - let strs = params |> map(p => emit_tco_param(param: p, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) +fn emit_tco_params(params: List, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { + let strs = params |> map(p => emit_tco_param(param: p, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) strs |> join(separator: ", ") } -fn emit_tco_param(param: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn emit_tco_param(param: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let authored = param_node_type_expr(n: param) let ty = if authored.params |> count > 0 { - emit_rust_param_type(n: authored, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + emit_rust_param_type(n: authored, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } else { - render_rust_param_sig_type(param: param, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_param_sig_type(param: param, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } concat("mut ", emit_ident(name: param_node_name_at(n: param, source_indices: source_indices), target: Rust), rust_items().param_type_sep, ty) } -fn emit_func_params(params: List, uses: List, service_names: List, shared_types: Set, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { - let param_strs = params |> map(p => emit_param(param: p, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, read_only_params: read_only_params, variant_to_enum: variant_to_enum, env: env)) +fn emit_func_params(params: List, uses: List, service_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { + let param_strs = params |> map(p => emit_param(param: p, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, read_only_params: read_only_params, variant_to_enum: variant_to_enum, env: env)) let resource_strs = uses |> map(u => - concat(emit_ident(name: resource_use_name_at(n: u, source_indices: source_indices), target: Rust), ": &", render_rust_type(n: resource_use_resource(n: u), shared_types: shared_types, source_indices: source_indices)) + concat(emit_ident(name: resource_use_name_at(n: u, source_indices: source_indices), target: Rust), ": &", render_rust_type(n: resource_use_resource(n: u), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices)) ) let service_strs = service_names |> map(sn => concat(service_var_name(service_name: sn), ": &", sanitize_service_name(name: sn)) @@ -3902,16 +3904,16 @@ fn emit_func_params(params: List, uses: List, service_names: List join(separator: ", ") } -fn emit_func_inferred(inferred: Node, shared_types: Set, source_indices: Map) -> String { - concat(" -> Result<", render_rust_type(n: inferred, shared_types: shared_types, source_indices: source_indices), ", Box>") +fn emit_func_inferred(inferred: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { + concat(" -> Result<", render_rust_type(n: inferred, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices), ", Box>") } // ========================================================================= // Parameter emission // ========================================================================= -fn emit_params(params: List, generic_param_names: List, shared_types: Set, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { - let strs = params |> map(p => emit_param(param: p, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, read_only_params: read_only_params, variant_to_enum: variant_to_enum, env: env)) +fn emit_params(params: List, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { + let strs = params |> map(p => emit_param(param: p, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, read_only_params: read_only_params, variant_to_enum: variant_to_enum, env: env)) strs |> join(separator: ", ") } @@ -3928,38 +3930,38 @@ fn emit_params(params: List, generic_param_names: List, shared_typ // ordinary variable references (`emit_var_ref`). Do not remove `+ Clone` // here and "compensate" only in the emitter: that splits clone authority // between the type signature and ownership analysis and breaks fixed-point. -fn render_rust_param_sig_type(param: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn render_rust_param_sig_type(param: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let type_node = resolved_type(n: param) - render_rust_fn_sig_type(n: type_node, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_fn_sig_type(n: type_node, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } -fn emit_rust_param_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { +fn emit_rust_param_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { if n.params |> count > 0 { - let param_types = n.params |> map(p => render_rust_fn_sig_type(n: param_node_type_expr(n: p), generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) + let param_types = n.params |> map(p => render_rust_fn_sig_type(n: param_node_type_expr(n: p), generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) let param_str = param_types |> join(separator: ", ") let ret_str = match n.inferred { - Present { value: Resolved { node: rt } } => render_rust_fn_sig_type(n: rt, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + Present { value: Resolved { node: rt } } => render_rust_fn_sig_type(n: rt, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) _ => "()" } concat("impl Fn(", param_str, ") -> ", ret_str, " + Clone") } else { - render_rust_fn_sig_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_fn_sig_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } } -fn emit_param(param: Node, generic_param_names: List, shared_types: Set, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { +fn emit_param(param: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { let authored = param_node_type_expr(n: param) let ty = if authored.params |> count > 0 { - emit_rust_param_type(n: authored, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + emit_rust_param_type(n: authored, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } else { - render_rust_param_sig_type(param: param, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) + render_rust_param_sig_type(param: param, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } let pname = param_node_name_at(n: param, source_indices: source_indices) concat(emit_ident(name: pname, target: Rust), rust_items().param_type_sep, ty) } -fn emit_inferred(inferred: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - concat(rust_items().return_arrow, render_rust_fn_sig_type(n: inferred, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) +fn emit_inferred(inferred: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { + concat(rust_items().return_arrow, render_rust_fn_sig_type(n: inferred, generic_param_names: generic_param_names, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) } fn needs_reference_node(n: Node, source_indices: Map) -> Bool { @@ -4833,22 +4835,22 @@ fn rust_runtime_bridge_name(function_name: String) -> String { } } -fn rust_empty_map_value_type_str(map_type: Node, shared_types: Set, source_indices: Map) -> String { +fn rust_empty_map_value_type_str(map_type: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { match map_type.children |> skip(1) |> first { Present { value: value_child } => - let rendered = render_rust_type(n: child_type_node(ch: value_child), shared_types: shared_types, source_indices: source_indices) + let rendered = render_rust_type(n: child_type_node(ch: value_child), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) if rendered == "" { "" } else { rendered } Absent => "" } } -fn rust_empty_map_kv_type_str(map_type: Node, shared_types: Set, source_indices: Map) -> String { +fn rust_empty_map_kv_type_str(map_type: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { let key_str = match map_type.children |> first { Present { value: key_child } => - render_rust_type(n: child_type_node(ch: key_child), shared_types: shared_types, source_indices: source_indices) + render_rust_type(n: child_type_node(ch: key_child), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) Absent => "" } - let val_str = rust_empty_map_value_type_str(map_type: map_type, shared_types: shared_types, source_indices: source_indices) + let val_str = rust_empty_map_value_type_str(map_type: map_type, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) if key_str != "" && val_str != "" { concat(key_str, ", ", val_str) } else { "" } @@ -5240,7 +5242,7 @@ fn emit_typed_call_expr(func: String, args: List, inferred: InferredNode?, let call_str = if func == "empty_map" { match inferred { Present { value: Resolved { node: ret_type } } => - let kv_type_str = rust_empty_map_kv_type_str(map_type: ret_type, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let kv_type_str = rust_empty_map_kv_type_str(map_type: ret_type, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) if kv_type_str != "" { concat("v1_rt::rc_empty_map::<", kv_type_str, ">()") } else { From 675046ca74f70cc39330a1938b71c02c06041614 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 04:36:01 +0000 Subject: [PATCH 32/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 105 +++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 8133e050f6f..4dcfd6a05e3 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -226,16 +226,16 @@ fn render_rust_text_carrier(shared_types: Set) -> String { // §2 — route ALL host→DAG String boundary bridges through HostStringText seam (one authority). // §7: seam wrappers are v2-self-host only; v1 seed keeps host String (no v2_std_text module). -fn emit_rust_host_to_dag_string_via_seam(host_expr: String, source_indices: Map) -> String { - if rust_emit_faithful_text_carrier(source_indices: source_indices) { +fn emit_rust_host_to_dag_string_via_seam(host_expr: String, corpus_repr: RustCorpusRepr) -> String { + if corpus_repr == FaithfulFreeMonoid { concat("crate::v2_std_text::host_string_text_from_rust_host(", host_expr, ")") } else { host_expr } } -fn emit_rust_dag_string_to_host_via_seam(dag_expr: String, source_indices: Map) -> String { - if rust_emit_faithful_text_carrier(source_indices: source_indices) { +fn emit_rust_dag_string_to_host_via_seam(dag_expr: String, corpus_repr: RustCorpusRepr) -> String { + if corpus_repr == FaithfulFreeMonoid { concat("crate::v2_std_text::host_string_text_to_rust_host(", dag_expr, ")") } else { dag_expr @@ -1521,7 +1521,8 @@ fn emit_rust(typed: ResolvedGraph) -> EmitResult { let test_files = typed.modules |> map(tm => emit_test_file( module_name: authored_name_at(source_indices: tm.type_env.source_indices, node: tm.module), - projections: test_projections |> filter(p => p.module_name == authored_name_at(source_indices: tm.type_env.source_indices, node: tm.module)))) + projections: test_projections |> filter(p => p.module_name == authored_name_at(source_indices: tm.type_env.source_indices, node: tm.module)), + corpus_repr: emit_info.corpus_repr)) |> filter(f => f.path != "") let has_services = has_service_items(typed: typed) let has_pipeline = typed.modules |> any(m => authored_name_at(source_indices: m.type_env.source_indices, node: m.module) == "v1.compiler.compile") @@ -3081,9 +3082,9 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map, source_indices: Map) -> String { +fn collection_element_type(receiver_type: InferredNode?, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { match receiver_type { Present { value: Resolved { node: rt } } => let __rt_is_container = node_is_element_collection(n: rt, source_indices: source_indices) @@ -5524,7 +5525,7 @@ fn collection_element_type(receiver_type: InferredNode?, shared_types: Set "_" } } else { "_" } @@ -5548,7 +5549,7 @@ fn lambda_scope_from_children(scope: InferScope, params: List, param_nod ) } -fn lambda_param_type_strs(params: List, param_nodes: List, fallback_types: List, shared_types: Set, source_indices: Map) -> List { +fn lambda_param_type_strs(params: List, param_nodes: List, fallback_types: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> List { params |> enumerate |> map(pair => let idx = pair.first let param_name = pair.second @@ -5561,7 +5562,7 @@ fn lambda_param_type_strs(params: List, param_nodes: List, fallbac if param_is_type_var || param_is_error { none } else { - Present { value: render_rust_type(n: param_type, shared_types: shared_types, source_indices: source_indices) } + Present { value: render_rust_type(n: param_type, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices) } } _ => none } @@ -5587,7 +5588,7 @@ fn emit_typed_collection_lambda(lambda_expr: Node, elem_type_str: String, regist let ps = lambda_param_names_at(texpr: lambda_expr, source_indices: scope.type_env.source_indices) let bd = lambda_body(texpr: lambda_expr) let pn = lambda_expr.children |> skip(1) - let param_strs = lambda_param_type_strs(params: ps, param_nodes: pn, fallback_types: [elem_type_str], shared_types: shared_types, source_indices: scope.type_env.source_indices) + let param_strs = lambda_param_type_strs(params: ps, param_nodes: pn, fallback_types: [elem_type_str], shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let params_str = param_strs |> join(separator: ", ") let lambda_scope = lambda_scope_from_children(scope: scope, params: ps, param_nodes: pn) let body_str = emit_typed_expr(texpr: bd, registry: registry, scope: lambda_scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) @@ -5613,7 +5614,7 @@ fn emit_typed_fold_lambda(lambda_expr: Node, acc_type_str: String, elem_type_str let fallback_types = ps |> enumerate |> map(pair => if pair.first == 0 { safe_acc_type } else { elem_type_str } ) - let param_strs = lambda_param_type_strs(params: ps, param_nodes: [], fallback_types: fallback_types, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let param_strs = lambda_param_type_strs(params: ps, param_nodes: [], fallback_types: fallback_types, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let params_str = param_strs |> join(separator: ", ") let lambda_scope = lambda_scope_from_children(scope: scope, params: ps, param_nodes: pn) let body_str = emit_typed_expr(texpr: bd, registry: registry, scope: lambda_scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) @@ -5634,7 +5635,7 @@ fn emit_typed_fold_lambda(lambda_expr: Node, acc_type_str: String, elem_type_str fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Node?, result_type: InferredNode?, receiver: Node, args: List, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { let recv_str = emit_typed_expr(texpr: receiver, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) - let elem_type_str = collection_element_type(receiver_type: receiver.inferred, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let elem_type_str = collection_element_type(receiver_type: receiver.inferred, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let contextual_acc_type = match result_type { Present { value: Resolved { node: method_result_type } } => Present { value: method_result_type } _ => none @@ -5730,7 +5731,7 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod _ => emit_info } } else { emit_info } - let acc_type_str = render_rust_type(n: acc_type_node, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let acc_type_str = render_rust_type(n: acc_type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let acc_type_is_type_var = if acc_type_node.inferred != none { is_type_variable(inferred: acc_type_node.inferred.value) } else { false } let acc_child_is_type_var = acc_type_node.children |> any(c => type_node_child_is_type_variable(c: c)) let is_bare_container = acc_type_node.children |> count == 0 && is_container_type(name: acc_type_name) @@ -5742,7 +5743,7 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod ExprCall { call_semantics: _, descent_evidence: _ } => let init_func = expr_call_func_at(texpr: arg_value(n: init_arg), source_indices: scope.type_env.source_indices) if init_func == "empty_map" && acc_type_str != "_" && acc_type_str != "" && !acc_has_unit_child { - let kv_type_str = rust_empty_map_kv_type_str(map_type: acc_type_node, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let kv_type_str = rust_empty_map_kv_type_str(map_type: acc_type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) if kv_type_str != "" { concat("v1_rt::rc_empty_map::<", kv_type_str, ">()") } else { @@ -5778,7 +5779,7 @@ fn emit_rust_sort_by_method_call(receiver: Node, args: List, registry: Map let elem = for_each_element_type_node(n: resolved, source_indices: scope.type_env.source_indices) let elem_is_type_var = if elem.inferred != none { is_type_variable(inferred: elem.inferred.value) } else { false } if elem.ident_span != none && !elem_is_type_var { - render_rust_type(n: elem, shared_types: shared_types, source_indices: scope.type_env.source_indices) + render_rust_type(n: elem, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) } else { "_" } _ => "_" } @@ -6901,13 +6902,14 @@ fn emit_service_def( item: Node, registry: Map, shared_types: Set, + corpus_repr: RustCorpusRepr, env: TypeEnv ) -> String { let safe_name = sanitize_service_name(name: authored_name(env: env, node: item)) let fallback_transport = service_fallback_transport(item: item) let op_children = item.children let struct_def = emit_service_struct(name: safe_name, fallback_transport: fallback_transport, op_children: op_children, service_item: item, source_indices: env.source_indices) - let impl_block = emit_service_impl(name: safe_name, transport: fallback_transport, op_children: op_children, registry: registry, shared_types: shared_types, env: env, service_item: item) + let impl_block = emit_service_impl(name: safe_name, transport: fallback_transport, op_children: op_children, registry: registry, shared_types: shared_types, corpus_repr: corpus_repr, env: env, service_item: item) concat(struct_def, "\n\n", impl_block) } @@ -6928,11 +6930,11 @@ fn emit_service_config_fields(fallback_transport: Node, op_children: List, else { decls |> join(separator: "") } } -fn emit_service_impl(name: String, transport: Node, op_children: List, registry: Map, shared_types: Set, env: TypeEnv, service_item: Node) -> String { +fn emit_service_impl(name: String, transport: Node, op_children: List, registry: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv, service_item: Node) -> String { let depth = 0 let new_method = emit_service_new_method(name: name, fallback_transport: transport, op_children: op_children, service_item: service_item, source_indices: env.source_indices) let method_strs = op_children |> map(op_node => - emit_operation_method(service_name: name, transport: transport, op_node: op_node, registry: registry, depth: depth + 1, shared_types: shared_types, env: env, service_item: service_item) + emit_operation_method(service_name: name, transport: transport, op_node: op_node, registry: registry, depth: depth + 1, shared_types: shared_types, corpus_repr: corpus_repr, env: env, service_item: service_item) ) let all_methods = concat([new_method], method_strs) let methods_str = all_methods |> join(separator: "\n\n") @@ -7015,10 +7017,10 @@ fn emit_modifier_doc_from_props(properties: List, source_indices: Map, depth: Int, shared_types: Set, env: TypeEnv, service_item: Node) -> String { +fn emit_operation_method(service_name: String, transport: Node, op_node: Node, registry: Map, depth: Int, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv, service_item: Node) -> String { let op_text = authored_name(env: env, node: op_node) let input_params = op_node.params |> map(p => - concat(emit_ident(name: param_node_name_at(n: p, source_indices: env.source_indices), target: Rust), rust_items().param_type_sep, emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: shared_types, source_indices: env.source_indices, variant_to_enum: empty_map(), env: env.clone())) + concat(emit_ident(name: param_node_name_at(n: p, source_indices: env.source_indices), target: Rust), rust_items().param_type_sep, emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: env.source_indices, variant_to_enum: empty_map(), env: env.clone())) ) let params_str = input_params |> join(separator: ", ") let all_params = if params_str == "" { @@ -7026,12 +7028,12 @@ fn emit_operation_method(service_name: String, transport: Node, op_node: Node, r } else { concat("&self, ", params_str) } - let ret_type = render_rust_type(n: resolved_type(n: op_node), shared_types: shared_types, source_indices: env.source_indices) + let ret_type = render_rust_type(n: resolved_type(n: op_node), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: env.source_indices) let eff_transport = effective_operation_transport(op_node: op_node, fallback: transport) let op_inferred = resolved_type(n: op_node) - let real_body = emit_transport_call(transport: eff_transport, op_name: op_text, registry: registry, depth: depth + 2, inferred: op_inferred, service_item: service_item, op_node: op_node, source_indices: env.source_indices, shared_types: shared_types, env: env) + let real_body = emit_transport_call(transport: eff_transport, op_name: op_text, registry: registry, depth: depth + 2, inferred: op_inferred, service_item: service_item, op_node: op_node, source_indices: env.source_indices, shared_types: shared_types, corpus_repr: corpus_repr, env: env) let mock_props = op_node.properties |> filter(p => has_mock_prefix(name: field_init_node_name_at(n: p, source_indices: env.source_indices))) - let dry_run_body = emit_dry_run_branch_from_props(op_name: op_text, inferred: resolved_type(n: op_node), mock_props: mock_props, registry: registry, source_indices: env.source_indices, op_node: op_node, env: env, shared_types: shared_types) + let dry_run_body = emit_dry_run_branch_from_props(op_name: op_text, inferred: resolved_type(n: op_node), mock_props: mock_props, registry: registry, source_indices: env.source_indices, op_node: op_node, env: env, shared_types: shared_types, corpus_repr: corpus_repr) let body = concat( "if self.dry_run.is_dry_run() {\n", make_indent(level: depth + 2),dry_run_body, "\n", @@ -7045,7 +7047,7 @@ fn emit_operation_method(service_name: String, transport: Node, op_node: Node, r make_indent(level: depth + 1),body, "\n}") } -fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: List, registry: Map, source_indices: Map, op_node: Node, env: TypeEnv, shared_types: Set) -> String { +fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: List, registry: Map, source_indices: Map, op_node: Node, env: TypeEnv, shared_types: Set, corpus_repr: RustCorpusRepr) -> String { let log_line = concat("eprintln!(\"[dry-run] ", op_name, "\");") if mock_props |> count > 0 { let first_mock = mock_props |> first @@ -7075,7 +7077,7 @@ fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: L Present { value: Resolved { node: rt } } => rt _ => tn } - concat("let __rest_wire: ", render_rust_type(n: wire_ty, shared_types: shared_types, source_indices: source_indices), " = serde_json::from_str(r#\"", mock_json, "\"#)?;\n") + concat("let __rest_wire: ", render_rust_type(n: wire_ty, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices), " = serde_json::from_str(r#\"", mock_json, "\"#)?;\n") } Absent => concat("let json_body: serde_json::Value = serde_json::from_str(r#\"", mock_json, "\"#)?;\n") } @@ -7126,14 +7128,14 @@ fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: L } } -fn emit_transport_call(transport: Node, op_name: String, registry: Map, depth: Int, inferred: Node, service_item: Node, op_node: Node, source_indices: Map, shared_types: Set, env: TypeEnv) -> String { - if is_rest_transport(t: transport, source_indices: source_indices) { emit_rest_call(op_name: op_name, transport: transport, registry: registry, depth: depth, service_item: service_item, op_node: op_node, source_indices: source_indices, shared_types: shared_types, env: env) } +fn emit_transport_call(transport: Node, op_name: String, registry: Map, depth: Int, inferred: Node, service_item: Node, op_node: Node, source_indices: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { + if is_rest_transport(t: transport, source_indices: source_indices) { emit_rest_call(op_name: op_name, transport: transport, registry: registry, depth: depth, service_item: service_item, op_node: op_node, source_indices: source_indices, shared_types: shared_types, corpus_repr: corpus_repr, env: env) } else if is_shell_transport(t: transport) { emit_shell_call(op_name: op_name, transport: transport, registry: registry, depth: depth, inferred: inferred, op_node: op_node, source_indices: source_indices) } else if is_file_transport(t: transport, source_indices: source_indices) { emit_file_call(op_name: op_name, inferred: inferred) } else { emit_local_call(op_name: op_name) } } -fn emit_rest_call(op_name: String, transport: Node, registry: Map, depth: Int, service_item: Node, op_node: Node, source_indices: Map, shared_types: Set, env: TypeEnv) -> String { +fn emit_rest_call(op_name: String, transport: Node, registry: Map, depth: Int, service_item: Node, op_node: Node, source_indices: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { let client_init = "let client = reqwest::Client::builder().user_agent(\"gunbc/1.0\").build()?;" let url_line = emit_rest_url_line(transport: transport, op_name: op_name, source_indices: source_indices) let http_method = emit_rest_http_method(transport: transport, source_indices: source_indices) @@ -7147,7 +7149,7 @@ fn emit_rest_call(op_name: String, transport: Node, registry: Map filter(l => l != "") @@ -7469,7 +7471,7 @@ fn emit_json_value_extract(var_name: String, from_path: String, dag_type_name: S concat("let ", var_name, " = json_body.pointer(\"", pointer, "\")", accessor, ";") } -fn emit_from_key_extraction(op_node: Node, source_indices: Map, shared_types: Set, env: TypeEnv) -> String { +fn emit_from_key_extraction(op_node: Node, source_indices: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { let rt = resolved_type(n: op_node) let children = rt.children let wire_opt = operation_response_200_resolved_type(op_node: op_node, source_indices: source_indices, env: env) @@ -7492,7 +7494,7 @@ fn emit_from_key_extraction(op_node: Node, source_indices: Map rt _ => tn } - concat("let __rest_wire: ", render_rust_type(n: wire_ty, shared_types: shared_types, source_indices: source_indices), " = response.json().await?;\n") + concat("let __rest_wire: ", render_rust_type(n: wire_ty, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices), " = response.json().await?;\n") } Absent => "let json_body: serde_json::Value = response.json().await?;\n" } @@ -7539,17 +7541,17 @@ fn emit_plain_response_body(op_node: Node, transport: Node, source_indices: Map< } } -fn emit_response_code_handling(op_node: Node, transport: Node, source_indices: Map, shared_types: Set, env: TypeEnv) -> String { +fn emit_response_code_handling(op_node: Node, transport: Node, source_indices: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { let use_from_key = has_from_key_fields(op_node: op_node, source_indices: source_indices) let response_props = op_node.properties |> filter(p => has_response_prefix(name: field_init_node_name_at(n: p, source_indices: source_indices))) if response_props |> count == 0 { if use_from_key { - emit_from_key_extraction(op_node: op_node, source_indices: source_indices, shared_types: shared_types, env: env) + emit_from_key_extraction(op_node: op_node, source_indices: source_indices, shared_types: shared_types, corpus_repr: corpus_repr, env: env) } else { emit_plain_response_body(op_node: op_node, transport: transport, source_indices: source_indices) } } else { - let arms = response_props |> map(p => emit_response_arm(prop: p, op_node: op_node, use_from_key: use_from_key, transport: transport, source_indices: source_indices, shared_types: shared_types, env: env)) + let arms = response_props |> map(p => emit_response_arm(prop: p, op_node: op_node, use_from_key: use_from_key, transport: transport, source_indices: source_indices, shared_types: shared_types, corpus_repr: corpus_repr, env: env)) concat( "let status = response.status().as_u16();\n", "match status {\n", @@ -7559,7 +7561,7 @@ fn emit_response_code_handling(op_node: Node, transport: Node, source_indices: M } } -fn emit_response_arm(prop: Node, op_node: Node, use_from_key: Bool, transport: Node, source_indices: Map, shared_types: Set, env: TypeEnv) -> String { +fn emit_response_arm(prop: Node, op_node: Node, use_from_key: Bool, transport: Node, source_indices: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { let name = field_init_node_name_at(n: prop, source_indices: source_indices) let code_str = substring(s: name, start: 9, end: string_length(s: name)) let is_success = if string_length(s: code_str) >= 1 { @@ -7573,7 +7575,7 @@ fn emit_response_arm(prop: Node, op_node: Node, use_from_key: Bool, transport: N else { code_str } if is_success { if use_from_key { - concat(" ", pattern, " => { ", emit_from_key_extraction(op_node: op_node, source_indices: source_indices, shared_types: shared_types, env: env), " },") + concat(" ", pattern, " => { ", emit_from_key_extraction(op_node: op_node, source_indices: source_indices, shared_types: shared_types, corpus_repr: corpus_repr, env: env), " },") } else { concat(" ", pattern, " => { ", emit_plain_response_body(op_node: op_node, transport: transport, source_indices: source_indices), " },") } @@ -7805,23 +7807,23 @@ fn emit_local_call(op_name: String) -> String { // Resource definition emission // ========================================================================= -fn emit_resource_def(item: Node, shared_types: Set, env: TypeEnv) -> String { +fn emit_resource_def(item: Node, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { let item_text = authored_name(env: env, node: item) let cap_children = item.children if cap_children |> count == 0 { concat("#[derive(Debug, Clone)]\npub struct ", item_text, ";") } else { let depth = 0 - let cap_methods = cap_children |> map(c => emit_capability_method(cap_node: c, shared_types: shared_types, env: env)) + let cap_methods = cap_children |> map(c => emit_capability_method(cap_node: c, shared_types: shared_types, corpus_repr: corpus_repr, env: env)) let methods_str = cap_methods |> join(separator: "\n\n") concat("#[async_trait::async_trait]\npub trait ", item_text, " {\n", make_indent(level: depth + 1),methods_str, "\n}") } } -fn emit_capability_method(cap_node: Node, shared_types: Set, env: TypeEnv) -> String { +fn emit_capability_method(cap_node: Node, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { let input_params = cap_node.params |> map(p => - concat(emit_ident(name: param_node_name_at(n: p, source_indices: env.source_indices), target: Rust), rust_items().param_type_sep, emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: shared_types, source_indices: env.source_indices, variant_to_enum: empty_map(), env: env.clone())) + concat(emit_ident(name: param_node_name_at(n: p, source_indices: env.source_indices), target: Rust), rust_items().param_type_sep, emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: env.source_indices, variant_to_enum: empty_map(), env: env.clone())) ) let params_str = input_params |> join(separator: ", ") let all_params = if params_str == "" { @@ -7829,7 +7831,7 @@ fn emit_capability_method(cap_node: Node, shared_types: Set, env: TypeEn } else { concat("&self, ", params_str) } - let ret = render_rust_type(n: resolved_type(n: cap_node), shared_types: shared_types, source_indices: env.source_indices) + let ret = render_rust_type(n: resolved_type(n: cap_node), shared_types: shared_types, corpus_repr: corpus_repr, source_indices: env.source_indices) let items = rust_items() concat(items.async_prefix, items.func_keyword, " ", emit_ident(name: authored_name(env: env, node: cap_node), target: Rust), "(", all_params, ") -> Result<", ret, ", Box>;") } @@ -7858,7 +7860,7 @@ fn emit_data_def(name: String, type_node: Node, value: Node, registry: Map annotation_type_node } } - let raw_ty_str = render_rust_type_with_applied_binding(n: render_type_node, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let raw_ty_str = render_rust_type_with_applied_binding(n: render_type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let ty_str = if raw_ty_str == "BoundedLattice" || raw_ty_str == "Rc" { match field_value_by_name(record: value, field_name: "top", source_indices: scope.type_env.source_indices) { Present { value: top_value } => @@ -7914,7 +7916,7 @@ fn rust_nominal_identity_data_expr(type_node: Node, value: Node, source_indices: } fn emit_data_def_body(type_node: Node, value: Node, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo, needs_rc: Bool) -> String { - let raw_ty_str = render_rust_type(n: type_node, shared_types: shared_types, source_indices: scope.type_env.source_indices) + let raw_ty_str = render_rust_type(n: type_node, shared_types: shared_types, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices) let type_name = authored_name_at(source_indices: scope.type_env.source_indices, node: type_node) if type_name == "BoundedLattice" { match value.expr_data { @@ -7993,10 +7995,10 @@ fn emit_data_def_body(type_node: Node, value: Node, registry: Map) -> TextFile { +fn emit_test_file(module_name: String, projections: List, corpus_repr: RustCorpusRepr) -> TextFile { let depth = 0 let test_fns = projections - |> map(p => emit_operation_test(projection: p, depth: depth + 1)) + |> map(p => emit_operation_test(projection: p, depth: depth + 1, corpus_repr: corpus_repr)) if test_fns |> count == 0 { TextFile { path: "", content: "" } } else { @@ -8012,9 +8014,10 @@ fn emit_test_file(module_name: String, projections: List) -> Tex } } -fn rust_test_signature_comment(projection: TestProjection) -> String { +fn rust_test_signature_comment(projection: TestProjection, corpus_repr: RustCorpusRepr) -> String { + let stub_env = TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: projection.source_indices, intern_table: empty_intern_table() } let params_str = projection.params - |> map(p => concat(param_node_name_at(n: p, source_indices: projection.source_indices), ": ", emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: empty_set(), source_indices: projection.source_indices, variant_to_enum: empty_map()))) + |> map(p => concat(param_node_name_at(n: p, source_indices: projection.source_indices), ": ", emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: empty_set(), corpus_repr: corpus_repr, source_indices: projection.source_indices, variant_to_enum: empty_map(), env: stub_env))) |> join(separator: ", ") concat( "// Signature: ", @@ -8026,7 +8029,7 @@ fn rust_test_signature_comment(projection: TestProjection) -> String { emit_node_type(n: projection.inferred, target: Rust, source_indices: projection.source_indices)) } -fn emit_operation_test(projection: TestProjection, depth: Int) -> String { +fn emit_operation_test(projection: TestProjection, depth: Int, corpus_repr: RustCorpusRepr) -> String { let test_name = rust_test_name(projection: projection) let struct_name = sanitize_service_name(name: projection.service_name) let op_method = to_snake(name: projection.operation_name) @@ -8037,7 +8040,7 @@ fn emit_operation_test(projection: TestProjection, depth: Int) -> String { let args_str = param_args |> join(separator: ", ") let call_args = if args_str == "" { "" } else { args_str } concat(rust_async_test_decorator(), "\nasync fn ", test_name, "() {\n", - indent, rust_test_signature_comment(projection: projection), "\n", + indent, rust_test_signature_comment(projection: projection, corpus_repr: corpus_repr), "\n", indent, "let service = ", struct_name, "::new(crate::dry_run::DryRunMode(true));\n", indent, "let result = service.", emit_ident(name: op_method, target: Rust), "(", call_args, ").await;\n", indent, "assert!(result.is_ok(), \"", struct_name, ".", projection.operation_name, " should succeed in dry-run mode: {:?}\", result.err());\n", From bedc4156e40a1f4812515096efd68e1f5856eec5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 04:41:44 +0000 Subject: [PATCH 33/61] Section 5 self-host: thread corpus-global RustCorpusRepr selector through emitter (class-3 representation-coherence) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Realization-layer-not-model-change: replaces the per-module host-vs-faithful gate (rust_emit_faithful_text_carrier(source_indices)) with a single corpus-global RustCorpusRepr (computed once in rust_corpus_repr, stored on EmitGraphInfo.corpus_repr), threaded as the corpus_repr selector to every renderer/emitter/seam site. Deletes the old per-module gate fns (§5 single-authority: divergence was writable). §6-transitional: collapses to HostNative when src/v1 is deleted. Co-Authored-By: Claude Opus 4.8 --- src/v1/05_emit_rust.dag | 91 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 4dcfd6a05e3..82b4115582c 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -212,14 +212,13 @@ fn rust_type_is_rc_wrapped(type_name: String) -> Bool { // §3 faithful DAG String carrier for v2 Rust self-host (String = FreeMonoid, Char = Nat). // §7: carrier is v2-self-host target only — v1 seed/bootstrap keeps host String. -fn rust_corpus_includes_v1_compiler(source_indices: Map) -> Bool { - map_keys(source_indices) |> any(k => contains(k, "/v1/") || contains(k, "src/v1")) -} - -fn rust_emit_faithful_text_carrier(source_indices: Map) -> Bool { - !rust_corpus_includes_v1_compiler(source_indices: source_indices) -} - +// The corpus-representation choice is now a single corpus-global authority: +// `rust_corpus_repr` (04_infer.dag) computes RustCorpusRepr ONCE over all modules and +// threads it as `corpus_repr` to every renderer/emitter (EmitGraphInfo.corpus_repr). +// The old per-module gates (rust_corpus_includes_v1_compiler / rust_emit_faithful_text_carrier) +// were deleted: a per-module gate let a dsl module in a v1-bundled crate emit the faithful +// carrier while its siblings emit host — divergence was WRITABLE (a §5 dual-authority breach). +// §6-transitional: corpus_repr collapses to HostNative when src/v1 is deleted (seed→zero). fn render_rust_text_carrier(shared_types: Set) -> String { render_rust_shared_type_if_needed(type_name: "FreeMonoid", rendered: "FreeMonoid", shared_types: shared_types) } @@ -273,8 +272,8 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // target), the algebraic numeric tower (Nat = CommutativeSemiring, // Int = AbelianGroup>) maps to the host primitive i64 -- the // numeric analogue of String -> host String in the seed branch. Gated by the SAME -// rust_corpus_includes_v1_compiler authority as the text carrier (single lever, no -// parallel mechanism). The v2-target faithful numeric representation is escalated to +// corpus-global `corpus_repr` (RustCorpusRepr) authority as the text carrier (single +// lever, no parallel mechanism). The v2-target faithful numeric representation is escalated to // operator + non-blocking, so the faithful branch leaves the algebraic alias intact. // The seed numeric ops (nat_compare/nat_max/nat_min) use /.clone(), all native to // i64, so the alias-RHS override alone clears them and the Nat-as-number consumers @@ -3742,7 +3741,7 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg let si = scope.type_env.source_indices match rust_host_string_seam_fn_emit(name: name) { Present { value: seam_fn } => - if rust_emit_faithful_text_carrier(source_indices: si) { seam_fn } else { "" } + if emit_info.corpus_repr == FaithfulFreeMonoid { seam_fn } else { "" } Absent => { let type_params = function_type_params(params: params) let value_params = function_value_params(params: params) @@ -5221,7 +5220,7 @@ fn emit_discriminant_call_lowering(value_arg: Node, registry: Map ", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", child_text, "\""), source_indices: scope.type_env.source_indices), ",") + concat(" ", pat, " => ", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", child_text, "\""), corpus_repr: emit_info.corpus_repr), ",") ) // Borrow the scrutinee so the arms (which never bind fields) don't move it. Shared types // are Rc-wrapped, so deref through the Rc with `&*` to reach `&T`; owned values use `&`. @@ -5233,9 +5232,9 @@ fn emit_discriminant_call_lowering(value_arg: Node, registry: Map join(separator: "\n"), "\n })") } else { // Product/record type: the discriminant is the type's own name (interpreter returns type_name). - emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", ty_name, "\""), source_indices: scope.type_env.source_indices) + emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", ty_name, "\""), corpus_repr: emit_info.corpus_repr) } - Absent => emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", ty_name, "\""), source_indices: scope.type_env.source_indices) + Absent => emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", ty_name, "\""), corpus_repr: emit_info.corpus_repr) } } @@ -5317,7 +5316,7 @@ fn emit_typed_call(func: String, args: List, registry: Map first { Present { value: value_arg } => - emit_rust_host_to_dag_string_via_seam(host_expr: concat("(", emit_typed_expr(texpr: arg_value(n: value_arg), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024), ").to_string()"), source_indices: scope.type_env.source_indices) + emit_rust_host_to_dag_string_via_seam(host_expr: concat("(", emit_typed_expr(texpr: arg_value(n: value_arg), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024), ").to_string()"), corpus_repr: emit_info.corpus_repr) Absent => "compile_error!(\"to_string call missing value argument\")" } return ts_result @@ -6517,7 +6516,7 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St let missing = map_keys(fs) |> filter(k => !emit_map_has(m: provided_set, key: k)) let all_defaultable = missing |> all(fname => let has_zv = match map_get(ftm, fname) { - Present { value: ft } => match rust_zero_value(type_name: ft, source_indices: si) { Present { value: _ } => true, Absent => false } + Present { value: ft } => match rust_zero_value(type_name: ft, corpus_repr: emit_info.corpus_repr) { Present { value: _ } => true, Absent => false } Absent => false } has_zv || is_optional_struct_field(emit_info: emit_info, struct_name: variant_summary_name, field_name: fname) @@ -6529,7 +6528,7 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St } else { match map_get(ftm, fname) { Present { value: ft } => - match rust_zero_value(type_name: ft, source_indices: si) { + match rust_zero_value(type_name: ft, corpus_repr: emit_info.corpus_repr) { Present { value: zv } => [concat(" ", emit_ident(name: fname, target: Rust), ": ", zv, ",")] Absent => [] } @@ -6567,11 +6566,11 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St } } -fn rust_zero_value(type_name: String, source_indices: Map) -> String? { +fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> String? { if type_name == "Int" { Present { value: "0" } } else if type_name == "Bool" { Present { value: "false" } } else if type_name == "String" { - if rust_emit_faithful_text_carrier(source_indices: source_indices) { + if corpus_repr == FaithfulFreeMonoid { Present { value: "crate::v2_std_algebra::freemonoid_empty::()" } } else { Present { value: "\"\".to_string()" } @@ -6591,11 +6590,11 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri let l_optional = is_optional_typed_expr(e: left) let r_optional = is_optional_typed_expr(e: right) if l_optional || r_optional { - let l_cmp = if l_optional { concat(l_str, ".as_deref()") } else { concat("Some(", emit_rust_dag_string_to_host_via_seam(dag_expr: l_str, source_indices: scope.type_env.source_indices), ")") } - let r_cmp = if r_optional { concat(r_str, ".as_deref()") } else { concat("Some(", emit_rust_dag_string_to_host_via_seam(dag_expr: r_str, source_indices: scope.type_env.source_indices), ")") } + let l_cmp = if l_optional { concat(l_str, ".as_deref()") } else { concat("Some(", emit_rust_dag_string_to_host_via_seam(dag_expr: l_str, corpus_repr: emit_info.corpus_repr), ")") } + let r_cmp = if r_optional { concat(r_str, ".as_deref()") } else { concat("Some(", emit_rust_dag_string_to_host_via_seam(dag_expr: r_str, corpus_repr: emit_info.corpus_repr), ")") } concat("(", l_cmp, " ", op_str, " ", r_cmp, ")") } else { - concat("(", emit_rust_dag_string_to_host_via_seam(dag_expr: l_str, source_indices: scope.type_env.source_indices), " ", op_str, " ", emit_rust_dag_string_to_host_via_seam(dag_expr: r_str, source_indices: scope.type_env.source_indices), ")") + concat("(", emit_rust_dag_string_to_host_via_seam(dag_expr: l_str, corpus_repr: emit_info.corpus_repr), " ", op_str, " ", emit_rust_dag_string_to_host_via_seam(dag_expr: r_str, corpus_repr: emit_info.corpus_repr), ")") } } else { concat("(", l_str, " ", op_str, " ", r_str, ")") @@ -6637,10 +6636,10 @@ fn emit_typed_string_interp(parts: List, registry: Map map(p => p.arg_expr) |> filter(a => a != "") if args |> count == 0 { - emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", fmt_str, "\""), source_indices: scope.type_env.source_indices) + emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", fmt_str, "\""), corpus_repr: emit_info.corpus_repr) } else { let args_str = args |> join(separator: ", ") - emit_rust_host_to_dag_string_via_seam(host_expr: concat("format!(\"", fmt_str, "\", ", args_str, ")"), source_indices: scope.type_env.source_indices) + emit_rust_host_to_dag_string_via_seam(host_expr: concat("format!(\"", fmt_str, "\", ", args_str, ")"), corpus_repr: emit_info.corpus_repr) } } @@ -7096,7 +7095,7 @@ fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: L Absent => concat("let ", field_name, " = compile_error!(\"REST typed dry-run: response_200 wire type missing despite typed projection; illegal state\");\n") } } else { - emit_json_value_extract(var_name: field_name, from_path: from_path, dag_type_name: authored_name_at(source_indices: source_indices, node: tn), source_indices: source_indices) + emit_json_value_extract(var_name: field_name, from_path: from_path, dag_type_name: authored_name_at(source_indices: source_indices, node: tn), corpus_repr: corpus_repr, source_indices: source_indices) } _ => concat("let ", field_name, " = compile_error!(\"unresolved type for mock field: ", ch_name, "\");") @@ -7130,7 +7129,7 @@ fn emit_dry_run_branch_from_props(op_name: String, inferred: Node, mock_props: L fn emit_transport_call(transport: Node, op_name: String, registry: Map, depth: Int, inferred: Node, service_item: Node, op_node: Node, source_indices: Map, shared_types: Set, corpus_repr: RustCorpusRepr, env: TypeEnv) -> String { if is_rest_transport(t: transport, source_indices: source_indices) { emit_rest_call(op_name: op_name, transport: transport, registry: registry, depth: depth, service_item: service_item, op_node: op_node, source_indices: source_indices, shared_types: shared_types, corpus_repr: corpus_repr, env: env) } - else if is_shell_transport(t: transport) { emit_shell_call(op_name: op_name, transport: transport, registry: registry, depth: depth, inferred: inferred, op_node: op_node, source_indices: source_indices) } + else if is_shell_transport(t: transport) { emit_shell_call(op_name: op_name, transport: transport, registry: registry, depth: depth, inferred: inferred, op_node: op_node, corpus_repr: corpus_repr, source_indices: source_indices) } else if is_file_transport(t: transport, source_indices: source_indices) { emit_file_call(op_name: op_name, inferred: inferred) } else { emit_local_call(op_name: op_name) } } @@ -7140,7 +7139,7 @@ fn emit_rest_call(op_name: String, transport: Node, registry: Map map(h => @@ -7269,12 +7268,12 @@ fn emit_rest_auth_line(transport: Node, service_item: Node, http_method: String, } } -fn emit_rest_query_line(transport: Node, source_indices: Map) -> String { +fn emit_rest_query_line(transport: Node, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { match transport_query(t: transport, source_indices: source_indices) { Present { value: q } => { let pairs = q.children |> map(fi => concat("(\"", field_init_node_name_at(n: fi, source_indices: source_indices), "\", &", - emit_rust_dag_string_to_host_via_seam(dag_expr: emit_simple_expr(expr: field_init_node_value(n: fi), target: Rust, source_indices: source_indices), source_indices: source_indices), + emit_rust_dag_string_to_host_via_seam(dag_expr: emit_simple_expr(expr: field_init_node_value(n: fi), target: Rust, source_indices: source_indices), corpus_repr: corpus_repr), ")") ) if pairs |> count > 0 { @@ -7453,12 +7452,12 @@ fn escape_json_pointer_segment(seg: String) -> String { seg |> replace("~", "~0") |> replace("/", "~1") } -fn emit_json_value_extract(var_name: String, from_path: String, dag_type_name: String, source_indices: Map) -> String { +fn emit_json_value_extract(var_name: String, from_path: String, dag_type_name: String, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { let escaped_path = from_path |> split("/") |> map(seg => escape_json_pointer_segment(seg: seg)) |> join(separator: "/") let pointer = concat("/", escaped_path) let rust_type = coerce_primitive_type(target: Rust, dag_name: dag_type_name) let accessor = if dag_type_name == "String" { - concat(".and_then(|v| v.as_str()).map(|s| ", emit_rust_host_to_dag_string_via_seam(host_expr: "s.to_string()", source_indices: source_indices), ").ok_or(\"missing field: ", from_path, "\")?") + concat(".and_then(|v| v.as_str()).map(|s| ", emit_rust_host_to_dag_string_via_seam(host_expr: "s.to_string()", corpus_repr: corpus_repr), ").ok_or(\"missing field: ", from_path, "\")?") } else if rust_type == "i64" { concat(".and_then(|v| v.as_i64()).ok_or(\"missing field: ", from_path, "\")?") } else if rust_type == "f64" { @@ -7513,7 +7512,7 @@ fn emit_from_key_extraction(op_node: Node, source_indices: Map concat("let ", field_name, " = compile_error!(\"REST typed response: response_200 wire type missing despite typed projection; illegal state\");\n") } } else { - emit_json_value_extract(var_name: field_name, from_path: from_path, dag_type_name: authored_name_at(source_indices: source_indices, node: tn), source_indices: source_indices) + emit_json_value_extract(var_name: field_name, from_path: from_path, dag_type_name: authored_name_at(source_indices: source_indices, node: tn), corpus_repr: corpus_repr, source_indices: source_indices) } _ => concat("let ", field_name, " = compile_error!(\"unresolved type for output field: ", ch_name, "\");") @@ -7589,15 +7588,15 @@ fn has_exit_prefix(name: String) -> Bool { else { substring(s: name, start: 0, end: 5) == "exit_" } } -fn emit_exit_code_handling(op_node: Node, inferred: Node, source_indices: Map) -> String { +fn emit_exit_code_handling(op_node: Node, inferred: Node, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { let exit_props = op_node.properties |> filter(p => has_exit_prefix(name: field_init_node_name_at(n: p, source_indices: source_indices))) if exit_props |> count == 0 { emit_shell_return(inferred: inferred, source_indices: source_indices) } else { let has_nonzero = exit_props |> any(p => field_init_node_name_at(n: p, source_indices: source_indices) == "exit_nonzero") - let exit_arms = exit_props |> map(p => emit_exit_arm(prop: p, inferred: inferred, source_indices: source_indices)) + let exit_arms = exit_props |> map(p => emit_exit_arm(prop: p, inferred: inferred, corpus_repr: corpus_repr, source_indices: source_indices)) let default_arm = if has_nonzero { "" } - else { concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(", emit_rust_host_to_dag_string_via_seam(host_expr: "stderr", source_indices: source_indices), ") },") } + else { concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(", emit_rust_host_to_dag_string_via_seam(host_expr: "stderr", corpus_repr: corpus_repr), ") },") } concat( "let exit_code = output.status.code().unwrap_or(-1);\n", "match exit_code {\n", @@ -7607,7 +7606,7 @@ fn emit_exit_code_handling(op_node: Node, inferred: Node, source_indices: Map) -> String { +fn emit_exit_arm(prop: Node, inferred: Node, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { let name = field_init_node_name_at(n: prop, source_indices: source_indices) let code_str = substring(s: name, start: 5, end: string_length(s: name)) let pattern = if code_str == "nonzero" { "_" } @@ -7616,11 +7615,11 @@ fn emit_exit_arm(prop: Node, inferred: Node, source_indices: Map { ", emit_shell_return(inferred: inferred, source_indices: source_indices), " },") } else { - concat(" ", pattern, " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(", emit_rust_host_to_dag_string_via_seam(host_expr: "stderr", source_indices: source_indices), ") },") + concat(" ", pattern, " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(", emit_rust_host_to_dag_string_via_seam(host_expr: "stderr", corpus_repr: corpus_repr), ") },") } } -fn emit_shell_call(op_name: String, transport: Node, registry: Map, depth: Int, inferred: Node, op_node: Node, source_indices: Map) -> String { +fn emit_shell_call(op_name: String, transport: Node, registry: Map, depth: Int, inferred: Node, op_node: Node, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { let argv = transport.children let optional_params = op_node.params |> filter(p => param_node_type_expr(n: p).return_cardinality == CardOptional) @@ -7633,7 +7632,7 @@ fn emit_shell_call(op_name: String, transport: Node, registry: Map count > 0 { match argv |> first { Present { value: first_arg } => concat(let_kw, " = std::process::Command::new(", - emit_shell_argv_element(arg: first_arg, optional_params: optional_params, source_indices: source_indices), ")") + emit_shell_argv_element(arg: first_arg, optional_params: optional_params, corpus_repr: corpus_repr, source_indices: source_indices), ")") Absent => concat(let_kw, " = std::process::Command::new(\"", emit_ident(name: op_name, target: Rust), "\")") } @@ -7643,7 +7642,7 @@ fn emit_shell_call(op_name: String, transport: Node, registry: Map count > 1 { argv |> skip(1) |> map(arg => - concat(" .arg(", emit_shell_argv_element(arg: arg, optional_params: optional_params, source_indices: source_indices), ")") + concat(" .arg(", emit_shell_argv_element(arg: arg, optional_params: optional_params, corpus_repr: corpus_repr, source_indices: source_indices), ")") ) } else { [] } let env_entries = transport_env(t: transport, source_indices: source_indices) @@ -7662,19 +7661,19 @@ fn emit_shell_call(op_name: String, transport: Node, registry: Map join(separator: "\n") } else { let output_line = " .output()?;" let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();" - let return_line = emit_exit_code_handling(op_node: op_node, inferred: inferred, source_indices: source_indices) + let return_line = emit_exit_code_handling(op_node: op_node, inferred: inferred, corpus_repr: corpus_repr, source_indices: source_indices) let all_lines = concat([cmd_line], arg_lines, env_lines, [wd_line, output_line, check_line, return_line]) all_lines |> join(separator: "\n") } } -fn emit_shell_argv_element(arg: Node, optional_params: Map, source_indices: Map) -> String { +fn emit_shell_argv_element(arg: Node, optional_params: Map, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { match arg.expr_data { ExprLiteral { value: LitStr { value: s } } => concat("\"", escape_string_literal_body(s: s), "\"") @@ -7715,9 +7714,9 @@ fn emit_shell_argv_element(arg: Node, optional_params: Map, source Absent => false } if is_opt { - emit_rust_dag_string_to_host_via_seam(dag_expr: concat(var_name, ".as_deref().unwrap_or(\"\")"), source_indices: source_indices) + emit_rust_dag_string_to_host_via_seam(dag_expr: concat(var_name, ".as_deref().unwrap_or(\"\")"), corpus_repr: corpus_repr) } else { - emit_rust_dag_string_to_host_via_seam(dag_expr: var_name, source_indices: source_indices) + emit_rust_dag_string_to_host_via_seam(dag_expr: var_name, corpus_repr: corpus_repr) } } _ => emit_simple_expr(expr: arg, target: Rust, source_indices: source_indices) @@ -7971,7 +7970,7 @@ fn emit_data_def_body(type_node: Node, value: Node, registry: Map let inserts = value.children |> map(f => let val_str = emit_typed_expr(texpr: field_init_node_value(n: f), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) - concat(" __m.insert(", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), "\""), source_indices: scope.type_env.source_indices), ", ", val_str, ");") + concat(" __m.insert(", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), "\""), corpus_repr: emit_info.corpus_repr), ", ", val_str, ");") ) let inserts_str = inserts |> join(separator: "\n") concat(" let mut __m = HashMap::new();\n", From ca4d06e1572c3139a985d9ef45820d65b7b447c2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 04:46:41 +0000 Subject: [PATCH 34/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/05_emit_rust.dag | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 82b4115582c..decc9f9954c 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -219,6 +219,14 @@ fn rust_type_is_rc_wrapped(type_name: String) -> Bool { // were deleted: a per-module gate let a dsl module in a v1-bundled crate emit the faithful // carrier while its siblings emit host — divergence was WRITABLE (a §5 dual-authority breach). // §6-transitional: corpus_repr collapses to HostNative when src/v1 is deleted (seed→zero). +// Shape-reading predicates over the single corpus_repr authority (match, not `==`: +// a bare-variant `==` adjacent to a block `{` collides with record-literal syntax). +fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> Bool { + match corpus_repr { FaithfulFreeMonoid => true HostNative => false } +} +fn corpus_repr_is_host(corpus_repr: RustCorpusRepr) -> Bool { + match corpus_repr { HostNative => true FaithfulFreeMonoid => false } +} fn render_rust_text_carrier(shared_types: Set) -> String { render_rust_shared_type_if_needed(type_name: "FreeMonoid", rendered: "FreeMonoid", shared_types: shared_types) } From c725862306e9b090f08c2751250989f0ba4819b8 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 04:57:03 +0000 Subject: [PATCH 35/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/04_infer.dag | 1 + src/v1/05_emit_rust.dag | 24 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 3693 ++++++++++------- src/v1/stage0/src/v1_compiler_infer.rs | 500 +-- .../stage0/src/v1_compiler_infer_emit_info.rs | 20 +- 5 files changed, 2432 insertions(+), 1806 deletions(-) diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index 3de73f94237..a65e63baae4 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -111,6 +111,7 @@ import v1.compiler.infer_sigs { import v1.compiler.infer_emit_info { TypeRepr, StructRepr, EnumRepr, TypeSummary, EmitGraphInfo, EmitInfoBuildState, + RustCorpusRepr, HostNative, FaithfulFreeMonoid, empty_emit_graph_info, lookup_emit_type_summary, build_struct_field_summaries, build_enum_field_summaries, add_emit_item_summary, derive_variant_to_enum diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index decc9f9954c..85865abf4e1 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -111,7 +111,7 @@ import v1.compiler.infer { expand_type_for_field_access } import v1.compiler.infer_emit_info { - EmitGraphInfo, TypeSummary, StructRepr, EnumRepr, + EmitGraphInfo, RustCorpusRepr, HostNative, FaithfulFreeMonoid, TypeSummary, StructRepr, EnumRepr, lookup_emit_type_summary, is_enum_in_summaries, find_variant_parent, is_known_variant, variant_belongs_to_enum, variant_summary_key } @@ -194,7 +194,7 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, } } else { let tn = authored_name_at(source_indices: source_indices, node: n) - if tn == "String" && n.children |> count == 0 && corpus_repr == FaithfulFreeMonoid { + if tn == "String" && n.children |> count == 0 && corpus_repr_is_faithful(corpus_repr: corpus_repr) { render_rust_text_carrier(shared_types: shared_types) } else { render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) @@ -234,7 +234,7 @@ fn render_rust_text_carrier(shared_types: Set) -> String { // §2 — route ALL host→DAG String boundary bridges through HostStringText seam (one authority). // §7: seam wrappers are v2-self-host only; v1 seed keeps host String (no v2_std_text module). fn emit_rust_host_to_dag_string_via_seam(host_expr: String, corpus_repr: RustCorpusRepr) -> String { - if corpus_repr == FaithfulFreeMonoid { + if corpus_repr_is_faithful(corpus_repr: corpus_repr) { concat("crate::v2_std_text::host_string_text_from_rust_host(", host_expr, ")") } else { host_expr @@ -242,7 +242,7 @@ fn emit_rust_host_to_dag_string_via_seam(host_expr: String, corpus_repr: RustCor } fn emit_rust_dag_string_to_host_via_seam(dag_expr: String, corpus_repr: RustCorpusRepr) -> String { - if corpus_repr == FaithfulFreeMonoid { + if corpus_repr_is_faithful(corpus_repr: corpus_repr) { concat("crate::v2_std_text::host_string_text_to_rust_host(", dag_expr, ")") } else { dag_expr @@ -288,7 +288,7 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { // (E0277/E0369). DISSOLUTION: remove when the numeric tower gains a faithful // host-realization seam mirroring the text carrier (emit_rust_host_to_dag_string_via_seam). fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> String? { - if (name == "Nat" || name == "Int") && corpus_repr == HostNative { + if (name == "Nat" || name == "Int") && corpus_repr_is_host(corpus_repr: corpus_repr) { Present { value: "i64" } } else { none @@ -303,7 +303,7 @@ fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> St // preserve-nominal alias-RHS policy for non-container nominals (FreeMonoid/Box) or // the v2-TARGET faithful FreeMonoid representation. List ops stay Vec-based. fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> String? { - if name == "List" && corpus_repr == HostNative { + if name == "List" && corpus_repr_is_host(corpus_repr: corpus_repr) { Present { value: "Vec" } } else { none @@ -313,7 +313,7 @@ fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> S fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { if name == "Witness" || name == "witness" { "Witness" - } else if name == "String" && corpus_repr == FaithfulFreeMonoid { + } else if name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) @@ -422,7 +422,7 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type let name = authored_name_at(source_indices: source_indices, node: n) if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name - } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && name == "String" && corpus_repr == FaithfulFreeMonoid { + } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { render_rust_text_carrier(shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && set_contains(shared_types, name) { let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) @@ -474,7 +474,7 @@ fn rust_fn_sig_peel_closed_alias(env: TypeEnv, n: Node) -> Bool { fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let name = authored_name_at(source_indices: source_indices, node: n) - if n.connective == NoConnective && n.children |> count == 0 && name == "String" && corpus_repr == FaithfulFreeMonoid { + if n.connective == NoConnective && n.children |> count == 0 && name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { render_rust_text_carrier(shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) @@ -512,7 +512,7 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared match rust_seed_host_numeric_alias(name: name, corpus_repr: corpus_repr) { Present { value: host } => host Absent => - if name == "String" && corpus_repr == FaithfulFreeMonoid { + if name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { render_rust_text_carrier(shared_types: shared_types) } else { match rust_opaque_kernel_alias_carrier(name: name) { @@ -3749,7 +3749,7 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg let si = scope.type_env.source_indices match rust_host_string_seam_fn_emit(name: name) { Present { value: seam_fn } => - if emit_info.corpus_repr == FaithfulFreeMonoid { seam_fn } else { "" } + if corpus_repr_is_faithful(corpus_repr: emit_info.corpus_repr) { seam_fn } else { "" } Absent => { let type_params = function_type_params(params: params) let value_params = function_value_params(params: params) @@ -6578,7 +6578,7 @@ fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> String? { if type_name == "Int" { Present { value: "0" } } else if type_name == "Bool" { Present { value: "false" } } else if type_name == "String" { - if corpus_repr == FaithfulFreeMonoid { + if corpus_repr_is_faithful(corpus_repr: corpus_repr) { Present { value: "crate::v2_std_algebra::freemonoid_empty::()" } } else { Present { value: "\"\".to_string()" } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 2f8f22d77f7..3fe26ae05d6 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -1,6 +1,7 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.emit_rust +pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::extdeps_languages_rust_emit::HigherOrderMethodSpec; pub use crate::extdeps_languages_rust_emit::{ rt_bridge_function_names, rt_functions, rt_ref_map_functions, rt_wraps_result, @@ -8,8 +9,8 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_templates, rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_struct_derives, rust_struct_derives_copy, }; -pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::SubValueUnknown; +pub use crate::std_induction::{InductiveField, SubValueRelation}; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{is_container_type, is_kernel_type}; @@ -45,19 +46,25 @@ pub use crate::v1_compiler_emit_core_support::{ pub use crate::v1_compiler_emit_core_support::{EmitResult, TestProjection}; pub use crate::v1_compiler_infer::InferScope; pub use crate::v1_compiler_infer::{ - build_emit_graph_info, build_params_scope, expr_span, extend_scope, resolved_type_name, + build_emit_graph_info, build_params_scope, expand_type_for_field_access, expr_span, + extend_scope, resolved_type_name, }; +use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ find_variant_parent, is_enum_in_summaries, is_known_variant, lookup_emit_type_summary, variant_belongs_to_enum, variant_summary_key, }; -pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; +pub use crate::v1_compiler_infer_emit_info::{ + EmitGraphInfo, RustCorpusRepr, TypeRepr, TypeSummary, +}; pub use crate::v1_compiler_infer_env::{authored_name, lookup_type_by_name, lookup_type_for}; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; use crate::v1_compiler_infer_items::ItemKind::{DataItem, OtherItem, TypeItem}; pub use crate::v1_compiler_infer_items::{ItemInfo, ItemKind, ResolvedGraph, TypedModule}; -pub use crate::v1_compiler_infer_resolve::lookup_unit_variant_phantom_type; +pub use crate::v1_compiler_infer_resolve::{ + is_width_nat_type_literal, lookup_unit_variant_phantom_type, +}; pub use crate::v1_compiler_infer_service::{ extract_typed_service_name, is_typed_service_call_receiver, }; @@ -83,7 +90,6 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -112,16 +118,16 @@ use crate::v1_std_core::VarBindingKind::{ }; pub use crate::v1_std_core::{ arg_name_at, arg_value, arm_body, arm_guard, arm_pattern, authored_name_at, binop_left, - binop_right, cast_expr, cast_target, expr_call_func_at, expr_has_non_tail_self_call, - expr_has_self_call, expr_method_name_at, expr_var_name_at, field_access_base, - 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, - find_property, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, - if_condition, if_else_branch, if_then_branch, import_is_all, import_specific_names_at, - index_base, index_expr, is_compiler_error, is_file_transport, is_rest_transport, - is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, let_body, - let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, make_span, - match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + binop_right, cast_expr, cast_target, empty_intern_table, expr_call_func_at, + expr_has_non_tail_self_call, expr_has_self_call, expr_method_name_at, expr_var_name_at, + field_access_base, 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, find_property, foreach_body, foreach_collection, foreach_variable_at, + generic_param_name_at, if_condition, if_else_branch, if_then_branch, import_is_all, + import_specific_names_at, index_base, index_expr, is_compiler_error, is_file_transport, + is_rest_transport, is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, + let_body, let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, + make_span, match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, module_items, param_node_default_value, param_node_name_at, param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, return_value, service_config_auth, service_config_auth_input, service_config_auth_source, @@ -144,6 +150,7 @@ use std::rc::Rc; pub fn render_rust_type( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match n.inferred.clone().as_deref().cloned() { @@ -159,12 +166,26 @@ pub fn render_rust_type( applied.clone(), Rc::new(vec![]), shared_types, + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { render_rust_type_without_applied_binding( n.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -172,6 +193,7 @@ pub fn render_rust_type( None => render_rust_type_without_applied_binding( n.clone(), shared_types, + corpus_repr, source_indices.clone(), ), }, @@ -181,6 +203,7 @@ pub fn render_rust_type( pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if (((n.connective.clone() == Connective::NoConnective) @@ -191,7 +214,17 @@ pub fn render_rust_type_without_applied_binding( n.clone(), Rc::new(vec![]), shared_types, + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::>>>(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -231,19 +264,20 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { - let tn = authored_name_at(source_indices.clone(), n.clone()); - if (tn.clone().as_str() == "String".to_string().as_str() - && ((n.children.clone().len() as i64) == 0) - && rust_emit_faithful_text_carrier(source_indices.clone())) { - render_rust_text_carrier(shared_types.clone()) - } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) + let tn = authored_name_at(source_indices.clone(), n.clone()); + if (((tn == "String".to_string()) && ((n.children.clone().len() as i64) == 0)) + && corpus_repr_is_faithful(corpus_repr)) + { + render_rust_text_carrier(shared_types) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) + } } } } @@ -255,22 +289,21 @@ pub fn empty_string_bool_map() -> Rc> { pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { ((v1_rt::string_length(&type_name) >= 3) - && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) + && (v1_rt::substring(&type_name, 0, 3) == "Rc<".to_string())) } -pub fn rust_corpus_includes_v1_compiler( - source_indices: Rc>>, -) -> bool { - v1_rt::map_keys(&source_indices) - .iter() - .cloned() - .any(|k| k.contains("/v1/") || k.contains("src/v1")) +pub fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> bool { + match corpus_repr { + RustCorpusRepr::FaithfulFreeMonoid => true, + RustCorpusRepr::HostNative => false, + } } -pub fn rust_emit_faithful_text_carrier( - source_indices: Rc>>, -) -> bool { - !rust_corpus_includes_v1_compiler(source_indices) +pub fn corpus_repr_is_host(corpus_repr: RustCorpusRepr) -> bool { + match corpus_repr { + RustCorpusRepr::HostNative => true, + RustCorpusRepr::FaithfulFreeMonoid => false, + } } pub fn render_rust_text_carrier(shared_types: Rc>) -> String { @@ -283,9 +316,9 @@ pub fn render_rust_text_carrier(shared_types: Rc>>, + corpus_repr: RustCorpusRepr, ) -> String { - if rust_emit_faithful_text_carrier(source_indices) { + if corpus_repr_is_faithful(corpus_repr) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), @@ -300,9 +333,9 @@ pub fn emit_rust_host_to_dag_string_via_seam( pub fn emit_rust_dag_string_to_host_via_seam( dag_expr: String, - source_indices: Rc>>, + corpus_repr: RustCorpusRepr, ) -> String { - if rust_emit_faithful_text_carrier(source_indices) { + if corpus_repr_is_faithful(corpus_repr) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), @@ -316,57 +349,52 @@ pub fn emit_rust_dag_string_to_host_via_seam( } pub fn rust_host_string_seam_fn_emit(name: String) -> Option { - if name.as_str() == "host_string_text_from_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), - " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), - ), - "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), - ), - "}\n".to_string(), - )) - } else if name.as_str() == "host_string_text_to_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), - " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), - ), - "}\n".to_string(), - ), - "".to_string(), - )) + if (name.clone() == "host_string_text_from_rust_host".to_string()) { + Some(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string()), "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string()), "}\n".to_string())) } else { - None + if (name.clone() == "host_string_text_to_rust_host".to_string()) { + Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) + } else { + None + } } } pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if (name.clone().as_str() == "Json".to_string().as_str()) - || (name.clone().as_str() == "Bytes".to_string().as_str()) - { + if ((name.clone() == "Json".to_string()) || (name.clone() == "Bytes".to_string())) { Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { None } } -pub fn rust_named_type_base( - name: String, - source_indices: Rc>>, -) -> String { - if ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> Option { + if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) + && corpus_repr_is_host(corpus_repr)) { + Some("i64".to_string()) + } else { + None + } +} + +pub fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> Option { + if ((name == "List".to_string()) && corpus_repr_is_host(corpus_repr)) { + Some("Vec".to_string()) + } else { + None + } +} + +pub fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { + if ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) { "Witness".to_string() - } else if name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices) - { - "FreeMonoid".to_string() } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) + if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr)) { + "FreeMonoid".to_string() + } else { + coerce_primitive_type(RenderTarget::Rust, name.clone()) + } } } @@ -394,15 +422,112 @@ 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()), + None => false, + } +} + +pub fn is_parametric_opaque_type_base( + type_name: String, + def_mod_filename: String, + typed_modules: Rc>>, + source_indices: Rc>>, + module_index: Rc, +) -> bool { + match type_item_by_name_in_module_filename( + type_name, + def_mod_filename, + typed_modules, + source_indices.clone(), + module_index, + ) { + Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), + None => false, + } +} + +pub fn render_rust_phantom_opaque_applied_type_arg( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + corpus_repr: RustCorpusRepr, + source_indices: Rc>>, + scope: Rc, + imports: Rc>>, + registry: Rc>>, + module_name: String, + export_sets: Rc>>>, + typed_modules: Rc>>, + module_index: Rc, + variant_to_enum: Rc>, +) -> String { + if is_width_nat_type_literal(n.clone()) { + "()".to_string() + } else { + render_rust_alias_rhs_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + scope, + imports, + registry, + module_name, + export_sets, + typed_modules, + module_index, + variant_to_enum, + ) + } +} + +pub fn render_rust_phantom_opaque_applied_decl_arg( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + corpus_repr: RustCorpusRepr, + source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_width_nat_type_literal(n.clone()) { + "()".to_string() + } else { + render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + variant_to_enum, + env, + ) + } +} + pub fn render_rust_applied_type_arg( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), + _ => render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + variant_to_enum, + env, + ), } } @@ -410,26 +535,46 @@ pub fn render_rust_applied_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { - let base = rust_named_type_base( - authored_name_at(source_indices.clone(), n.clone()), - source_indices.clone(), - ); + let base_name = authored_name_at(source_indices.clone(), n.clone()); + let base = 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()), + }; if ((n.children.clone().len() as i64) == 0) { base } else { { + 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() { - __result.push(render_rust_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - )); + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_decl_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + }); } __result }) @@ -460,14 +605,20 @@ pub fn render_rust_applied_type_shared( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { let rendered = render_rust_applied_type( n.clone(), generic_param_names, shared_types.clone(), + corpus_repr, source_indices.clone(), + variant_to_enum, + env, ); let type_name = authored_name_at(source_indices.clone(), n.clone()); render_rust_shared_type_if_needed(type_name, rendered, shared_types.clone()) @@ -478,7 +629,10 @@ pub fn render_rust_decl_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -486,8 +640,7 @@ pub fn render_rust_decl_type( "__applied_type_args".to_string(), source_indices.clone(), ); - let has_applied_prop = applied_prop.is_some(); - let applied_overlay = match applied_prop { + let applied_overlay = match applied_prop.clone() { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) @@ -502,7 +655,10 @@ pub fn render_rust_decl_type( applied.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -511,7 +667,7 @@ pub fn render_rust_decl_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (g.clone() == name.clone()) { __found = true; break; } @@ -520,67 +676,103 @@ pub fn render_rust_decl_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && v1_rt::set_contains(&shared_types, name.clone())) - { - let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), - recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }); - let rendered = rust_render_type_leaf_name( - name.clone(), - v1_rt::rc_empty_map::(), - stub_env, - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + if (((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && (name.clone() == "String".to_string())) + && corpus_repr_is_faithful(corpus_repr.clone())) { + render_rust_text_carrier(shared_types.clone()) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && v1_rt::set_contains(&shared_types, name.clone())) { - let base = rust_named_type_base(name.clone(), source_indices.clone()); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), + { + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + if (!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(), - source_indices.clone(), - )); + ) + } else { + { + let base = + rust_named_type_base(name.clone(), corpus_repr.clone()); + let peel = is_parametric_opaque_type_by_name( + env.clone(), + name.clone(), + ); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_decl_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + }); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base, "<".to_string()), + args, + ), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) + } } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - ) } } } @@ -589,53 +781,78 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - if name.clone().as_str() == "String".to_string().as_str() { - return false; - } - let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b, - None => { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b, - None => return false, - } + { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if (name.clone() == "String".to_string()) { + return false; } - }; - (binding.params.clone().len() as i64) == 0 + let binding = match lookup_type_for(env.clone(), n.clone()) { + 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()) { + Some(b) => b.clone(), + None => return false, + } + } + }; + ((binding.params.clone().len() as i64) == 0) + } } pub fn render_rust_fn_sig_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0) - && !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()) - } else if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) - } else { - render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (name.clone() == "String".to_string())) + && corpus_repr_is_faithful(corpus_repr.clone())) + { + render_rust_text_carrier(shared_types) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !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) + } else { + if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types, + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum, + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types, + corpus_repr.clone(), + source_indices.clone(), + env.clone(), + ) + } + } + } } } pub fn render_rust_fn_sig_type_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, env: Rc, ) -> String { @@ -646,25 +863,42 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if ((((outer_name.clone() != "".to_string()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + && rust_fn_sig_peel_closed_alias(env, n.clone())) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) + } } } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) } } - None => render_rust_type_with_applied_binding(n, shared_types, source_indices), + None => render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ), } } @@ -672,6 +906,7 @@ pub fn render_rust_alias_rhs_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, scope: Rc, imports: Rc>>, @@ -689,7 +924,7 @@ pub fn render_rust_alias_rhs_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (g.clone() == name.clone()) { __found = true; break; } @@ -698,85 +933,140 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - { - if name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone()) + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) { - render_rust_text_carrier(shared_types.clone()) - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier + match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { + Some(host) => host.clone(), + None => { + if ((name.clone() == "String".to_string()) + && corpus_repr_is_faithful(corpus_repr.clone())) + { + render_rust_text_carrier(shared_types.clone()) + } else { + 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(), + scope.type_env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } + } + } + } } else { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - scope.type_env.clone(), - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) - } - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = if (def_mod.clone().as_str() != local_mod.as_str()) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - }; - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - scope.clone(), + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), imports.clone(), + scope.clone(), registry.clone(), - module_name.clone(), export_sets.clone(), typed_modules.clone(), + source_indices.clone(), module_index.clone(), - variant_to_enum.clone(), - )); + ); + let base = match rust_seed_host_container_base( + name.clone(), + corpus_repr.clone(), + ) { + Some(host) => host.clone(), + None => { + if (def_mod.clone() != local_mod) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + } + } + }; + let peel = is_parametric_opaque_type_base( + name.clone(), + def_mod.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + ) + } else { + render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + ) + }); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + } else { + applied_ty.clone() + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - applied_ty.clone() + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } - } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -903,14 +1193,14 @@ pub fn rust_nominal_identity_carrier_def(name: String) -> String { } pub fn rust_nominal_identity_carrier_type_eligible(type_name: String) -> bool { - (type_name.as_str() == "Symbol".to_string().as_str()) + (type_name == "Symbol".to_string()) } pub fn rust_nominal_identity_carrier_shape_eligible( n: Rc, source_indices: Rc>>, ) -> bool { - ((((authored_name_at(source_indices, n.clone()).as_str() == "Symbol".to_string().as_str()) + ((((authored_name_at(source_indices, n.clone()) == "Symbol".to_string()) && ((n.children.clone().len() as i64) == 0)) && ((n.params.clone().len() as i64) == 0)) && (n.connective.clone() == Connective::NoConnective)) @@ -921,8 +1211,7 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( children: Rc>>, source_indices: Rc>>, ) -> bool { - if ((name.as_str() != "DiffId".to_string().as_str()) || ((children.clone().len() as i64) != 1)) - { + if ((name != "DiffId".to_string()) || ((children.clone().len() as i64) != 1)) { false } else { match children.clone().first().cloned() { @@ -956,8 +1245,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().as_str() == "Symbol".to_string().as_str()) - || (type_name.clone().as_str() == "DiffId".to_string().as_str()))) + && ((type_name.clone() == "Symbol".to_string()) + || (type_name.clone() == "DiffId".to_string()))) } } @@ -1058,9 +1347,7 @@ pub fn field_value_by_name( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at(fi.clone(), source_indices.clone()).as_str() - == field_name.clone().as_str()) - { + if (field_init_node_name_at(fi.clone(), source_indices.clone()) == field_name.clone()) { __result.push(fi); } } @@ -1130,18 +1417,16 @@ pub fn rust_string_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (naming_name.clone() == "AsAuthored".to_string()) { rust_string_as_authored_policy() } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (naming_name.clone() == "SnakeCase".to_string()) { rust_snake_string_policy() } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { rust_screaming_snake_string_policy() } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1158,9 +1443,7 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1177,35 +1460,15 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) + if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) { - 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()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + 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())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1227,7 +1490,7 @@ pub fn rust_internal_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (naming_name.clone() == "AsAuthored".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1238,7 +1501,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (naming_name.clone() == "SnakeCase".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1249,7 +1512,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1260,9 +1523,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1282,9 +1543,7 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1304,41 +1563,15 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) + if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) { - 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()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + 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())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1384,10 +1617,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ) -> Rc { { let encoding_name = authored_name_at(source_indices.clone(), ve.clone()); - if (encoding_name.clone().as_str() == "InternallyTaggedObject".to_string().as_str()) { + if (encoding_name.clone() == "InternallyTaggedObject".to_string()) { rust_internal_policy_for_encoding(ve.clone(), source_indices.clone()) } else { - if (encoding_name.clone().as_str() == "StringVariant".to_string().as_str()) { + 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()), None => rust_serde_error_policy( @@ -1395,10 +1628,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ), } } else { - if (encoding_name.clone().as_str() == "UntaggedVariant".to_string().as_str()) { + if (encoding_name.clone() == "UntaggedVariant".to_string()) { rust_untagged_policy() } else { - if (encoding_name.clone().as_str() == "TaggedVariant".to_string().as_str()) { + if (encoding_name.clone() == "TaggedVariant".to_string()) { rust_tagged_object_policy() } else { rust_serde_error_policy(v1_rt::concat( @@ -1428,8 +1661,7 @@ pub fn resolve_wire_serde_policy( } pub fn item_binding_is_named(env: Rc, node: Rc, name: String) -> bool { - ((authored_name(env, node.clone()).as_str() == name.clone().as_str()) - || (node.name.clone().as_str() == name.clone().as_str())) + ((authored_name(env, node.clone()) == name.clone()) || (node.name.clone() == name.clone())) } pub fn resolve_wire_serde_policy_for_coproduct( @@ -1622,7 +1854,7 @@ pub fn variant_encoding_is_string_variant( encoding: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, encoding).as_str() == "StringVariant".to_string().as_str()) + (authored_name_at(source_indices, encoding) == "StringVariant".to_string()) } pub fn coproduct_wire_contract_targets( @@ -1633,7 +1865,7 @@ pub fn coproduct_wire_contract_targets( match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { - Some(target_name) => (target_name.clone().as_str() == coproduct_name.as_str()), + Some(target_name) => (target_name.clone() == coproduct_name), None => false, } } @@ -1662,15 +1894,15 @@ pub fn module_imports_std_serialization_coproduct_wire_contract( { let mut __found = false; for imp in imports.iter().cloned() { - if ((authored_name_at(source_indices.clone(), imp.clone()).as_str() - == "std.serialization".to_string().as_str()) + if ((authored_name_at(source_indices.clone(), imp.clone()) + == "std.serialization".to_string()) && (import_is_all(imp.clone()) || { let mut __found = false; for name in import_specific_names_at(imp.clone(), source_indices.clone()) .iter() .cloned() { - if (name.clone().as_str() == "CoproductWireContract".to_string().as_str()) { + if (name.clone() == "CoproductWireContract".to_string()) { __found = true; break; } @@ -1693,8 +1925,8 @@ 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.clone()).as_str() - == "CoproductWireContract".to_string().as_str()) + ((authored_name_at(source_indices.clone(), type_node.clone()) + == "CoproductWireContract".to_string()) && module_imports_std_serialization_coproduct_wire_contract( imports, source_indices.clone(), @@ -1714,8 +1946,8 @@ pub fn module_defines_local_coproduct_wire_contract_type( if (((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), item.clone()).as_str() - == "CoproductWireContract".to_string().as_str())) + && (authored_name_at(source_indices.clone(), item.clone()) + == "CoproductWireContract".to_string())) { __found = true; break; @@ -1776,7 +2008,7 @@ pub fn emit_coproduct_wire_contract_target_validation( if { let mut __found = false; for name in local_coproduct_names.iter().cloned() { - if (name.clone().as_str() == target_name.clone().as_str()) { + if (name.clone() == target_name.clone()) { __found = true; break; } @@ -1841,7 +2073,7 @@ pub fn emit_coproduct_wire_contract_validations( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (text.clone() != "".to_string()) { __result.push(text); } } @@ -2198,19 +2430,166 @@ pub fn emit_rust_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; - remaining = __tco_0; - text = __tco_1; - scope = __tco_2; - continue; + let __tco_0 = rest.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; + continue; + } + } + } + } + } + } +} + +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + 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(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name.clone() + } else { + match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum), + } + } +} + +pub fn rust_phantom_zst_marker_def(vname: String) -> String { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]\n".to_string(), rust_visibility_prefix()), rust_items().struct_keyword.clone()), " ".to_string()), vname), ";".to_string()) +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + { + let markers = Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if ((child.children.clone().len() as i64) == 0) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + if is_phantom_unit_variant_type_arg( + env.clone(), + authored_name(env.clone(), child.clone()), + ) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + __result.push({ + let vname = authored_name(env.clone(), child.clone()); + rust_phantom_zst_marker_def(vname.clone()) + }); + } + __result + }) + .join(&"\n".to_string()); + markers + } +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (is_type_def_item(item.clone()) && { + let mut __all = true; + for c in item.children.clone().iter().cloned() { + if !((c.children.clone().len() as i64) == 0) { + __all = false; + break; + } + } + __all + }) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { + item.children.clone().iter().cloned().fold( + acc, + |inner: Rc>, child: Rc| { + if ((child.children.clone().len() as i64) == 0) { + { + let vname = authored_name(env.clone(), child.clone()); + if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !{ + let mut __found = false; + for n in inner.clone().iter().cloned() { + if (n.clone() == vname.clone()) { + __found = true; + break; + } + } + __found + }) + { + v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + } else { + inner.clone() } } + } else { + inner.clone() } - } + }, + ) + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { + __result.push(rust_phantom_zst_marker_def(vname.clone())); } - } + __result + }) + .join(&"\n".to_string()) } pub fn has_complex_variants(item: Rc) -> bool { @@ -2352,9 +2731,8 @@ pub fn build_shared_types( .iter() .cloned() { - if ((sharing.needs_sharing.clone() - && (k.clone().as_str() != "optional".to_string().as_str())) - && (k.clone().as_str() != "boolean_algebra".to_string().as_str())) + if ((sharing.needs_sharing.clone() && (k.clone() != "optional".to_string())) + && (k.clone() != "boolean_algebra".to_string())) { __result.push(k); } @@ -2532,6 +2910,7 @@ pub fn emit_rust(typed: Rc) -> Rc { owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let registry = typed.item_registry.clone(); @@ -2612,18 +2991,18 @@ pub fn emit_rust(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone().as_str() + if (p.module_name.clone() == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ) - .as_str()) + )) { __result.push(p); } } __result }), + emit_info.corpus_repr.clone(), )); } __result @@ -2631,7 +3010,7 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (f.path.clone() != "".to_string()) { __result.push(f); } } @@ -2642,8 +3021,7 @@ pub fn emit_rust(typed: Rc) -> Rc { 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()) - .as_str() - == "v1.compiler.compile".to_string().as_str()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -2752,7 +3130,7 @@ pub fn emit_lib_rs_from_files( __result }); let hand_maintained_mods = if has_compiler_tests.clone() { - "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() + "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod languages_consumer_census;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() } else { "".to_string() }; @@ -2762,9 +3140,6 @@ pub fn emit_lib_rs_from_files( "".to_string() }; let shared_types = emit_non_empty_wrappers(); - // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (single authority): - // crate-root #![recursion_limit = "256"] added (serde_json::json! recursion fix). - // DISSOLUTION lane adhoc-1bdd0259-2e3; a clean regen reproduces this from the .dag. let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); Rc::new(TextFile { path: v1_rt::concat( @@ -2799,6 +3174,7 @@ pub fn emit_module( owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let export_sets = build_module_export_sets(Rc::new(vec![typed_module.clone()])); @@ -2895,7 +3271,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), module_index.clone(), ); - let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { + let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n".to_string(), imports_str.clone()) @@ -2925,7 +3301,7 @@ pub fn emit_module_full( __result.extend( (*match v1_rt::map_get(&svc_module_map, sn.clone()) { Some(mod_file) => { - if (mod_file.clone().as_str() == this_mod_filename.clone().as_str()) { + if (mod_file.clone() == this_mod_filename.clone()) { Rc::new(vec![]) } else { Rc::new(vec![v1_rt::concat( @@ -3012,7 +3388,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = - if (coproduct_wire_contract_validations.clone().as_str() == "".to_string().as_str()) { + if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat( @@ -3073,19 +3449,19 @@ 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()); - let phantom_section = if phantom_zst_markers.as_str() == "" { + 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(authored_name(scope.type_env.clone(), m.clone())); - let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { + 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()).as_str() - == "std.error_primitives".to_string().as_str()) + 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 { @@ -3287,10 +3663,10 @@ pub fn has_physical_type_def_in_module_filename( if { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) - && (is_type_def_item(item.clone()) - || is_type_alias_item(item.clone(), source_indices.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()) + == rhs_name.clone()) + && ((is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; @@ -3342,8 +3718,8 @@ pub fn find_variant_parent_in_module( if { let mut __found = false; for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()).as_str() - == variant_name.clone().as_str()) + if (authored_name_at(source_indices.clone(), child.clone()) + == variant_name.clone()) { __found = true; break; @@ -3385,8 +3761,7 @@ pub fn type_name_is_export_source_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3419,8 +3794,7 @@ pub fn type_name_is_rust_importable_in_module( Some(tm) => match Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3502,7 +3876,7 @@ pub fn name_in_transitive_export_surface( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (v.clone() == module_name.clone()) { __found = true; break; } @@ -3597,7 +3971,7 @@ pub fn reexport_source_module_name_with_visited( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == import_module.clone().as_str()) { + if (v.clone() == import_module.clone()) { __found = true; break; } @@ -3651,8 +4025,7 @@ pub fn reexport_source_module_name_with_visited( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) - { + if (n.clone() == name.clone()) { __found = true; break; } @@ -3826,7 +4199,7 @@ pub fn import_module_enum_scope( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { __result.push(p); } } @@ -3901,8 +4274,7 @@ pub fn enum_physically_defined_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if (((authored_name_at(source_indices.clone(), item.clone()).as_str() - == enum_name.clone().as_str()) + if (((authored_name_at(source_indices.clone(), item.clone()) == enum_name.clone()) && is_type_def_item(item.clone())) && is_coproduct_type(item.clone())) { @@ -3927,7 +4299,7 @@ pub fn wildcard_import_pool_surface_names( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (v.clone() == module_name.clone()) { __found = true; break; } @@ -4024,7 +4396,7 @@ pub fn wildcard_reexport_surface_names( source_indices.clone(), module_index.clone(), ) { - Some(src) => (src.clone().as_str() != import_module.clone().as_str()), + Some(src) => (src.clone() != import_module.clone()), None => false, } { __result.push(n); @@ -4097,7 +4469,7 @@ pub fn variant_defining_module_filename_for_import( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != import_module.clone().as_str()) { + if (hop.clone() != import_module.clone()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4135,7 +4507,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone().as_str() == parent_enum.clone().as_str()) { + if (local_parent.clone() == parent_enum.clone()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -4187,7 +4559,7 @@ pub fn explicit_import_source_module_for_name( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (n.clone() == name.clone()) { __found = true; break; } @@ -4300,7 +4672,7 @@ pub fn reexport_variant_parent_in_import_module( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != src_mod.clone().as_str()) { + if (hop.clone() != src_mod.clone()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4391,7 +4763,7 @@ pub fn alias_rhs_base_module_filename( let local_mod = module_to_filename(alias_module.clone()); match lookup_item(scope.item_registry.clone(), name.clone()) { Some(info) => { - if ((info.module_name.clone().as_str() == alias_module.clone().as_str()) + if ((info.module_name.clone() == alias_module.clone()) && ((info.kind.clone() == ItemKind::TypeItem) || (info.kind.clone() == ItemKind::OtherItem))) { @@ -4444,7 +4816,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (n.clone() == name.clone()) { __found = true; break; } @@ -4551,8 +4923,8 @@ pub fn type_item_by_name_in_module_filename( Some(tm) => Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) + == rhs_name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -4599,28 +4971,12 @@ pub fn type_item_has_rust_nominal_shell_authority( { true } else { - let rhs = resolved_type(item.clone()); - if is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && ((rhs.children.clone().len() as i64) > 0) - { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else if is_type_alias_return_node(rhs.clone(), source_indices.clone()) { - let rhs_name = - authored_name_at(source_indices.clone(), rhs.clone()); - (rhs_name.as_str() != item_text.as_str()) - && rhs_name.as_str() != "" - && alias_rhs_nominal_shell_has_rust_authority( + let rhs = resolved_type(item.clone()); + if (is_type_alias_return_node(rhs.clone(), source_indices.clone()) + && ((rhs.children.clone().len() as i64) > 0)) + { + alias_rhs_nominal_shell_has_rust_authority( rhs.clone(), module_name, imports, @@ -4631,8 +4987,34 @@ pub fn type_item_has_rust_nominal_shell_authority( source_indices.clone(), module_index, ) - } else { - false + } else { + if is_type_alias_return_node( + rhs.clone(), + source_indices.clone(), + ) { + { + let rhs_name = authored_name_at( + source_indices.clone(), + rhs.clone(), + ); + (((rhs_name.clone() != item_text.clone()) + && (rhs_name.clone() != "".to_string())) + && alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + )) + } + } else { + false + } + } } } } else { @@ -4830,9 +5212,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( } else { { let name = authored_name_at(source_indices.clone(), n.clone()); - if ((name.clone().as_str() == "".to_string().as_str()) - || is_kernel_type(name.clone())) - { + if ((name.clone() == "".to_string()) || is_kernel_type(name.clone())) { true } else { if is_phantom_unit_variant_type_arg( @@ -4881,91 +5261,100 @@ pub fn is_self_referential_opaque_type_resolved( item: Rc, source_indices: Rc>>, ) -> bool { - 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 + { + 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)) + } } pub fn is_zero_param_self_referential_opaque_decl( item: Rc, source_indices: Rc>>, ) -> bool { - is_bare_leaf_item(item.clone()) - && is_self_referential_opaque_type_resolved(item.clone(), source_indices) + (is_bare_leaf_item(item.clone()) + && is_self_referential_opaque_type_resolved(item.clone(), source_indices)) } pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((item.params.clone().len() as i64) > 0) - && item.body.is_none() - && item.transport.is_none() - && (item.children.clone().len() as i64) == 0 + ((((((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)) + || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) } pub fn emit_zero_param_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - v1_rt::concat( + { + let item_text = authored_name_at(source_indices, item); v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), + v1_rt::concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), + ), + rust_items().struct_keyword.clone(), ), - rust_items().struct_keyword.clone(), - ), - v1_rt::concat( - v1_rt::concat(" ".to_string(), item_text), - "(pub std::marker::PhantomData<()>);".to_string(), + " ".to_string(), ), + item_text, ), - "".to_string(), - ), - "".to_string(), - ) + "(pub std::marker::PhantomData<()>);".to_string(), + ) + } } pub fn emit_parametric_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - let type_params = emit_type_params(item.params.clone(), source_indices.clone()); - 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(), g), - ">".to_string(), - ), - None => "std::marker::PhantomData<()>".to_string(), - }; - v1_rt::concat( + { + let item_text = authored_name_at(source_indices.clone(), item.clone()); + let type_params = emit_type_params(item.params.clone(), source_indices.clone()); + 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(), g.clone()), + ">".to_string(), + ), + None => "std::marker::PhantomData<()>".to_string(), + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n" + .to_string(), + rust_visibility_prefix(), + ), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + item_text, + ), + type_params, ), - rust_items().struct_keyword.clone(), + "(pub ".to_string(), ), - v1_rt::concat(v1_rt::concat(" ".to_string(), item_text), type_params), + marker_ty, ), - v1_rt::concat( - v1_rt::concat("(pub ".to_string(), marker_ty), - ");".to_string(), - ), - ), - "".to_string(), - ) + ");".to_string(), + ) + } } pub fn is_emittable_parametric_type_alias_item( @@ -4995,37 +5384,21 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs_name = authored_name_at(source_indices.clone(), rhs.clone()); - if rhs_name.as_str() != item_text.as_str() { - if (rhs.children.clone().len() as i64) > 0 { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else if rhs_name.as_str() != "" { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else { - false - } - } else { - false - } + ((rhs_name.clone() != item_text) + && (((rhs.children.clone().len() as i64) > 0) + || ((((rhs.children.clone().len() as i64) == 0) + && (rhs_name.clone() != "".to_string())) + && alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + )))) } } } @@ -5053,7 +5426,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for ln in local_names.clone().iter().cloned() { - if !(ln.clone().as_str() != n.clone().as_str()) { + if !(ln.clone() != n.clone()) { __all = false; break; } @@ -5195,7 +5568,7 @@ pub fn emit_specific_import_block( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { __result.push(p); } } @@ -5229,7 +5602,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, } { __found = true; @@ -5251,7 +5624,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for n in direct_names.clone().iter().cloned() { - if !(n.clone().as_str() != p.clone().as_str()) { + if !(n.clone() != p.clone()) { __all = false; break; } @@ -5276,7 +5649,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, } { __found = true; @@ -5360,9 +5733,7 @@ pub fn emit_specific_import_block( export_sets.clone(), source_indices.clone(), module_index.clone(), - ) - .as_str() - == def_mod.clone().as_str()) + ) == def_mod.clone()) { __result.push(n); } @@ -5440,13 +5811,13 @@ pub fn emit_specific_import_block( Rc::new({ let mut __result = Vec::new(); for l in type_direct_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } __result }), - if (other_direct_line.clone().as_str() != "".to_string().as_str()) { + if (other_direct_line.clone() != "".to_string()) { Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) @@ -5466,9 +5837,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } + Some(found) => (found.clone() == p.clone()), None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -5479,9 +5848,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } + Some(found) => (found.clone() == p.clone()), None => false, }, } { @@ -5520,15 +5887,15 @@ pub fn emit_specific_import_block( __result.push({ let group = Rc::new({ let mut __result = Vec::new(); for p in remote_parent_list.clone().iter().cloned() { if { let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, }, } { __result.push(n); } } __result }).first().cloned(); match rep_variant.clone() { - Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()).as_str() == def_mod.clone().as_str()), - None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()).as_str() == def_mod.clone().as_str()), + Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()) == def_mod.clone()), + None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()) == def_mod.clone()), } } { __result.push(p); } } __result }); if ((group.clone().len() as i64) > 0) { @@ -5549,7 +5916,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5560,7 +5927,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5596,10 +5963,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) - } + Some(found) => (found.clone() == parent.clone()), None => { match reexport_variant_parent_in_import_module( n.clone(), @@ -5612,8 +5976,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib module_index.clone(), ) { Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) + (found.clone() == parent.clone()) } None => match find_variant_parent( type_summaries.clone(), @@ -5692,7 +6055,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib if ({ let mut __found = false; for p in parent_list.clone().iter().cloned() { - if (p.clone().as_str() == en.clone().as_str()) { + if (p.clone() == en.clone()) { __found = true; break; } @@ -5726,7 +6089,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5735,7 +6098,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in variant_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5859,7 +6222,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { } pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: String) -> bool { - (((rust_pub_use_module_name(line.clone()).as_str() == mod_name.as_str()) + (((rust_pub_use_module_name(line.clone()) == mod_name) && v1_rt::contains(line.clone(), "::{".to_string())) && (((v1_rt::contains( line.clone(), @@ -5892,9 +6255,7 @@ pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> b { let mod_name = rust_pub_use_module_name(line.clone()); let name = rust_pub_use_singleton_name(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || (name.clone().as_str() == "".to_string().as_str())) - { + if ((mod_name.clone() == "".to_string()) || (name.clone() == "".to_string())) { false } else { { @@ -5919,17 +6280,14 @@ pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || ((names.clone().len() as i64) == 0)) - { + if ((mod_name.clone() == "".to_string()) || ((names.clone().len() as i64) == 0)) { false } else { { let mut __found = false; for other in lines.iter().cloned() { - if (((((other.clone().as_str() != line.clone().as_str()) - && (rust_pub_use_module_name(other.clone()).as_str() - == mod_name.clone().as_str())) + if (((((other.clone() != line.clone()) + && (rust_pub_use_module_name(other.clone()) == mod_name.clone())) && v1_rt::contains(other.clone(), "::{".to_string())) && ((rust_pub_use_braced_names(other.clone()).len() as i64) > (names.clone().len() as i64))) @@ -5968,9 +6326,7 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> Rc> { let exact = unique_strings(Rc::new({ let mut __result = Vec::new(); for line in lines.iter().cloned() { - if (line.clone().as_str() != "".to_string().as_str()) { + if (line.clone() != "".to_string()) { __result.push(line); } } @@ -6083,8 +6439,7 @@ pub fn emit_imports( let mut __result = Vec::new(); for imp in imports.clone().iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - .as_str() - == import_module.clone().as_str()) + == import_module.clone()) { __result.push(imp); } @@ -6154,8 +6509,7 @@ pub fn emit_imports( source_indices.clone(), module_index.clone(), ); - if (specific_block.clone().as_str() != "".to_string().as_str()) - { + if (specific_block.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat(wildcard_line.clone(), "\n".to_string()), specific_block.clone(), @@ -6285,44 +6639,74 @@ pub fn emit_typed_item( && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { rust_nominal_identity_carrier_def(item_text.clone()) - } else if is_zero_param_self_referential_opaque_decl( - item.clone(), - env.source_indices.clone(), - ) { - emit_zero_param_phantom_opaque_struct(item.clone(), env.source_indices.clone()) } else { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( + if is_zero_param_self_referential_opaque_decl( + item.clone(), + env.source_indices.clone(), + ) { + emit_zero_param_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + match rust_seed_host_numeric_alias( + item_text.clone(), + emit_info.corpus_repr.clone(), + ) { + Some(host) => v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), + ), + " ".to_string(), + ), + item_text.clone(), ), - " ".to_string(), + " = ".to_string(), ), - item_text.clone(), + host.clone(), ), - " = ".to_string(), + ";".to_string(), ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - Rc::new(vec![]), - shared_types, - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), + ), + " ".to_string(), + ), + item_text.clone(), + ), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + Rc::new(vec![]), + shared_types, + emit_info.corpus_repr.clone(), + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), ), - ), - ";".to_string(), - ) + } + } } } else { if is_type_decl_item(item.clone(), env.source_indices.clone()) { @@ -6331,19 +6715,11 @@ pub fn emit_typed_item( { rust_nominal_identity_carrier_def(item_text.clone()) } else { - if is_emittable_parametric_type_alias_item( - item.clone(), + match rust_seed_host_container_base( item_text.clone(), - env.source_indices.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), + emit_info.corpus_repr.clone(), ) { - { + Some(host) => { let type_params = emit_type_params( item.params.clone(), env.source_indices.clone(), @@ -6359,45 +6735,105 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items() + .type_alias_keyword + .clone(), + ), + " ".to_string(), + ), + item_text.clone(), ), - " ".to_string(), + type_params, ), - item_text.clone(), + " = ".to_string(), ), - type_params, + host.clone(), ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - generic_names, - shared_types, - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + "<".to_string(), ), + generic_names.join(&", ".to_string()), ), - ";".to_string(), + ">;".to_string(), ) } - } else if is_parametric_opaque_type_decl_item( - item.clone(), - env.source_indices.clone(), - ) { - emit_parametric_phantom_opaque_struct( - item.clone(), - env.source_indices.clone(), - ) - } else { - "".to_string() + None => { + if is_emittable_parametric_type_alias_item( + item.clone(), + item_text.clone(), + env.source_indices.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + ) { + { + let type_params = emit_type_params( + item.params.clone(), + env.source_indices.clone(), + ); + let generic_names = item_generic_param_names( + item.clone(), + env.source_indices.clone(), + ); + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items() + .type_alias_keyword + .clone(), + ), + " ".to_string(), + ), + item_text.clone(), + ), + type_params, + ), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + generic_names, + shared_types, + emit_info.corpus_repr.clone(), + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), + ) + } + } else { + if is_parametric_opaque_type_decl_item( + item.clone(), + env.source_indices.clone(), + ) { + emit_parametric_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + "".to_string() + } + } + } } } } else { @@ -6441,6 +6877,7 @@ pub fn emit_typed_item( owned_bindings: v1_rt::rc_empty_set::(), 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(), @@ -6495,11 +6932,17 @@ pub fn emit_typed_item( item.clone(), registry.clone(), shared_types, + emit_info.corpus_repr.clone(), env.clone(), ) } else { if is_resource_def_item(item.clone()) { - emit_resource_def(item.clone(), shared_types, env.clone()) + emit_resource_def( + item.clone(), + shared_types, + emit_info.corpus_repr.clone(), + env.clone(), + ) } else { v1_rt::concat( v1_rt::concat( @@ -6530,9 +6973,7 @@ pub fn needs_box_wrapping( if v1_rt::set_contains(&shared_types, name.clone()) { break false; } else { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()).as_str() - != name.clone().as_str()) - { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { break false; } else { break v1_rt::set_contains(&recursive_types, name.clone()); @@ -6583,12 +7024,11 @@ pub fn is_function_type_param(param: Rc) -> bool { Some(inf) => is_type_variable(inf.clone()), None => false, }; - let same_source_span = (((param.span.clone().file.clone().as_str() - == type_expr.span.clone().file.clone().as_str()) + let same_source_span = (((param.span.clone().file.clone() + == type_expr.span.clone().file.clone()) && (param.span.clone().start.clone() == type_expr.span.clone().start.clone())) && (param.span.clone().end.clone() == type_expr.span.clone().end.clone())); - (((param.name.clone().as_str() != "".to_string().as_str()) - && (param.name.clone().as_str() == type_expr.name.clone().as_str())) + (((param.name.clone() != "".to_string()) && (param.name.clone() == type_expr.name.clone())) && (type_expr_is_var || same_source_span)) } } @@ -6709,11 +7149,10 @@ pub fn emit_type_def_from_connective( Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; - let validations = if (policy_validation.clone().as_str() == "".to_string().as_str()) - { + let validations = if (policy_validation.clone() == "".to_string()) { rename_validations.clone() } else { - if (rename_validations.clone().as_str() == "".to_string().as_str()) { + if (rename_validations.clone() == "".to_string()) { policy_validation.clone() } else { v1_rt::concat( @@ -6740,7 +7179,7 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), emit_info, ); - if (validations.clone().as_str() == "".to_string().as_str()) { + if (validations.clone() == "".to_string()) { enum_text } else { v1_rt::concat( @@ -6753,6 +7192,73 @@ pub fn emit_type_def_from_connective( } } +pub fn type_node_mentions_name( + n: Rc, + target: String, + source_indices: Rc>>, +) -> bool { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (authored_name_at(source_indices.clone(), n.clone()) == target.clone()) { + true + } else { + { + let mut __found = false; + for c in n.children.clone().iter().cloned() { + if type_node_mentions_name(c.clone(), target.clone(), source_indices.clone()) { + __found = true; + break; + } + } + __found + } + } + }) +} + +pub fn struct_unused_param_names( + generic_param_names: Rc>, + children: Rc>>, + source_indices: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for p in generic_param_names.iter().cloned() { + if !{ + let mut __found = false; + for child in children.clone().iter().cloned() { + if type_node_mentions_name( + field_node_type_expr(child.clone()), + p.clone(), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + } { + __result.push(p); + } + } + __result + }) +} + +pub fn rust_phantom_marker_inner(unused: Rc>) -> String { + if ((unused.clone().len() as i64) == 1) { + unused.clone().join(&", ".to_string()) + } else { + v1_rt::concat( + v1_rt::concat("(".to_string(), unused.clone().join(&", ".to_string())), + ")".to_string(), + ) + } +} + +pub fn rust_phantom_field_name() -> String { + "_phantom".to_string() +} + pub fn emit_struct_from_children( name: String, type_params: String, @@ -6775,9 +7281,7 @@ pub fn emit_struct_from_children( name.clone(), children.clone(), env.source_indices.clone(), - ) - .as_str() - != "".to_string().as_str()) + ) != "".to_string()) { rust_nominal_ord_derives_for_shape( name.clone(), @@ -6829,7 +7333,32 @@ pub fn emit_struct_from_children( } __result }); - let fields_str = field_lines.join(&"\n".to_string()); + let unused_params = struct_unused_param_names( + generic_param_names.clone(), + children.clone(), + env.source_indices.clone(), + ); + let all_field_lines = if ((unused_params.clone().len() as i64) > 0) { + v1_rt::concat( + field_lines, + Rc::new(vec![v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(" ".to_string(), rust_visibility_prefix()), + rust_phantom_field_name(), + ), + ": std::marker::PhantomData<".to_string(), + ), + rust_phantom_marker_inner(unused_params.clone()), + ), + ">,".to_string(), + )]), + ) + } else { + field_lines + }; + let fields_str = all_field_lines.join(&"\n".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -6863,6 +7392,7 @@ pub fn emit_struct_from_children( pub fn render_rust_type_with_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match find_property( @@ -6872,51 +7402,93 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 { - if outer_name != applied_name { - render_rust_shared_type_if_needed( - 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, - shared_types.clone(), - ) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if (((outer_name.clone() != "".to_string()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + { + if (outer_name.clone() != applied_name) { + render_rust_shared_type_if_needed( + outer_name.clone(), + 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.clone(), + shared_types.clone(), + ) + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >( + ), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), + ) + } + } } else { render_rust_applied_type_shared( applied.clone(), Rc::new(vec![]), - shared_types, + shared_types.clone(), + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types, - source_indices.clone(), - ) } } else { - render_rust_type(n.clone(), shared_types, source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + ) } } - None => render_rust_type(n.clone(), shared_types, source_indices.clone()), + None => render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + ), } } pub fn render_rust_field_type_with_applied_binding( field: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -6930,6 +7502,7 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( field.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } else { @@ -6942,17 +7515,24 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( authored_type.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } else { if ((authored_type.connective.clone() == Connective::NoConnective) && ((authored_type.children.clone().len() as i64) > 0)) { - render_rust_type(authored_type.clone(), shared_types, source_indices.clone()) + render_rust_type( + authored_type.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) } else { render_rust_type_with_applied_binding( resolved_type(field.clone()), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -6990,6 +7570,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7002,6 +7583,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( authored_child_type.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7014,6 +7596,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7060,6 +7643,7 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7067,6 +7651,7 @@ pub fn emit_struct_field_from_child( None => render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), } @@ -7075,6 +7660,7 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7082,7 +7668,7 @@ pub fn emit_struct_field_from_child( } } }; - let generic_ty = if (struct_name.as_str() == "PartialFunction".to_string().as_str()) { + let generic_ty = if (struct_name == "PartialFunction".to_string()) { rust_normalize_partial_function_field_type_text(rust_normalize_witness_type_text(ty)) } else { ty @@ -7113,8 +7699,8 @@ pub fn emit_struct_field_from_child( let rename_attr = match Rc::new({ let mut __result = Vec::new(); for p in child.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), env.source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (field_init_node_name_at(p.clone(), env.source_indices.clone()) + == "from_key".to_string()) { __result.push(p); } @@ -7159,19 +7745,18 @@ pub fn emit_rust_field_definition( { let snake = to_snake(authored.clone()); let emitted = emit_ident(authored.clone(), RenderTarget::Rust); - let keyword_rename = if ((emitted.clone().as_str() != snake.clone().as_str()) - && (rename_attr.clone().as_str() == "".to_string().as_str())) - { - v1_rt::concat( + let keyword_rename = + if ((emitted.clone() != snake.clone()) && (rename_attr.clone() == "".to_string())) { v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + v1_rt::concat( + v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), + snake.clone(), + ), + "\")]\n".to_string(), + ) + } else { + "".to_string() + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7241,7 +7826,7 @@ pub fn emit_enum_from_children( __result }); let variants_str = variant_lines.join(&"\n".to_string()); - let tag_line = if (serde_policy.enum_attr.clone().as_str() == "".to_string().as_str()) { + let tag_line = if (serde_policy.enum_attr.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) @@ -7283,7 +7868,7 @@ pub fn emit_enum_from_children( env.clone(), emit_info.clone(), ); - if (accessor_impl.clone().as_str() == "".to_string().as_str()) { + if (accessor_impl.clone() == "".to_string()) { enum_def } else { v1_rt::concat( @@ -7332,9 +7917,7 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> if !({ let mut __found = false; for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __found = true; break; } @@ -7398,8 +7981,7 @@ pub fn emit_enum_shared_accessors( match Rc::new({ let mut __result = Vec::new(); for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __result.push(f); } @@ -7412,6 +7994,7 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "".to_string(), @@ -7427,7 +8010,7 @@ pub fn emit_enum_shared_accessors( { let mut __all = true; for t in types.clone().iter().cloned() { - if !(t.clone().as_str() == first_type.clone().as_str()) { + if !(t.clone() == first_type.clone()) { __all = false; break; } @@ -7450,9 +8033,7 @@ pub fn emit_enum_shared_accessors( let ty = match Rc::new({ let mut __result = Vec::new(); for f in first_fielded.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __result.push(f); } } @@ -7464,6 +8045,7 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "compile_error!(\"enum shared accessor missing field metadata\")" @@ -7609,8 +8191,7 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) - && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)).as_str() - == prefix.clone().as_str())) + && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)) == prefix.clone())) { Some(v1_rt::substring( &value, @@ -7632,9 +8213,7 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { &value, (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), v1_rt::string_length(&value), - ) - .as_str() - == suffix.clone().as_str())) + ) == suffix.clone())) { Some(v1_rt::substring( &value, @@ -7647,67 +8226,120 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } +pub fn string_index_of_from(mut haystack: String, mut needle: String, mut pos: i64) -> Option { + loop { + if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { + break None; + } else { + if (v1_rt::substring( + &haystack, + pos.clone(), + (pos.clone() + v1_rt::string_length(&needle)), + ) == needle.clone()) + { + break Some(pos.clone()); + } else { + { + let __tco_0 = (pos + 1); + pos = __tco_0; + continue; + } + } + } + } +} + +pub fn string_index_of(haystack: String, needle: String) -> Option { + string_index_of_from(haystack, needle, 0) +} + pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, ) -> Option { - if policy.error_message.is_some() { - return None; - } - match policy.rename_style.clone() { - Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { - let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix) { - Some(stripped) => stripped, - 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, - }, - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } else { - None + if (policy.error_message.clone() != None) { + None + } else { + match policy.rename_style.clone() { + Some(style) => { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + { + let without_prefix = match policy.rename_prefix.clone() { + 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.clone()) { + Some(stripped) => stripped.clone(), + None => return None, + } + } + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } + } else { + None + } } - } - None => { - if policy.enum_attr.contains("rename_all = \"snake_case\"") { - Some(to_snake(authored)) - } else if policy.enum_attr.is_empty() - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - { - Some(authored) - } else { - None + None => { + if v1_rt::contains( + policy.enum_attr.clone(), + "rename_all = \"snake_case\"".to_string(), + ) { + Some(to_snake(authored)) + } else { + if (((policy.enum_attr.clone() == "".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + { + Some(authored) + } else { + None + } + } } } } } -pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { - let needle = "tag = \""; - let start = policy.enum_attr.find(needle)? + needle.len(); - let rest = &policy.enum_attr[start..]; - let end = rest.find('"')?; - Some(rest[..end].to_string()) +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)); + 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(), + )), + None => None, + } + } + None => None, + } + } } -pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { - policy.enum_attr.contains("untagged") +pub fn policy_is_untagged(policy: Rc) -> bool { + v1_rt::contains(policy.enum_attr.clone(), "untagged".to_string()) } -pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { - !policy.enum_attr.contains("tag =") - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - && policy.rename_style.is_none() +pub fn policy_is_string_variant(policy: Rc) -> bool { + (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + && (policy.rename_style.clone() == None)) } pub fn wire_variant_rename_attr_for_policy( @@ -7717,9 +8349,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.as_str() == "StripAffixAndSnakeCase" { + 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 { @@ -7738,7 +8370,7 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { @@ -7801,7 +8433,7 @@ pub fn variant_rename_validations_for_policy( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (text.clone() != "".to_string()) { __result.push(text); } } @@ -7843,6 +8475,7 @@ pub fn enum_variant_field_type_node( pub fn render_variant_payload_type( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if ((n.connective.clone() == Connective::NoConnective) @@ -7856,6 +8489,7 @@ pub fn render_variant_payload_type( __result.push(render_rust_type( child_type_node(c.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), )); } @@ -7874,7 +8508,12 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } @@ -7886,9 +8525,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).as_str() == "0".to_string().as_str()) - } + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, } } @@ -7923,8 +8560,7 @@ pub fn emit_variant_from_child( env.source_indices.clone(), ); let tuple_style = (positional_payload.clone() - || (serde_policy.enum_attr.clone().as_str() - == "#[serde(untagged)]".to_string().as_str())); + || (serde_policy.enum_attr.clone() == "#[serde(untagged)]".to_string())); if tuple_style { match child.children.clone().first().cloned() { Some(f) => { @@ -7945,12 +8581,14 @@ pub fn emit_variant_from_child( render_variant_payload_type( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { render_rust_type( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) }; @@ -7963,6 +8601,7 @@ pub fn emit_variant_from_child( render_rust_type_with_applied_binding( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -8013,6 +8652,7 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8066,6 +8706,7 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8122,71 +8763,78 @@ pub fn emit_fn_def( shared_types: Rc>, emit_info: Rc, ) -> String { - if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { - if rust_emit_faithful_text_carrier(scope.type_env.source_indices.clone()) { - return seam_fn; - } else { - return "".to_string(); - } - } { let si = scope.type_env.clone().source_indices.clone(); - let type_params = function_type_params(params.clone()); - let value_params = function_value_params(params.clone()); - if function_type_params_have_collision(type_params.clone()) { - return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); - } - let type_params_str = emit_type_params(type_params.clone(), si.clone()); - let generic_param_names = Rc::new({ - let mut __result = Vec::new(); - for p in type_params.clone().iter().cloned() { - __result.push(generic_param_name_at(p.clone(), si.clone())); + 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() + } else { + "".to_string() + } } - __result - }); - let params_str = emit_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - emit_info.read_only_params.clone(), - scope.type_env.clone(), - ); - let ret_str = emit_inferred( - inferred, - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - scope.type_env.clone(), - ); - let body_scope = build_params_scope(scope.clone(), value_params.clone()); - let depth = 0; - let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); - let needs_stacker = - (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) - && (use_tco.clone() == false)); - if use_tco.clone() { - { - let tco_params_str = emit_tco_params( + None => { + let type_params = function_type_params(params.clone()); + let value_params = function_value_params(params.clone()); + if function_type_params_have_collision(type_params.clone()) { + return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); + } + let type_params_str = emit_type_params(type_params.clone(), si.clone()); + let generic_param_names = Rc::new({ + let mut __result = Vec::new(); + for p in type_params.clone().iter().cloned() { + __result.push(generic_param_name_at(p.clone(), si.clone())); + } + __result + }); + let params_str = emit_params( value_params.clone(), generic_param_names.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), si.clone(), + emit_info.read_only_params.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); - let body_str = emit_typed_tco_body( - body.clone(), - name.clone(), - value_params.clone(), - registry.clone(), - body_scope, - (depth.clone() + 1), + let ret_str = emit_inferred( + inferred, + generic_param_names.clone(), shared_types.clone(), - emit_info.clone(), + emit_info.corpus_repr.clone(), + si.clone(), + emit_info.variant_to_enum.clone(), + scope.type_env.clone(), ); - let kw = rust_items().func_keyword.clone(); - v1_rt::concat( - v1_rt::concat( + let body_scope = build_params_scope(scope.clone(), value_params.clone()); + let depth = 0; + let use_tco = + is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); + let needs_stacker = + (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) + && (use_tco.clone() == false)); + if use_tco.clone() { + { + let tco_params_str = emit_tco_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + emit_info.corpus_repr.clone(), + 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.clone(), + registry.clone(), + body_scope, + (depth.clone() + 1), + shared_types.clone(), + emit_info.clone(), + ); + let kw = rust_items().func_keyword.clone(); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -8197,49 +8845,53 @@ pub fn emit_fn_def( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - kw, + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + kw, + ), + " ".to_string(), + ), + emit_ident( + name.clone(), + RenderTarget::Rust, + ), ), - " ".to_string(), - ), - emit_ident( - name.clone(), - RenderTarget::Rust, + type_params_str, ), + "(".to_string(), ), - type_params_str, + tco_params_str, ), - "(".to_string(), + ")".to_string(), ), - tco_params_str, + ret_str, ), - ")".to_string(), + " {\n".to_string(), ), - ret_str, + make_indent((depth.clone() + 1)), ), - " {\n".to_string(), + body_str, ), - make_indent((depth.clone() + 1)), - ), - body_str, - ), - "\n}".to_string(), - ) + "\n}".to_string(), + ) + } + } else { + emit_fn_def_non_tco( + name.clone(), + type_params_str, + params_str, + ret_str, + body.clone(), + registry.clone(), + body_scope, + depth.clone(), + shared_types.clone(), + emit_info.clone(), + needs_stacker, + ) + } } - } else { - emit_fn_def_non_tco( - name.clone(), - type_params_str, - params_str, - ret_str, - body.clone(), - registry.clone(), - body_scope, - depth.clone(), - shared_types.clone(), - emit_info.clone(), - needs_stacker, - ) } } } @@ -8399,13 +9051,16 @@ pub fn emit_func_def( uses.clone(), service_names, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), + emit_info.variant_to_enum.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(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -8619,7 +9274,9 @@ pub fn emit_tco_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8630,7 +9287,9 @@ pub fn emit_tco_params( p.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8644,7 +9303,9 @@ pub fn emit_tco_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8654,15 +9315,19 @@ pub fn emit_tco_param( authored.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8687,8 +9352,10 @@ pub fn emit_func_params( uses: Rc>>, service_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8699,8 +9366,10 @@ pub fn emit_func_params( p.clone(), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8720,6 +9389,7 @@ pub fn emit_func_params( render_rust_type( resource_use_resource(u.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ), )); @@ -8744,12 +9414,13 @@ pub fn emit_func_params( pub fn emit_func_inferred( inferred: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { v1_rt::concat( v1_rt::concat( " -> Result<".to_string(), - render_rust_type(inferred, shared_types, source_indices), + render_rust_type(inferred, shared_types, corpus_repr, source_indices), ), ", Box>".to_string(), ) @@ -8759,8 +9430,10 @@ pub fn emit_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8771,8 +9444,10 @@ pub fn emit_params( p.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8786,16 +9461,20 @@ pub fn render_rust_param_sig_type( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param.clone()); + let type_node = resolved_type(param); render_rust_fn_sig_type( type_node, generic_param_names, shared_types, + corpus_repr, source_indices, + variant_to_enum, env, ) } @@ -8805,7 +9484,9 @@ pub fn emit_rust_param_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -8817,7 +9498,9 @@ pub fn emit_rust_param_type( param_node_type_expr(p.clone()), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8829,7 +9512,9 @@ pub fn emit_rust_param_type( rt.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8850,8 +9535,10 @@ pub fn emit_rust_param_type( n.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), - env, + variant_to_enum.clone(), + env.clone(), ) } } @@ -8860,8 +9547,10 @@ pub fn emit_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8871,15 +9560,19 @@ pub fn emit_param( authored.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8898,7 +9591,9 @@ pub fn emit_inferred( inferred: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -8907,7 +9602,9 @@ pub fn emit_inferred( inferred, generic_param_names, shared_types, + corpus_repr, source_indices, + variant_to_enum, env, ), ) @@ -8990,12 +9687,11 @@ pub fn collect_field_binding_string_guards( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) - } else { - v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) - }; + let field_path = if (fb_name.clone() == "0".to_string()) { + v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) + } else { + v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) + }; let bind_name = pattern_string_binding_name(field_path.clone()); match positional_payload_string_guard( fb_pat.clone(), @@ -9014,7 +9710,7 @@ pub fn collect_field_binding_string_guards( nested_path.clone(), source_indices.clone(), ); - if (nested.clone().as_str() == "".to_string().as_str()) { + if (nested.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![nested.clone()]) @@ -9045,7 +9741,7 @@ pub fn collect_pattern_string_guards( field_bindings: fbs, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) + if (((n.clone() == "Present".to_string()) && (parent.clone().as_deref() == Some("Optional".to_string()).as_deref())) && ((fbs.clone().len() as i64) == 1)) { @@ -9088,8 +9784,7 @@ pub fn collect_pattern_string_guards( match fbs.clone().first().cloned() { Some(fb) => { if (field_binding_name_at(fb.clone(), source_indices.clone()) - .as_str() - == "0".to_string().as_str()) + == "0".to_string()) { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( @@ -9230,7 +9925,7 @@ pub fn pattern_parent_enum( type_summaries: Rc>>, ) -> Option { { - let scrut_is_known_enum = ((scrut_type.clone().as_str() != "".to_string().as_str()) + 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() @@ -9273,13 +9968,12 @@ pub fn unique_variant_parent( } pub fn is_optional_variant_name(name: String) -> bool { - ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str())) + ((name.clone() == "Present".to_string()) || (name.clone() == "Absent".to_string())) } pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent.clone().as_str() == "Optional".to_string().as_str()), + Some(parent) => (parent.clone() == "Optional".to_string()), None => false, } } @@ -9337,7 +10031,7 @@ pub fn emit_variant_pattern( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -9350,7 +10044,7 @@ pub fn emit_variant_pattern( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (parent.clone() == "Witness".to_string()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9362,7 +10056,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -9393,8 +10087,8 @@ pub fn emit_variant_pattern( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (field_binding_name_at(fb.clone(), source_indices.clone()) + == "0".to_string()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -9597,25 +10291,24 @@ pub fn emit_variant_pattern( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone() == "0".to_string()) { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -9626,15 +10319,13 @@ pub fn emit_variant_pattern( } } else { { - let is_shorthand = match (*fb_pat.clone()) - .clone() - { - MatchPattern::Bind { name: n, .. } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } - _ => false, - }; + let is_shorthand = + match (*fb_pat.clone()).clone() { + MatchPattern::Bind { + name: n, .. + } => (n.clone() == fb_name.clone()), + _ => false, + }; if is_shorthand.clone() { emit_ident( fb_name.clone(), @@ -9642,26 +10333,25 @@ pub fn emit_variant_pattern( ) } else { { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { + let field_path = if (fb_name.clone() + == "0".to_string()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let pat_str = emit_pattern( fb_pat.clone(), field_path.clone(), @@ -9732,7 +10422,7 @@ pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc { let mut __found = false; for name in rc_analysis.ref_bound_fields.clone().iter().cloned() { - if (name.clone().as_str() == field_name.clone().as_str()) { + if (name.clone() == field_name.clone()) { __found = true; break; } @@ -9768,8 +10458,7 @@ pub fn analyze_rc_pattern( ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone().as_str() - == "Present".to_string().as_str()) + 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![]), @@ -9799,18 +10488,17 @@ pub fn analyze_rc_pattern( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let inner_scrut = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - positional_payload_scrut_type( - resolved_parent.clone(), - n.clone(), - fb.clone(), - emit_info.clone(), - source_indices.clone(), - ) - } else { - "".to_string() - }; + let inner_scrut = if (fb_name.clone() == "0".to_string()) { + positional_payload_scrut_type( + resolved_parent.clone(), + n.clone(), + fb.clone(), + emit_info.clone(), + source_indices.clone(), + ) + } else { + "".to_string() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -9970,7 +10658,7 @@ pub fn emit_variant_pattern_rc_aware( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -9983,7 +10671,7 @@ pub fn emit_variant_pattern_rc_aware( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (parent.clone() == "Witness".to_string()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9995,7 +10683,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10034,8 +10722,8 @@ pub fn emit_variant_pattern_rc_aware( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (field_binding_name_at(fb.clone(), source_indices.clone()) + == "0".to_string()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10270,25 +10958,24 @@ pub fn emit_variant_pattern_rc_aware( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone() == "0".to_string()) { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -10316,10 +11003,7 @@ pub fn emit_variant_pattern_rc_aware( { MatchPattern::Bind { name: n, .. - } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } + } => (n.clone() == fb_name.clone()), _ => false, }; if is_shorthand.clone() { @@ -10329,26 +11013,26 @@ pub fn emit_variant_pattern_rc_aware( ) } else { { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { + let field_path = if (fb_name + .clone() + == "0".to_string()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let inner_analysis = analyze_rc_pattern( fb_pat.clone(), @@ -10456,7 +11140,7 @@ pub fn rc_pattern_preludes( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - if (fb_name.clone().as_str() == "0".to_string().as_str()) { + if (fb_name.clone() == "0".to_string()) { { let payload_scrut = positional_payload_scrut_type( resolved_parent.clone(), @@ -10479,9 +11163,7 @@ pub fn rc_pattern_preludes( source_indices.clone(), emit_info.clone(), ); - if (inner_preludes.clone().as_str() - == "".to_string().as_str()) - { + if (inner_preludes.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![inner_preludes.clone()]) @@ -10566,7 +11248,7 @@ pub fn explicit_record_struct_name( false }; let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone().as_str() == "__EmitTypeCacheMiss".to_string().as_str()) { + if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { type_name.clone() } else { if n_is_error { @@ -10615,141 +11297,30 @@ pub fn variant_parent_from_binding_kind( } } -pub fn apply_clone(expr: String) -> String { - apply_type_template1( - sharing_for_target(RenderTarget::Rust).clone_value.clone(), - expr, - ) -} - -pub fn apply_deref_clone(expr: String) -> String { - apply_type_template1( - sharing_for_target(RenderTarget::Rust).deref_clone.clone(), - expr, - ) -} - -pub fn apply_field_clone(expr: String, field: String) -> String { - apply_type_template2( - sharing_for_target(RenderTarget::Rust).field_clone.clone(), - expr, - field, - ) -} - -pub fn clone_iterator_suffix() -> String { - sharing_for_target(RenderTarget::Rust).clone_suffix.clone() -} - -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - match v1_rt::map_get(&variant_to_enum, name.clone()) { - Some(parent) => { - if parent.as_str() != "" { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier - } else { - rust_qualify_type_leaf_name(name, variant_to_enum) - } -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - } - } - __result - }) - .join("\n") -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut names: Vec = Vec::new(); - for item in items.iter().cloned() { - if is_type_def_item(item.clone()) - && item - .children - .clone() - .iter() - .all(|c| c.children.clone().len() as i64 == 0) - { - for child in item.children.clone().iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !names.iter().any(|n| n == &vname) - { - names.push(vname); - } - } - } - } - } - names - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env.clone()) - .iter() - .cloned() - { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - __result - }) - .join("\n") +pub fn apply_clone(expr: String) -> String { + apply_type_template1( + sharing_for_target(RenderTarget::Rust).clone_value.clone(), + expr, + ) +} + +pub fn apply_deref_clone(expr: String) -> String { + apply_type_template1( + sharing_for_target(RenderTarget::Rust).deref_clone.clone(), + expr, + ) +} + +pub fn apply_field_clone(expr: String, field: String) -> String { + apply_type_template2( + sharing_for_target(RenderTarget::Rust).field_clone.clone(), + expr, + field, + ) +} + +pub fn clone_iterator_suffix() -> String { + sharing_for_target(RenderTarget::Rust).clone_suffix.clone() } pub fn effective_variant_parent( @@ -10762,7 +11333,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().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { Some(p.clone()) } else { None @@ -10775,8 +11346,7 @@ pub fn effective_variant_parent( None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); - if (((rt.ident_span.clone() != None) - && (rt_name.clone().as_str() != name.clone().as_str())) + if (((rt.ident_span.clone() != None) && (rt_name.clone() != name.clone())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), name.clone(), @@ -10803,14 +11373,10 @@ pub fn emit_var_ref( emit_info: Rc, source_indices: Rc>>, ) -> String { - if ((name.clone().as_str() == "none".to_string().as_str()) - || (name.clone().as_str() == "None".to_string().as_str())) - { + if ((name.clone() == "none".to_string()) || (name.clone() == "None".to_string())) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((name.clone().as_str() == "true".to_string().as_str()) - || (name.clone().as_str() == "false".to_string().as_str())) - { + if ((name.clone() == "true".to_string()) || (name.clone() == "false".to_string())) { emit_keyword(name.clone(), RenderTarget::Rust) } else { { @@ -10826,9 +11392,9 @@ pub fn emit_var_ref( let ref_str = match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(name.clone()) - && (enum_name.clone().as_str() == "Optional".to_string().as_str())) + && (enum_name.clone() == "Optional".to_string())) { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -10918,14 +11484,10 @@ pub fn emit_typed_expr_base( .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) - { + if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((n.clone().as_str() == "true".to_string().as_str()) - || (n.clone().as_str() == "false".to_string().as_str())) - { + if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { emit_keyword(n.clone(), RenderTarget::Rust) } else { { @@ -10939,10 +11501,9 @@ pub fn emit_typed_expr_base( match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(n.clone()) - && (enum_name.clone().as_str() - == "Optional".to_string().as_str())) + && (enum_name.clone() == "Optional".to_string())) { - if (n.clone().as_str() == "Present".to_string().as_str()) { + if (n.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -10991,6 +11552,35 @@ pub fn emit_typed_expr_base( } } +pub fn field_access_field_is_boxed( + base: Rc, + field: String, + scope: Rc, + shared_types: Rc>, + emit_info: Rc, +) -> bool { + { + let base_struct = expand_type_for_field_access( + resolved_type(base), + scope.type_env.clone(), + scope.module_name.clone(), + ); + match find_child_named( + base_struct, + field, + scope.type_env.clone().source_indices.clone(), + ) { + Some(field_child) => needs_box_wrapping( + resolved_type(field_child.clone()), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ), + None => false, + } + } +} + pub fn emit_typed_field_access( base: Rc, field: String, @@ -11053,9 +11643,7 @@ pub fn emit_typed_field_access( if (authored_name_at( scope.type_env.clone().source_indices.clone(), pair.1.clone(), - ) - .as_str() - == field.clone().as_str()) + ) == field.clone()) { __result.push(pair); } @@ -11125,19 +11713,39 @@ pub fn emit_typed_field_access( } _ => false, }; - if base_is_owned { + let field_is_boxed = field_access_field_is_boxed( + base.clone(), + field.clone(), + scope.clone(), + shared_types.clone(), + emit_info.clone(), + ); + if field_is_boxed { v1_rt::concat( - v1_rt::concat(base_str, ".".to_string()), - emit_ident(field.clone(), RenderTarget::Rust), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(*".to_string(), base_str), + ".".to_string(), + ), + emit_ident(field.clone(), RenderTarget::Rust), + ), + ").clone()".to_string(), ) } else { - apply_type_template1( - sharing.clone_value.clone(), + if base_is_owned { v1_rt::concat( v1_rt::concat(base_str, ".".to_string()), emit_ident(field.clone(), RenderTarget::Rust), - ), - ) + ) + } else { + apply_type_template1( + sharing.clone_value.clone(), + v1_rt::concat( + v1_rt::concat(base_str, ".".to_string()), + emit_ident(field.clone(), RenderTarget::Rust), + ), + ) + } } } }, @@ -11192,7 +11800,7 @@ pub fn type_needs_rc_seen( } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); if (normed.inferred.clone() != None) { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11205,12 +11813,12 @@ pub fn type_needs_rc_seen( continue; } } else { - if ((canonical.clone().as_str() != "".to_string().as_str()) + if ((canonical.clone() != "".to_string()) && emit_map_has(seen.clone(), canonical.clone())) { break false; } else { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11248,6 +11856,7 @@ pub fn rust_runtime_bridge_name(function_name: String) -> String { pub fn rust_empty_map_value_type_str( map_type: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match map_type.children.clone().get(1 as usize).cloned() { @@ -11255,9 +11864,10 @@ pub fn rust_empty_map_value_type_str( let rendered = render_rust_type( child_type_node(value_child.clone()), shared_types, + corpus_repr, source_indices, ); - if (rendered.clone().as_str() == "".to_string().as_str()) { + if (rendered.clone() == "".to_string()) { "".to_string() } else { rendered.clone() @@ -11270,6 +11880,7 @@ pub fn rust_empty_map_value_type_str( pub fn rust_empty_map_kv_type_str( map_type: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -11277,6 +11888,7 @@ pub fn rust_empty_map_kv_type_str( Some(key_child) => render_rust_type( child_type_node(key_child.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ), None => "".to_string(), @@ -11284,11 +11896,10 @@ pub fn rust_empty_map_kv_type_str( let val_str = rust_empty_map_value_type_str( map_type.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ); - if ((key_str.clone().as_str() != "".to_string().as_str()) - && (val_str.clone().as_str() != "".to_string().as_str())) - { + 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(), @@ -11316,12 +11927,12 @@ pub fn rust_btree_set_element_ord_eligible( ) -> bool { { let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); - (((((((elem_name.clone().as_str() == "String".to_string().as_str()) - || (elem_name.clone().as_str() == "Int".to_string().as_str())) - || (elem_name.clone().as_str() == "Bool".to_string().as_str())) - || (elem_name.clone().as_str() == "Unit".to_string().as_str())) - || (elem_name.clone().as_str() == "Secret".to_string().as_str())) - || (elem_name.clone().as_str() == "Bytes".to_string().as_str())) + (((((((elem_name.clone() == "String".to_string()) + || (elem_name.clone() == "Int".to_string())) + || (elem_name.clone() == "Bool".to_string())) + || (elem_name.clone() == "Unit".to_string())) + || (elem_name.clone() == "Secret".to_string())) + || (elem_name.clone() == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -11394,7 +12005,7 @@ pub fn emit_rust_empty_set_expr( shared_types, source_indices.clone(), ); - if (elem_str.clone().as_str() != "".to_string().as_str()) { + if (elem_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_set::<".to_string(), @@ -11697,36 +12308,70 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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.module_name.clone(), + ); + let variant_name = match tn.clone() { + Some(n) => n.clone(), + None => "".to_string(), + }; + let peeled_type_name = if (((parent_enum.clone() == None) + && (expanded_rt.connective.clone() == Connective::Conj)) + && (expanded_rt.ident_span.clone() != None)) + { + { + let concrete = authored_name_at(si.clone(), expanded_rt.clone()); + if ((concrete.clone() != "".to_string()) + && (concrete.clone() != variant_name.clone())) + { + Some(concrete.clone()) + } else { + tn.clone() + } + } + } else { + tn.clone() + }; let raw = emit_typed_record_lit( - tn.clone(), + peeled_type_name, fs, parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), registry, scope.clone(), depth, shared_types.clone(), emit_info.clone(), ); - let si = scope.type_env.clone().source_indices.clone(); - let variant_name = match tn.clone() { - Some(n) => n.clone(), - None => "".to_string(), - }; let rc_name = match parent_enum.clone() { Some(en) => en.clone(), None => match contextual_variant_parent( variant_name.clone(), parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), emit_info.clone(), si.clone(), ) { - Some(p) => p, - None => variant_name.clone(), + Some(p) => p.clone(), + None => { + 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.clone() + } else { + variant_name.clone() + } + } }, }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + 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()) @@ -12161,7 +12806,7 @@ pub fn contextual_variant_parent( None => { let rt_name = authored_name_at(source_indices, resolved_type.clone()); if (((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != variant_name.clone().as_str())) + && (rt_name.clone() != variant_name.clone())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), variant_name.clone(), @@ -12204,7 +12849,7 @@ pub fn emit_discriminant_call_lowering( scope.clone(), depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ); let ty_name = @@ -12266,7 +12911,7 @@ pub fn emit_discriminant_call_lowering( ), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), ), ",".to_string(), @@ -12303,7 +12948,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } } @@ -12312,7 +12957,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), } } @@ -12329,15 +12974,16 @@ pub fn emit_typed_call_expr( emit_info: Rc, ) -> String { { - let call_str = if (func.clone().as_str() == "empty_map".to_string().as_str()) { + let call_str = if (func.clone() == "empty_map".to_string()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( ret_type.clone(), shared_types, + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -12354,7 +13000,7 @@ pub fn emit_typed_call_expr( .to_string(), } } else { - if (func.clone().as_str() == "empty_set".to_string().as_str()) { + if (func.clone() == "empty_set".to_string()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( @@ -12398,7 +13044,7 @@ pub fn emit_typed_call( emit_info: Rc, ) -> String { { - if (func.clone().as_str() == "get".to_string().as_str()) { + if (func.clone() == "get".to_string()) { { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); @@ -12442,7 +13088,7 @@ pub fn emit_typed_call( return get_result; } } - if (func.clone().as_str() == "with".to_string().as_str()) { + if (func.clone() == "with".to_string()) { { let with_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); if ((with_args.clone().len() as i64) == 0) { @@ -12540,7 +13186,7 @@ pub fn emit_typed_call( } } } - if (func.clone().as_str() == "to_string".to_string().as_str()) { + if (func.clone() == "to_string".to_string()) { { let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12561,45 +13207,24 @@ pub fn emit_typed_call( ), ").to_string()".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), None => "compile_error!(\"to_string call missing value argument\")".to_string(), }; return ts_result; } } - if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { + if (func.clone() == "utf8_decode_bytes".to_string()) { { let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let decode_result = match decode_args.first().cloned() { - Some(value_arg) => v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "String::from_utf8(".to_string(), - emit_typed_expr( - arg_value(value_arg.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ), - ), - ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" - .to_string(), - ), - "".to_string(), - ), - None => { - "compile_error!(\"utf8_decode_bytes call missing value argument\")" - .to_string() - } - }; + Some(value_arg) => v1_rt::concat(v1_rt::concat("String::from_utf8(".to_string(), emit_typed_expr(arg_value(value_arg.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)), ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?".to_string()), + None => "compile_error!(\"utf8_decode_bytes call missing value argument\")".to_string(), +}; return decode_result; } } - if (func.clone().as_str() == "discriminant".to_string().as_str()) { + if (func.clone() == "discriminant".to_string()) { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { @@ -12618,10 +13243,10 @@ pub fn emit_typed_call( return disc_result; } } - let collection_scope = if ((((func.clone().as_str() == "map".to_string().as_str()) - || (func.clone().as_str() == "filter".to_string().as_str())) - || (func.clone().as_str() == "flat_map".to_string().as_str())) - || (func.clone().as_str() == "fold".to_string().as_str())) + let collection_scope = if ((((func.clone() == "map".to_string()) + || (func.clone() == "filter".to_string())) + || (func.clone() == "flat_map".to_string())) + || (func.clone() == "fold".to_string())) { { let call_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12796,8 +13421,7 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt.clone() - && (func.clone().as_str() == "concat".to_string().as_str())) + 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.clone(), "".to_string(), shared_types.clone()) @@ -12853,12 +13477,11 @@ pub fn fill_default_args( let is_provided = { let mut __found = false; for n in provided_names.clone().iter().cloned() { - if (n.clone().as_str() + if (n.clone() == param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str()) + )) { __found = true; break; @@ -12971,7 +13594,7 @@ pub fn emit_nested_rt_concat( break acc.clone(); } Some(arg) => { - let next_acc = if (acc.clone().as_str() == "".to_string().as_str()) { + let next_acc = if (acc.clone() == "".to_string()) { arg.clone() } else { v1_rt::concat( @@ -13171,6 +13794,7 @@ pub fn emit_typed_slice( pub fn collection_element_type( receiver_type: Option>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match receiver_type.as_deref().cloned() { @@ -13196,6 +13820,7 @@ pub fn collection_element_type( render_rust_type( elem_node.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -13252,6 +13877,7 @@ pub fn lambda_param_type_strs( param_nodes: Rc>>, fallback_types: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> Rc> { Rc::new({ @@ -13291,6 +13917,7 @@ pub fn lambda_param_type_strs( Some(render_rust_type( param_type.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), )) } @@ -13354,6 +13981,7 @@ pub fn emit_typed_collection_lambda( pn.clone(), Rc::new(vec![elem_type_str]), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13364,7 +13992,7 @@ pub fn emit_typed_collection_lambda( lambda_scope, depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ); v1_rt::concat( @@ -13378,7 +14006,7 @@ pub fn emit_typed_collection_lambda( scope.clone(), depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ), } @@ -13410,10 +14038,9 @@ pub fn emit_typed_fold_lambda( .skip(1 as usize) .collect::>(), ); - let safe_acc_type = if (((acc_type_str.clone().as_str() - == "Rc>".to_string().as_str()) - || (acc_type_str.clone().as_str() == "Vec<()>".to_string().as_str())) - || (acc_type_str.clone().as_str() == "Option<()>".to_string().as_str())) + let safe_acc_type = if (((acc_type_str.clone() == "Rc>".to_string()) + || (acc_type_str.clone() == "Vec<()>".to_string())) + || (acc_type_str.clone() == "Option<()>".to_string())) { "_".to_string() } else { @@ -13445,6 +14072,7 @@ pub fn emit_typed_fold_lambda( Rc::new(vec![]), fallback_types, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13462,7 +14090,7 @@ pub fn emit_typed_fold_lambda( Some(n) => n.clone(), None => "".to_string(), }; - let needs_unwrap = ((acc_name.clone().as_str() != "".to_string().as_str()) + let needs_unwrap = ((acc_name.clone() != "".to_string()) && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); if needs_unwrap { { @@ -13534,6 +14162,7 @@ pub fn emit_rust_fold_method_call( let elem_type_str = collection_element_type( receiver.inferred.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { @@ -13685,6 +14314,7 @@ pub fn emit_rust_fold_method_call( ), 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(), }), None => emit_info.clone(), } @@ -13717,6 +14347,7 @@ pub fn emit_rust_fold_method_call( owned_bindings: emit_info.owned_bindings.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(), }), None => emit_info.clone(), } @@ -13730,6 +14361,7 @@ pub fn emit_rust_fold_method_call( let acc_type_str = render_rust_type( acc_type_node.clone(), shared_types.clone(), + 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) { @@ -13790,18 +14422,19 @@ pub fn emit_rust_fold_method_call( arg_value(init_arg.clone()), scope.type_env.clone().source_indices.clone(), ); - if ((((init_func.clone().as_str() == "empty_map".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + if ((((init_func.clone() == "empty_map".to_string()) + && (acc_type_str.clone() != "_".to_string())) + && (acc_type_str.clone() != "".to_string())) && !acc_has_unit_child.clone()) { { let kv_type_str = rust_empty_map_kv_type_str( acc_type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -13814,13 +14447,12 @@ pub fn emit_rust_fold_method_call( } } } else { - if (init_func.clone().as_str() == "empty_map".to_string().as_str()) { + if (init_func.clone() == "empty_map".to_string()) { "Rc::new(HashMap::new()) /* BRIDGE: fold empty_map accumulator type unresolved */".to_string() } else { - if ((((init_func.clone().as_str() - == "empty_set".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + 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()) { emit_rust_empty_set_expr( @@ -13829,8 +14461,7 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func.clone().as_str() == "empty_set".to_string().as_str()) - { + if (init_func.clone() == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -13927,6 +14558,7 @@ pub fn emit_rust_sort_by_method_call( render_rust_type( elem.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ) } else { @@ -13951,7 +14583,7 @@ pub fn emit_rust_sort_by_method_call( let iter_str = apply_type_template1(sharing.iter_owned.clone(), recv_str); let a_clone = apply_type_template1(sharing.clone_value.clone(), "a".to_string()); let b_clone = apply_type_template1(sharing.clone_value.clone(), "b".to_string()); - if (elem_type_str.clone().as_str() == "_".to_string().as_str()) { + 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()) @@ -14438,9 +15070,7 @@ pub fn emit_rust_first_method_call( if (expr_method_name_at( receiver.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "skip".to_string().as_str()) + ) == "skip".to_string()) { { let skip_recv = method_receiver(receiver.clone()); @@ -14678,9 +15308,7 @@ pub fn emit_typed_method_call( if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), - ) - .as_str() - == "serde_json::Value".to_string().as_str()) + ) == "serde_json::Value".to_string()) { __result.push(p); } @@ -14777,7 +15405,7 @@ pub fn emit_typed_method_call( scope.type_env.clone().source_indices.clone(), method_def.clone(), ); - if (method_name.clone().as_str() == "fold".to_string().as_str()) { + if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( method_call_node, fold_accumulator_type.clone(), @@ -14791,7 +15419,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "sort_by".to_string().as_str()) { + if (method_name.clone() == "sort_by".to_string()) { emit_rust_sort_by_method_call( receiver.clone(), args.clone(), @@ -14802,7 +15430,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "map".to_string().as_str()) { + if (method_name.clone() == "map".to_string()) { emit_rust_map_method_call( receiver.clone(), args.clone(), @@ -14816,9 +15444,7 @@ pub fn emit_typed_method_call( match Rc::new({ let mut __result = Vec::new(); for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone().as_str() - == method_name.clone().as_str()) - { + if (s.method_name.clone() == method_name.clone()) { __result.push(s); } } @@ -14838,8 +15464,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ), None => { - if (method_name.clone().as_str() == "get".to_string().as_str()) - { + if (method_name.clone() == "get".to_string()) { emit_rust_get_method_call( receiver.clone(), args.clone(), @@ -14850,9 +15475,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "with".to_string().as_str()) - { + if (method_name.clone() == "with".to_string()) { emit_rust_with_method_call( receiver.clone(), args.clone(), @@ -14863,8 +15486,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "string_contains".to_string().as_str()) + if (method_name.clone() + == "string_contains".to_string()) { emit_rust_generic_method_call( "string_contains".to_string(), @@ -14878,9 +15501,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "concat".to_string().as_str()) - { + if (method_name.clone() == "concat".to_string()) { { let recv_str = emit_typed_expr( receiver.clone(), @@ -14917,8 +15538,7 @@ pub fn emit_typed_method_call( ) } } else { - if (method_name.clone().as_str() - == "first".to_string().as_str()) + if (method_name.clone() == "first".to_string()) { emit_rust_first_method_call( receiver.clone(), @@ -15309,8 +15929,8 @@ pub fn emit_typed_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) + let guard_str = if ((field_guards.clone() != "".to_string()) + && (arm_guard_str.clone() != "".to_string())) { v1_rt::concat( v1_rt::concat( @@ -15320,10 +15940,10 @@ pub fn emit_typed_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { + if (field_guards.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { + if (arm_guard_str.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -15585,14 +16205,13 @@ pub fn wrap_rust_record_field_value( field_name: String, ) -> String { { - let is_bounded_lattice_field = - (struct_name.clone().as_str() == "BoundedLattice".to_string().as_str()); + let is_bounded_lattice_field = (struct_name.clone() == "BoundedLattice".to_string()); if rust_record_field_needs_fn_rc(scope.clone(), struct_name.clone(), field_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "meet".to_string().as_str()) - || (field_name.clone().as_str() == "join".to_string().as_str()))) + && ((field_name.clone() == "meet".to_string()) + || (field_name.clone() == "join".to_string()))) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -15606,8 +16225,8 @@ pub fn wrap_rust_record_field_value( v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "top".to_string().as_str()) - || (field_name.clone().as_str() == "bottom".to_string().as_str()))) + && ((field_name.clone() == "top".to_string()) + || (field_name.clone() == "bottom".to_string()))) { v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { @@ -15638,16 +16257,13 @@ pub fn is_already_optional( binding_kind: binding_kind, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) - || (n.clone().as_str() == "Absent".to_string().as_str())) + if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true } else { - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) - { + if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { match texpr.inferred.clone().as_deref().cloned() { @@ -15671,8 +16287,8 @@ pub fn is_already_optional( } => match tn { Some(name) => { ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) - && ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str()))) + && ((name.clone() == "Present".to_string()) + || (name.clone() == "Absent".to_string()))) } None => false, }, @@ -15894,7 +16510,7 @@ pub fn emit_field_value_with_context( Some(en) => en.clone(), None => variant_name.clone(), }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + 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()) @@ -16146,10 +16762,15 @@ pub fn emit_typed_record_lit( false }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); - if ((((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != tn.clone().as_str())) + if (((((resolved_type.ident_span.clone() != None) + && (rt_name.clone() != tn.clone())) && !rt_is_type_var) - && (rt_name.clone().as_str() != "Error".to_string().as_str())) + && (rt_name.clone() != "Error".to_string())) + && variant_belongs_to_enum( + emit_info.type_summaries.clone(), + tn.clone(), + rt_name.clone(), + )) { Some(rt_name.clone()) } else { @@ -16161,7 +16782,7 @@ pub fn emit_typed_record_lit( && (is_optional_parent(parent_enum.clone()) || is_optional_parent(effective_parent.clone()))); let rust_tn = if optional_variant.clone() { - if (tn.clone().as_str() == "Present".to_string().as_str()) { + if (tn.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -16180,8 +16801,7 @@ pub fn emit_typed_record_lit( None => rust_tn, } }; - if ((optional_variant.clone() - && (tn.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -16221,8 +16841,8 @@ pub fn emit_typed_record_lit( let is_positional_ctor = (((fields.clone().len() as i64) == 1) && match fields.clone().first().cloned() { Some(f) => { - (field_init_node_name_at(f.clone(), si.clone()).as_str() - == "0".to_string().as_str()) + (field_init_node_name_at(f.clone(), si.clone()) + == "0".to_string()) } None => false, }); @@ -16384,18 +17004,13 @@ pub fn emit_typed_record_lit( &ftm, fname.clone(), ) { - Some(ft) => { - match rust_zero_value( - ft.clone(), - scope - .type_env - .source_indices - .clone(), - ) { - Some(_) => true, - None => false, - } - } + Some(ft) => match rust_zero_value( + ft.clone(), + emit_info.corpus_repr.clone(), + ) { + Some(_) => true, + None => false, + }, None => false, }; (has_zv.clone() @@ -16419,10 +17034,7 @@ pub fn emit_typed_record_lit( Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { match v1_rt::map_get(&ftm, fname.clone()) { - Some(ft) => match rust_zero_value( - ft.clone(), - scope.type_env.source_indices.clone(), - ) { + Some(ft) => match rust_zero_value(ft.clone(), emit_info.corpus_repr.clone()) { Some(zv) => Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": ".to_string()), zv.clone()), ",".to_string())]), None => Rc::new(vec![]), }, @@ -16438,7 +17050,48 @@ pub fn emit_typed_record_lit( } None => Rc::new(vec![]), }; - let all_field_strs = v1_rt::concat(field_strs, default_strs); + let phantom_strs = match lookup_type_by_name( + scope.type_env.clone(), + tn.clone(), + ) { + Some(struct_decl) => { + let is_struct = (struct_decl.connective.clone() + == Connective::Conj); + let pnames = Rc::new({ + let mut __result = Vec::new(); + for p in struct_decl.params.clone().iter().cloned() + { + __result.push(generic_param_name_at( + p.clone(), + si.clone(), + )); + } + __result + }); + let unused = struct_unused_param_names( + pnames, + struct_decl.children.clone(), + si.clone(), + ); + let has_unused = ((unused.len() as i64) > 0); + if (is_struct && has_unused) { + Rc::new(vec![v1_rt::concat( + v1_rt::concat( + " ".to_string(), + rust_phantom_field_name(), + ), + ": std::marker::PhantomData,".to_string(), + )]) + } else { + Rc::new(vec![]) + } + } + None => Rc::new(vec![]), + }; + let all_field_strs = v1_rt::concat( + v1_rt::concat(field_strs, default_strs), + phantom_strs, + ); let fields_str = all_field_strs.join(&"\n".to_string()); let raw = v1_rt::concat( v1_rt::concat( @@ -16458,18 +17111,15 @@ pub fn emit_typed_record_lit( } } -pub fn rust_zero_value( - type_name: String, - source_indices: Rc>>, -) -> Option { - if (type_name.clone().as_str() == "Int".to_string().as_str()) { +pub fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> Option { + if (type_name.clone() == "Int".to_string()) { Some("0".to_string()) } else { - if (type_name.clone().as_str() == "Bool".to_string().as_str()) { + if (type_name.clone() == "Bool".to_string()) { Some("false".to_string()) } else { - if (type_name.clone().as_str() == "String".to_string().as_str()) { - if rust_emit_faithful_text_carrier(source_indices) { + if (type_name.clone() == "String".to_string()) { + if corpus_repr_is_faithful(corpus_repr) { Some( "crate::v2_std_algebra::freemonoid_empty::()" .to_string(), @@ -16537,8 +17187,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - scope.type_env.clone().source_indices.clone(), + l_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16551,8 +17201,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), - scope.type_env.clone().source_indices.clone(), + r_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16584,12 +17234,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + l_str, + emit_info.corpus_repr.clone(), ), ), " ".to_string(), @@ -16599,8 +17245,8 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), - scope.type_env.clone().source_indices.clone(), + r_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16733,7 +17379,7 @@ pub fn emit_typed_string_interp( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (a.clone() != "".to_string()) { __result.push(a); } } @@ -16742,7 +17388,7 @@ pub fn emit_typed_string_interp( if ((args.clone().len() as i64) == 0) { emit_rust_host_to_dag_string_via_seam( v1_rt::concat(v1_rt::concat("\"".to_string(), fmt_str), "\"".to_string()), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } else { { @@ -16758,7 +17404,7 @@ pub fn emit_typed_string_interp( ), ")".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } } @@ -16919,9 +17565,7 @@ pub fn emit_tco_init_stmt( if (param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + ) == n.clone()) { __found = true; break; @@ -17275,9 +17919,7 @@ pub fn emit_rust_tco_let( if (param_node_name_at( p.clone(), frame.scope.clone().type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + ) == n.clone()) { __found = true; break; @@ -17564,8 +18206,8 @@ pub fn emit_typed_tco_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) + let guard_str = if ((field_guards.clone() != "".to_string()) + && (arm_guard_str.clone() != "".to_string())) { v1_rt::concat( v1_rt::concat( @@ -17575,10 +18217,10 @@ pub fn emit_typed_tco_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { + if (field_guards.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { + if (arm_guard_str.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -17648,10 +18290,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()).as_str() - == var_name.clone().as_str()) - } + } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -17838,6 +18477,7 @@ pub fn emit_service_def( item: Rc, registry: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -17857,6 +18497,7 @@ pub fn emit_service_def( op_children.clone(), registry, shared_types, + corpus_repr, env.clone(), item.clone(), ); @@ -17936,6 +18577,7 @@ pub fn emit_service_impl( op_children: Rc>>, registry: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -17958,6 +18600,7 @@ pub fn emit_service_impl( registry.clone(), (depth.clone() + 1), shared_types.clone(), + corpus_repr.clone(), env.clone(), service_item.clone(), )); @@ -18023,7 +18666,7 @@ pub fn emit_service_new_method( }, None => "".to_string(), }; - let base_url_default = if (from_config.clone().as_str() != "".to_string().as_str()) { + let base_url_default = if (from_config.clone() != "".to_string()) { from_config.clone() } else { if fs.has_rest.clone() { @@ -18048,7 +18691,7 @@ pub fn emit_service_new_method( } else { "".to_string() }; - if (from_fallback.clone().as_str() != "".to_string().as_str()) { + if (from_fallback.clone() != "".to_string()) { from_fallback.clone() } else { "http://localhost".to_string() @@ -18116,7 +18759,7 @@ pub fn emit_auth_source_ctor( ) -> String { match (*source_expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { - Some(variant) => if (variant.clone().as_str() == "EnvVar".to_string().as_str()) { + 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()) }, @@ -18160,6 +18803,7 @@ pub fn emit_operation_method( registry: Rc>>, depth: i64, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18180,15 +18824,17 @@ pub fn emit_operation_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -18196,6 +18842,7 @@ pub fn emit_operation_method( let ret_type = render_rust_type( resolved_type(op_node.clone()), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), ); let eff_transport = effective_operation_transport(op_node.clone(), transport); @@ -18210,6 +18857,7 @@ pub fn emit_operation_method( op_node.clone(), env.source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), ); let mock_props = Rc::new({ @@ -18233,6 +18881,7 @@ pub fn emit_operation_method( op_node.clone(), env.clone(), shared_types.clone(), + corpus_repr.clone(), ); let body = v1_rt::concat( v1_rt::concat( @@ -18314,6 +18963,7 @@ pub fn emit_dry_run_branch_from_props( op_node: Rc, env: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, ) -> String { { let log_line = v1_rt::concat( @@ -18351,7 +19001,7 @@ let prelude = match wire_opt.clone() { 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, source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) +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()) } }, None => v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()), @@ -18370,7 +19020,7 @@ let raw = match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed dry-run: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for mock field: ".to_string()), ch_name.clone()), "\");".to_string()), }; @@ -18393,13 +19043,6 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } } } else { - // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single - // authority): compile_error! -> panic! in the dry-run missing-fixture branch. - // Applied by hand because regen-fixpoint is temporarily broken (§7 hole). - // DISSOLUTION lane: bright-stag's adhoc-1bdd0259-2e3 (re-repair the hole + add a - // regen-equals-committed CI drift-gate). When it lands, a clean regen reproduces - // this line from the .dag — delete this hand-patch; the dissolution check is - // regen-output == this mirror modulo HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -18424,6 +19067,7 @@ pub fn emit_transport_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { if is_rest_transport(transport.clone(), source_indices.clone()) { @@ -18436,6 +19080,7 @@ pub fn emit_transport_call( op_node, source_indices.clone(), shared_types, + corpus_repr, env, ) } else { @@ -18447,6 +19092,7 @@ pub fn emit_transport_call( depth, inferred, op_node, + corpus_repr, source_indices.clone(), ) } else { @@ -18468,6 +19114,7 @@ pub fn emit_rest_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -18482,7 +19129,11 @@ pub fn emit_rest_call( http_method, source_indices.clone(), ); - let query_line = emit_rest_query_line(transport.clone(), source_indices.clone()); + let query_line = emit_rest_query_line( + transport.clone(), + corpus_repr.clone(), + source_indices.clone(), + ); let body_line = emit_rest_body_line(transport.clone(), source_indices.clone()); let headers = transport_headers(transport.clone(), source_indices.clone()); let header_lines = Rc::new({ @@ -18515,6 +19166,7 @@ pub fn emit_rest_call( transport.clone(), source_indices.clone(), shared_types, + corpus_repr.clone(), env, ); let all_lines = Rc::new({ @@ -18529,7 +19181,7 @@ pub fn emit_rest_call( .iter() .cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -18774,6 +19426,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_rest_query_line( transport: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match transport_query(transport, source_indices.clone()) { @@ -18796,7 +19449,7 @@ pub fn emit_rest_query_line( RenderTarget::Rust, source_indices.clone(), ), - source_indices.clone(), + corpus_repr.clone(), ), ), ")".to_string(), @@ -18859,7 +19512,7 @@ pub fn has_response_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 9) { false } else { - (v1_rt::substring(&name, 0, 9).as_str() == "response_".to_string().as_str()) + (v1_rt::substring(&name, 0, 9) == "response_".to_string()) } } @@ -18870,8 +19523,8 @@ pub fn child_from_key( match Rc::new({ let mut __result = Vec::new(); for p in ch.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "from_key".to_string()) { __result.push(p); } @@ -18925,8 +19578,8 @@ pub fn has_response_200_property( { let mut __found = false; for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "response_200".to_string()) { __found = true; break; @@ -18944,8 +19597,8 @@ pub fn operation_response_200_resolved_type( match Rc::new({ let mut __result = Vec::new(); for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "response_200".to_string()) { __result.push(p); } @@ -18964,7 +19617,7 @@ pub fn operation_response_200_resolved_type( source_indices.clone(), normalize_access_type_node(v.clone()), ); - if (type_name.clone().as_str() == "".to_string().as_str()) { + if (type_name.clone() == "".to_string()) { None } else { lookup_type_by_name(env, type_name.clone()) @@ -18982,7 +19635,7 @@ pub fn is_json_wire_declaration_type( ) -> bool { { let n = authored_name_at(source_indices, normalize_access_type_node(t)); - if (n.clone().as_str() == "Json".to_string().as_str()) { + if (n.clone() == "Json".to_string()) { true } else { { @@ -18993,7 +19646,7 @@ pub fn is_json_wire_declaration_type( .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone().as_str() == "Json".to_string().as_str()), + Some(last) => (last.clone() == "Json".to_string()), None => false, } } @@ -19044,7 +19697,7 @@ pub fn wire_child_for_segment( Some(k) => k.clone(), None => authored.clone(), }; - (wire_key.clone().as_str() == seg.clone().as_str()) + (wire_key.clone() == seg.clone()) } { __result.push(ch); } @@ -19160,7 +19813,7 @@ pub fn emit_wire_struct_path_chain( .iter() .cloned() { - if (s.clone().as_str() != "".to_string().as_str()) { + if (s.clone() != "".to_string()) { __result.push(s); } } @@ -19226,6 +19879,7 @@ pub fn emit_json_value_extract( var_name: String, from_path: String, dag_type_name: String, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19247,9 +19901,8 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); - let is_dag_string = dag_type_name.as_str() == "String"; - let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); - let accessor = if is_dag_string { + let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name.clone()); + let accessor = if (dag_type_name.clone() == "String".to_string()) { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19257,7 +19910,7 @@ pub fn emit_json_value_extract( ".and_then(|v| v.as_str()).map(|s| ".to_string(), emit_rust_host_to_dag_string_via_seam( "s.to_string()".to_string(), - source_indices.clone(), + corpus_repr, ), ), ").ok_or(\"missing field: ".to_string(), @@ -19267,7 +19920,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "i64".to_string().as_str()) { + if (rust_type.clone() == "i64".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_i64()).ok_or(\"missing field: ".to_string(), @@ -19276,7 +19929,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "f64".to_string().as_str()) { + if (rust_type.clone() == "f64".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_f64()).ok_or(\"missing field: ".to_string(), @@ -19285,7 +19938,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "bool".to_string().as_str()) { + 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(), @@ -19322,6 +19975,7 @@ pub fn emit_from_key_extraction( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19359,6 +20013,7 @@ pub fn emit_from_key_extraction( render_rust_type( wire_ty, shared_types, + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19388,7 +20043,7 @@ match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed response: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for output field: ".to_string()), ch_name.clone()), "\");".to_string()), } @@ -19443,8 +20098,7 @@ pub fn emit_plain_response_body( { let is_text = match transport_response_format(transport, source_indices.clone()) { Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()).as_str() - == "Text".to_string().as_str()) + (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) } None => false, }; @@ -19461,6 +20115,7 @@ pub fn emit_response_code_handling( transport: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19480,6 +20135,7 @@ pub fn emit_response_code_handling( op_node.clone(), source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), ) } else { @@ -19497,6 +20153,7 @@ pub fn emit_response_code_handling( transport.clone(), source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), )); } @@ -19528,21 +20185,22 @@ pub fn emit_response_arm( transport: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 9, v1_rt::string_length(&name)); let is_success = if (v1_rt::string_length(&code_str) >= 1) { - (v1_rt::substring(&code_str, 0, 1).as_str() == "2".to_string().as_str()) + (v1_rt::substring(&code_str, 0, 1) == "2".to_string()) } else { false }; - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (code_str.clone() == "nonzero".to_string()) { "_".to_string() } else { if ((v1_rt::string_length(&code_str) == 3) - && (v1_rt::substring(&code_str, 1, 3).as_str() == "xx".to_string().as_str())) + && (v1_rt::substring(&code_str, 1, 3) == "xx".to_string())) { { let prefix = v1_rt::substring(&code_str, 0, 1); @@ -19570,6 +20228,7 @@ pub fn emit_response_arm( op_node, source_indices.clone(), shared_types, + corpus_repr, env, ), ), @@ -19597,13 +20256,14 @@ pub fn has_exit_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5).as_str() == "exit_".to_string().as_str()) + (v1_rt::substring(&name, 0, 5) == "exit_".to_string()) } } pub fn emit_exit_code_handling( op_node: Rc, inferred: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19623,8 +20283,8 @@ pub fn emit_exit_code_handling( let has_nonzero = { let mut __found = false; for p in exit_props.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "exit_nonzero".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "exit_nonzero".to_string()) { __found = true; break; @@ -19638,6 +20298,7 @@ pub fn emit_exit_code_handling( __result.push(emit_exit_arm( p.clone(), inferred.clone(), + corpus_repr.clone(), source_indices.clone(), )); } @@ -19646,16 +20307,7 @@ pub fn emit_exit_code_handling( let default_arm = if has_nonzero { "".to_string() } else { - v1_rt::concat( - v1_rt::concat( - "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), - emit_rust_host_to_dag_string_via_seam( - "stderr".to_string(), - source_indices.clone(), - ), - ), - ") },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr.clone())), ") },".to_string()) }; v1_rt::concat( v1_rt::concat( @@ -19678,17 +20330,18 @@ pub fn emit_exit_code_handling( pub fn emit_exit_arm( prop: Rc, inferred: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 5, v1_rt::string_length(&name)); - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (code_str.clone() == "nonzero".to_string()) { "_".to_string() } else { code_str.clone() }; - let is_success = (code_str.clone().as_str() == "0".to_string().as_str()); + let is_success = (code_str.clone() == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -19701,22 +20354,7 @@ pub fn emit_exit_arm( " },".to_string(), ) } else { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(" ".to_string(), pattern), - " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), - ), - emit_rust_host_to_dag_string_via_seam( - "stderr".to_string(), - source_indices.clone(), - ), - ), - ") },".to_string(), - ), - "".to_string(), - ) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string()), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr)), ") },".to_string()) } } } @@ -19728,6 +20366,7 @@ pub fn emit_shell_call( depth: i64, inferred: Rc, op_node: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19772,6 +20411,7 @@ pub fn emit_shell_call( emit_shell_argv_element( first_arg.clone(), optional_params.clone(), + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19813,6 +20453,7 @@ pub fn emit_shell_call( emit_shell_argv_element( arg.clone(), optional_params.clone(), + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19873,8 +20514,12 @@ pub fn emit_shell_call( let wait_line = "let output = output.wait_with_output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = - emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); + let return_line = emit_exit_code_handling( + op_node.clone(), + inferred, + corpus_repr.clone(), + source_indices.clone(), + ); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![ @@ -19894,8 +20539,12 @@ pub fn emit_shell_call( let output_line = " .output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = - emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); + let return_line = emit_exit_code_handling( + op_node.clone(), + inferred, + corpus_repr.clone(), + source_indices.clone(), + ); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![wd_line, output_line, check_line, return_line]), @@ -19909,6 +20558,7 @@ pub fn emit_shell_call( pub fn emit_shell_argv_element( arg: Rc, optional_params: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match (*arg.expr_data.clone()).clone() { @@ -20007,10 +20657,10 @@ pub fn emit_shell_argv_element( if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), - source_indices.clone(), + corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), source_indices.clone()) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) } } _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), @@ -20077,7 +20727,7 @@ pub fn emit_shell_return( } __result }); - let lines = if (stderr_line.clone().as_str() != "".to_string().as_str()) { + let lines = if (stderr_line.clone() != "".to_string()) { v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() @@ -20104,13 +20754,13 @@ pub fn emit_shell_return( pub fn emit_shell_channel_expr(channel: String, is_optional: bool) -> String { { - let base = if (channel.clone().as_str() == "exit_success".to_string().as_str()) { + let base = if (channel.clone() == "exit_success".to_string()) { "output.status.success()".to_string() } else { - if (channel.clone().as_str() == "stderr".to_string().as_str()) { + if (channel.clone() == "stderr".to_string()) { "stderr.clone()".to_string() } else { - if (channel.clone().as_str() == "stdout_lines".to_string().as_str()) { + if (channel.clone() == "stdout_lines".to_string()) { "Rc::new(stdout.lines().filter(|l| !l.is_empty()).map(|l| l.trim().to_string()).collect())".to_string() } else { "stdout.clone()".to_string() @@ -20182,6 +20832,7 @@ pub fn emit_local_call(op_name: String) -> String { pub fn emit_resource_def( item: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20204,6 +20855,7 @@ pub fn emit_resource_def( __result.push(emit_capability_method( c.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), )); } @@ -20234,6 +20886,7 @@ pub fn emit_resource_def( pub fn emit_capability_method( cap_node: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20252,15 +20905,17 @@ pub fn emit_capability_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -20268,6 +20923,7 @@ pub fn emit_capability_method( let ret = render_rust_type( resolved_type(cap_node.clone()), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), ); let items = rust_items(); @@ -20356,10 +21012,11 @@ pub fn emit_data_def( let raw_ty_str = render_rust_type_with_applied_binding( render_type_node, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - let ty_str = if ((raw_ty_str.clone().as_str() == "BoundedLattice".to_string().as_str()) - || (raw_ty_str.clone().as_str() == "Rc".to_string().as_str())) + let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) + || (raw_ty_str.clone() == "Rc".to_string())) { match field_value_by_name( value.clone(), @@ -20371,12 +21028,10 @@ pub fn emit_data_def( scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); - if (top_type_name.clone().as_str() == "".to_string().as_str()) { + if (top_type_name.clone() == "".to_string()) { raw_ty_str.clone() } else { - if (raw_ty_str.clone().as_str() - == "Rc".to_string().as_str()) - { + if (raw_ty_str.clone() == "Rc".to_string()) { v1_rt::concat( v1_rt::concat( "Rc { let lattice_value = field_value_by_name( @@ -20678,38 +21334,31 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( + v1_rt::concat( + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + v1_rt::concat( + "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), ), + "\"".to_string(), ), - "\"".to_string(), + emit_info.corpus_repr.clone(), ), - scope - .type_env - .clone() - .source_indices - .clone(), - ), - ), - v1_rt::concat( - v1_rt::concat( - ", ".to_string(), - val_str.clone(), ), - ");".to_string(), + ", ".to_string(), ), + val_str.clone(), ), - "".to_string(), + ");".to_string(), ) }); } @@ -20785,13 +21434,18 @@ pub fn emit_data_def_body( pub fn emit_test_file( module_name: String, projections: Rc>>, + corpus_repr: RustCorpusRepr, ) -> Rc { { let depth = 0; let test_fns = Rc::new({ let mut __result = Vec::new(); for p in projections.iter().cloned() { - __result.push(emit_operation_test(p.clone(), (depth.clone() + 1))); + __result.push(emit_operation_test( + p.clone(), + (depth.clone() + 1), + corpus_repr.clone(), + )); } __result }); @@ -20842,13 +21496,16 @@ pub fn emit_test_file( } } -pub fn rust_test_signature_comment(projection: Rc) -> String { +pub fn rust_test_signature_comment( + projection: Rc, + corpus_repr: RustCorpusRepr, +) -> String { { let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), + bindings: v1_rt::rc_empty_map::>(), recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::>>>(), source_indices: projection.source_indices.clone(), intern_table: empty_intern_table(), }); @@ -20864,7 +21521,9 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { param_node_type_expr(p.clone()), Rc::new(vec![]), v1_rt::rc_empty_set::(), + corpus_repr.clone(), projection.source_indices.clone(), + v1_rt::rc_empty_map::(), stub_env.clone(), ), )); @@ -20901,7 +21560,11 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { } } -pub fn emit_operation_test(projection: Rc, depth: i64) -> String { +pub fn emit_operation_test( + projection: Rc, + depth: i64, + corpus_repr: RustCorpusRepr, +) -> String { { let test_name = rust_test_name(projection.clone()); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -20918,12 +21581,12 @@ pub fn emit_operation_test(projection: Rc, depth: i64) -> String __result }); let args_str = param_args.join(&", ".to_string()); - let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { + let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { 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())), "\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.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()) } } @@ -21020,8 +21683,8 @@ pub fn emit_cargo_dep(name: String, version: String, features: Rc>) pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { { let header = v1_rt::concat( - v1_rt::concat("[package]\nname = \"".to_string(), crate_name), - "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n".to_string(), + render_cargo_package_header_prefix(crate_name), + "\nedition = \"2021\"\n".to_string(), ); let workspace = "\n[workspace]\n".to_string(); let base_deps = Rc::new(vec![ @@ -21121,8 +21784,8 @@ pub fn resolve_param_default( ItemKind::DataItem => match Rc::new({ let mut __result = Vec::new(); for i in module_items.iter().cloned() { - if (authored_name_at(source_indices.clone(), i.clone()).as_str() - == authored_name_at(source_indices.clone(), dv.clone()).as_str()) + if (authored_name_at(source_indices.clone(), i.clone()) + == authored_name_at(source_indices.clone(), dv.clone())) { __result.push(i); } @@ -21332,9 +21995,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc String { { - let about_attr = if (about.clone().as_str() != "".to_string().as_str()) { + let about_attr = if (about.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat(", about = \"".to_string(), about.clone()), "\"".to_string(), @@ -21907,11 +22567,18 @@ pub fn emit_cli_param_type_node( if ((n.children.clone().len() as i64) == 0) { { let nname = authored_name_at(source_indices, n.clone()); - let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone().as_str() != nname.clone().as_str()) { - mapped.clone() - } else { + if (nname.clone() == "String".to_string()) { "String".to_string() + } else { + { + let mapped = + coerce_primitive_type(RenderTarget::Rust, nname.clone()); + if (mapped.clone() != nname.clone()) { + mapped.clone() + } else { + "String".to_string() + } + } } } } else { @@ -21982,7 +22649,7 @@ pub fn emit_main_fn( ";".to_string(), ) }; - let body_lines = if (dry_run_line.clone().as_str() == "".to_string().as_str()) { + let body_lines = if (dry_run_line.clone() == "".to_string()) { v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) } else { v1_rt::concat( @@ -22017,15 +22684,7 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat( - v1_rt::concat( - "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" - .to_string(), - " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" - .to_string(), - ), - " },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index a0c3dd4540f..e716da211b3 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -35,13 +35,14 @@ pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_access::AccessCheckResultNode; pub use crate::v1_compiler_infer_access::{check_index_access_node, check_slice_access_node}; pub use crate::v1_compiler_infer_cycle::detect_type_cycles_kahn; +use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ add_emit_item_summary, build_enum_field_summaries, build_struct_field_summaries, derive_variant_to_enum, empty_emit_graph_info, lookup_emit_type_summary, }; pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, EmitInfoBuildState, TypeRepr, TypeSummary, + EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ inductive_fields_for, inductive_fields_list_to_map, is_recursive_type, @@ -163,8 +164,7 @@ use std::collections::HashMap; use std::rc::Rc; pub fn is_witness_type_name(name: String) -> bool { - ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) + ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -547,7 +547,7 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { + if (field_type_name.clone() == parent_name.clone()) { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -575,17 +575,15 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = ((value_type.clone().as_str() - == parent_name.clone().as_str()) + let is_recursive_element = ((value_type.clone() == parent_name.clone()) || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = - if (value_type.clone().as_str() == parent_name.clone().as_str()) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = if (value_type.clone() == parent_name.clone()) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -753,8 +751,8 @@ pub fn namespace_root_from_properties( match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "namespace_root".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "namespace_root".to_string()) { __result.push(p); } @@ -884,8 +882,7 @@ pub fn rejects_string_for_optional_coproduct_field( let expected_is_optional_coproduct = ((expected.return_cardinality.clone() == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); - let got_is_string = - (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); + let got_is_string = (authored_name_at(source_indices, got) == "String".to_string()); (expected_is_optional_coproduct && got_is_string) } } @@ -906,9 +903,7 @@ pub fn record_lit_expected_fields( if (authored_name_at( scope.type_env.clone().source_indices.clone(), v.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { __result.push(v); } @@ -942,9 +937,7 @@ pub fn record_lit_expanded_from_expected( if (((authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -955,9 +948,7 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), expanded.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { Some(expanded.clone()) } else { @@ -969,9 +960,7 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), rt.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { Some(rt.clone()) } else { @@ -1015,8 +1004,7 @@ pub fn record_lit_instantiated_fields( Some(tn) => match expected { Some(exp) => { if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - .as_str() - != tn.clone().as_str()) + != tn.clone()) { None } else { @@ -1186,10 +1174,9 @@ pub fn type_node_is_callable(n: Rc) -> bool { pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); + && (v1_rt::substring(&module_name, 0, 3) == "v2.".to_string())); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (v1_rt::substring(&module_name, 0, 13).as_str() - == "v1.compiler.".to_string().as_str())); + && (v1_rt::substring(&module_name, 0, 13) == "v1.compiler.".to_string())); (is_v4 || is_compiler_substrate) } } @@ -1204,13 +1191,11 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (formal_name.clone().as_str() != "".to_string().as_str())) - && (actual_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() != actual_name.clone().as_str())) + && (formal_name.clone() != "".to_string())) + && (actual_name.clone() != "".to_string())) + && (formal_name.clone() != actual_name.clone())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) - .as_str() - == structural_carrier_template_name(actual.clone(), source_indices.clone()) - .as_str())) + == 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())) } @@ -1225,8 +1210,8 @@ pub fn container_element_nominal_brand_mismatch( ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), formal.clone()).as_str() - == authored_name_at(source_indices.clone(), actual.clone()).as_str())) + && (authored_name_at(source_indices.clone(), formal.clone()) + == authored_name_at(source_indices.clone(), actual.clone()))) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1357,8 +1342,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( scope: Rc, span: Rc, ) -> Rc { - if ((func_name.clone().as_str() == "lookup".to_string().as_str()) - || (func_name.clone().as_str() == "map_get".to_string().as_str())) + if ((func_name.clone() == "lookup".to_string()) || (func_name.clone() == "map_get".to_string())) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1374,7 +1358,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (func_name.clone().as_str() == "lookup".to_string().as_str()) { + if (func_name.clone() == "lookup".to_string()) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1390,7 +1374,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { + if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1427,7 +1411,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (func_name.clone().as_str() == "map_values".to_string().as_str()) { + if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1465,14 +1449,13 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_union".to_string().as_str())) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + if (((func_name.clone() == "set_insert".to_string()) + || (func_name.clone() == "set_union".to_string())) + || (func_name.clone() == "set_contains".to_string())) { { - let operand_elem = if ((func_name.clone().as_str() - == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + let operand_elem = if ((func_name.clone() == "set_insert".to_string()) + || (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()) @@ -1516,18 +1499,17 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - let union_other_bad = - if (func_name.clone().as_str() == "set_union".to_string().as_str()) { - match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg.clone(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + 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(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1590,9 +1572,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let result_bt = if (func_name.clone() == "set_contains".to_string()) { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1635,9 +1615,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let build_diags = if (func_name.clone() == "set_contains".to_string()) { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1689,7 +1667,7 @@ pub fn method_pipe_map_keys_values_fallback( scope: Rc, span: Rc, ) -> Rc { - if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { + 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.clone()); @@ -1704,7 +1682,7 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (method_name.clone().as_str() == "map_values".to_string().as_str()) { + 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.clone()); @@ -1752,7 +1730,7 @@ pub fn validate_cast( match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (source_name.clone().as_str() == target_name.clone().as_str()) { + if (source_name.clone() == target_name.clone()) { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1880,23 +1858,18 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (scrutinee_name.clone().as_str() - != "Optional".to_string().as_str())); - let optional_coproduct_subject = ((scrutinee_name.clone().as_str() - == "Optional".to_string().as_str()) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))); + && (scrutinee_name.clone() != "Optional".to_string())); + let optional_coproduct_subject = ((scrutinee_name.clone() + == "Optional".to_string()) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((variant_name.clone().as_str() - == "Holds".to_string().as_str()) - || (variant_name.clone().as_str() - == "Violates".to_string().as_str()))); + && ((variant_name.clone() == "Holds".to_string()) + || (variant_name.clone() == "Violates".to_string()))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))) { Some("Optional".to_string()) } else { @@ -2141,7 +2114,7 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { + if (scrut_type_name.clone() == "".to_string()) { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2150,8 +2123,8 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) - && (f.field_name.clone().as_str() == field_name.clone().as_str())) + if ((f.variant_name.clone() == variant_name.clone()) + && (f.field_name.clone() == field_name.clone())) { __result.push(f); } @@ -2279,7 +2252,7 @@ pub fn method_name_is(opt: Option, expected: String) -> bool { if (opt.clone() == None) { false } else { - (opt.clone().unwrap().as_str() == expected.as_str()) + (opt.clone().unwrap() == expected) } } @@ -2293,7 +2266,7 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (n.clone().unwrap().as_str() == name.as_str()) + (n.clone().unwrap() == name) } } } @@ -2367,9 +2340,7 @@ pub fn derive_element_provenance( if (authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - ) - .as_str() - == "".to_string().as_str()) + ) == "".to_string()) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2777,11 +2748,18 @@ pub fn infer_expr( ); match field_type_lookup { Some(field_type) => { - let field_summary = field_summary_for_type( + let field_summary = match field_summary_for_type( base_rt.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(), + field_name.clone(), + ), + }; let fa_texpr = make_named_expr_node( field_name.clone(), Rc::new(ExprData::ExprFieldAccess { @@ -3425,7 +3403,7 @@ pub fn infer_expr( }) } } else { - if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { + if (func_name.clone() == "empty_map".to_string()) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3489,8 +3467,7 @@ match bare_m { } } } else { - if (func_name.clone().as_str() == "empty_set".to_string().as_str()) - { + if (func_name.clone() == "empty_set".to_string()) { { let bare_s = bare_set_node(); match expected.clone() { @@ -3563,13 +3540,12 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = if (func_name.clone().as_str() - == "lookup".to_string().as_str()) - { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = + if (func_name.clone() == "lookup".to_string()) { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4300,9 +4276,7 @@ match bare_s { (authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - ) - .as_str() - == let_name.clone().as_str()) + ) == let_name.clone()) } _ => false, }, @@ -5306,7 +5280,7 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (pn.clone().as_str() == fname.clone().as_str()) { + if (pn.clone() == fname.clone()) { __found = true; break; } @@ -5380,7 +5354,7 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) + let stop = ((is_optional || (next_name.clone() == "".to_string())) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5508,8 +5482,8 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((type_name.clone().unwrap().as_str() - == "Present".to_string().as_str()) + let is_present_ctor = ((type_name.clone().unwrap() == "Present".to_string()) && (local_variant_parent.clone().as_deref() == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { @@ -5848,9 +5818,7 @@ pub fn infer_record_lit( if (field_init_node_name_at( fir.typed_field.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "value".to_string().as_str()) + ) == "value".to_string()) { __result.push(fir); } @@ -5942,7 +5910,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()); - if (mname.as_str() == "count".to_string().as_str()) { + if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6039,7 +6007,7 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone().as_str() == param_name.clone().as_str()) { + 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 { @@ -6095,9 +6063,7 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "take".to_string().as_str()) - || (mname.clone().as_str() == "skip".to_string().as_str())) - { + if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { let receiver = method_receiver(arg_expr.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6108,7 +6074,7 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (rname.as_str() == param_name.clone().as_str()) { + if (rname == param_name.clone()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { @@ -6122,8 +6088,7 @@ pub fn classify_collection_shrink( unreachable!() }; if ((k.clone() > 0) - && (mname.clone().as_str() - == "skip".to_string().as_str())) + && (mname.clone() == "skip".to_string())) { match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { @@ -6166,9 +6131,7 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p.clone().as_str() - == param_name.clone().as_str()) - { + 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 { @@ -6199,8 +6162,7 @@ Rc::new(SubValueRelation::StrictSubValue { ExprData::ExprBinOp { op, .. } => { match op.clone() { BinOp::Add => { - if (mname.clone().as_str() - == "skip".to_string().as_str()) + if (mname.clone() == "skip".to_string()) { { let left = @@ -6321,16 +6283,15 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (lookup_type.clone().as_str() != "".to_string().as_str()) { + if (lookup_type.clone() != "".to_string()) { { 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() { - if ((f.field_name.clone().as_str() == field_label.clone().as_str()) - && ((f.variant_name.clone().as_str() == vname.clone().as_str()) - || (f.variant_name.clone().as_str() - == "".to_string().as_str()))) + if ((f.field_name.clone() == field_label.clone()) + && ((f.variant_name.clone() == vname.clone()) + || (f.variant_name.clone() == "".to_string()))) { __result.push(f); } @@ -6522,7 +6483,7 @@ pub fn resolve_collection_field( } } }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6534,8 +6495,7 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (f.field_name.clone().as_str() == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -6606,12 +6566,12 @@ pub fn resolve_collection_field( } => { let inner_mname = expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); - let is_collection_preserving = (((((inner_mname.clone().as_str() - == "enumerate".to_string().as_str()) - || (inner_mname.clone().as_str() == "skip".to_string().as_str())) - || (inner_mname.clone().as_str() == "take".to_string().as_str())) - || (inner_mname.clone().as_str() == "filter".to_string().as_str())) - || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); + 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 { { let __tco_0 = method_receiver(expr); @@ -6665,7 +6625,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (type_name.clone().as_str() != "".to_string().as_str()) { + if (type_name.clone() != "".to_string()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6745,9 +6705,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option "".to_string(), }, }; - if (inner_type.clone().as_str() - != "".to_string().as_str()) - { + if (inner_type.clone() != "".to_string()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6892,7 +6848,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if ((elem.clone().as_str() != "".to_string().as_str()) + if ((elem.clone() != "".to_string()) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -7037,7 +6993,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if (left_name.clone().as_str() != "".to_string().as_str()) { + if (left_name.clone() != "".to_string()) { match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -7079,12 +7035,12 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - if (mname.clone().as_str() == "skip".to_string().as_str()) { + if (mname.clone() == "skip".to_string()) { { let skip_args = method_arg_nodes(val.clone()); let skip_amount = match skip_args.first().cloned() { @@ -7297,7 +7253,7 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7343,7 +7299,7 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -7487,9 +7443,7 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7533,9 +7487,7 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7553,9 +7505,7 @@ pub fn classify_argument( ((expr_var_name_at( inner_left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7697,8 +7647,7 @@ pub fn read_arg_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) - { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -7838,7 +7787,7 @@ pub fn build_call_evidence( } pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { - if (found.clone().as_str() != "".to_string().as_str()) { + if (found.clone() != "".to_string()) { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -7885,7 +7834,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let arg_val = arg_value(child.clone()); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLambda => { - if (source_type.clone().as_str() != "".to_string().as_str()) { + if (source_type.clone() != "".to_string()) { { let lparams = lambda_param_names_at( arg_val.clone(), @@ -7902,9 +7851,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }; let lambda_ctx = Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (p2.clone().as_str() - != "".to_string().as_str()) - { + param_names: if (p2.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.param_names.clone(), @@ -7915,9 +7862,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { source_type.clone(), ) } else { - if (p1.clone().as_str() - != "".to_string().as_str()) - { + if (p1.clone() != "".to_string()) { v1_rt::rc_map_insert( ctx.param_names.clone(), p1.clone(), @@ -7929,9 +7874,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: if (p1.clone().as_str() - != "".to_string().as_str()) - { + sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( ctx.type_env.clone(), @@ -7959,9 +7902,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }), None => Rc::new(SubValueRelation::PreservedValue), }; - if (p2.clone().as_str() - != "".to_string().as_str()) - { + if (p2.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), @@ -8100,7 +8041,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Some(t) => t.clone(), None => "".to_string(), }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), @@ -8109,9 +8050,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -8135,8 +8074,8 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "first".to_string().as_str()) - || (mname.clone().as_str() == "last".to_string().as_str())) + if ((mname.clone() == "first".to_string()) + || (mname.clone() == "last".to_string())) { { let receiver = method_receiver(scrut.clone()); @@ -8148,8 +8087,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } _ => None, }; - let scrut_has_inductive = (((scrut_type.clone().as_str() - != "".to_string().as_str()) + let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) @@ -8190,7 +8128,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { + Some(ind_field) => if (vname.clone() == "Present".to_string()) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8214,9 +8152,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == inner_vname.clone()) && (f.field_name.clone() == inner_field_name.clone())) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { + Some(inner_ind_field) => if (inner_bind_name.clone() != "".to_string()) { Rc::new(DescentContext { 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()), @@ -8251,9 +8189,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == vname.clone()) && (f.field_name.clone() == field_name.clone())) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { + Some(ind_field) => if (bind_name.clone() != "".to_string()) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8276,7 +8214,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { + MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone() != "".to_string()) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8369,7 +8307,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { + param_names: if (sub_type.clone() != "".to_string()) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8486,9 +8424,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (sub_type.clone().as_str() - != "".to_string().as_str()) - { + param_names: if (sub_type.clone() != "".to_string()) { v1_rt::rc_map_insert( acc.ctx.clone().param_names.clone(), bname.clone(), @@ -8592,7 +8528,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (inner_mname.as_str() == "enumerate".to_string().as_str()) { + if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8638,7 +8574,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota None => "".to_string(), }, }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( @@ -8648,9 +8584,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .iter() .cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -8954,9 +8888,7 @@ pub fn infer_output_provenance( |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) - { + if ((pname.clone() != "".to_string()) && (ptype.clone() != "".to_string())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { acc.clone() @@ -9022,7 +8954,7 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (pn.clone().as_str() == vname.clone().as_str()) { + if (pn.clone() == vname.clone()) { __found = true; break; } @@ -9071,7 +9003,7 @@ pub fn classify_body_provenance( } _ => "".to_string(), }; - if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { + if (type_for_lookup.clone() != "".to_string()) { { let fields = inductive_fields_for( type_env.clone(), @@ -9080,9 +9012,7 @@ pub fn classify_body_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == field.clone().as_str()) - { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -9238,7 +9168,7 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { +if ((bind_name.clone() != "".to_string()) && (field_label.clone() != "".to_string())) { { let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) @@ -9426,7 +9356,7 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (first_pname.clone().as_str() != "".to_string().as_str()) { + if (first_pname.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), first_pname.clone(), @@ -9838,8 +9768,8 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((bind_name.clone().as_str() == "".to_string().as_str()) - || (field_label.clone().as_str() == "".to_string().as_str())) + if ((bind_name.clone() == "".to_string()) + || (field_label.clone() == "".to_string())) { c.clone() } else { @@ -9997,8 +9927,8 @@ pub fn compute_variant_provenance( param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) + if ((pname.clone() != "".to_string()) + && (ptype.clone() != "".to_string())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -10049,7 +9979,7 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { + if (enum_name.clone() == parent_enum.clone()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10073,7 +10003,7 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (fname.clone().as_str() != "".to_string().as_str()) { + if (fname.clone() != "".to_string()) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -10110,9 +10040,7 @@ pub fn collect_variant_constructors( if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) - .as_str() - == parent_enum.clone().as_str()) + ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10396,8 +10324,8 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((ptype.clone().as_str() != "".to_string().as_str()) - && (pname.clone().as_str() != "".to_string().as_str())) + if ((ptype.clone() != "".to_string()) + && (pname.clone() != "".to_string())) { { let fields = inductive_fields_for( @@ -10689,9 +10617,7 @@ pub fn infer_auth_source_properties( if (field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "svc_auth_source".to_string().as_str()) + ) == "svc_auth_source".to_string()) { { let val = field_init_node_value(p.clone()); @@ -11115,11 +11041,10 @@ pub fn infer_items( } pub fn is_type_variable_name(name: String) -> bool { - (((((name.clone().as_str() == "T".to_string().as_str()) - || (name.clone().as_str() == "K".to_string().as_str())) - || (name.clone().as_str() == "V".to_string().as_str())) - || (name.clone().as_str() == "MappedElement".to_string().as_str())) - || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) + (((((name.clone() == "T".to_string()) || (name.clone() == "K".to_string())) + || (name.clone() == "V".to_string())) + || (name.clone() == "MappedElement".to_string())) + || (name.clone() == "FoldAccumulator".to_string())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -11134,7 +11059,7 @@ pub fn type_node_label( ) -> String { { let authored = authored_name_at(source_indices, n.clone()); - if (authored.clone().as_str() != "".to_string().as_str()) { + if (authored.clone() != "".to_string()) { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11159,9 +11084,9 @@ pub fn param_is_generic_decl( }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) - && (pname.clone().as_str() != "".to_string().as_str())) - && ((pname.clone().as_str() == tname.as_str()) - || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) + && (pname.clone() != "".to_string())) + && ((pname.clone() == tname) + || (type_expr_is_var && (pname.clone() == pt.name.clone())))) } } @@ -11184,7 +11109,7 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == bind_name.clone().as_str()) { + if (g.clone() == bind_name.clone()) { __found = true; break; } @@ -11243,9 +11168,9 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); - (((formal_name.clone().as_str() != "".to_string().as_str()) - && (record_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() == record_name.clone().as_str())) + (((formal_name.clone() != "".to_string()) + && (record_name.clone() != "".to_string())) + && (formal_name.clone() == record_name.clone())) } } } @@ -11270,9 +11195,7 @@ pub fn unify_record_lit_field_walk( if (field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == field_name.clone().as_str()) + ) == field_name.clone()) { __result.push(fi); } @@ -11327,7 +11250,7 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == formal_name.clone().as_str()) { + if (g.clone() == formal_name.clone()) { __found = true; break; } @@ -11349,8 +11272,8 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((record_type_name.clone().as_str() != "".to_string().as_str()) - && (formal_name.clone().as_str() == record_type_name.clone().as_str())) + if ((record_type_name.clone() != "".to_string()) + && (formal_name.clone() == record_type_name.clone())) { unify_record_lit_field_walk( record_lit_expected_fields( @@ -11823,9 +11746,6 @@ pub fn build_type_env( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - // §3 single-authority: no implicit std.types base-injection. Resolution - // flows through each module's explicit import graph only (mirrors - // v1.compiler.infer build_type_env in src/v1/04_infer.dag). let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); @@ -11848,7 +11768,7 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12420,8 +12340,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - // §3 single-authority: no implicit std.types base-injection (mirrors - // build_type_env_unresolved in src/v1/04_infer.dag). + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12443,7 +12362,7 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -13357,8 +13276,8 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (dep.clone().as_str() == "None".to_string().as_str())) - || (dep.clone().as_str() == "".to_string().as_str())) + || (dep.clone() == "None".to_string())) + || (dep.clone() == "".to_string())) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13571,9 +13490,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).as_str() == "0".to_string().as_str()) - } + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, }) } @@ -13700,6 +13617,40 @@ pub fn build_positional_payload_variants( ) } +pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { + { + let has_seed = { + let mut __found = false; + 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() + { + if (v1_rt::contains(k.clone(), "/v1/".to_string()) + || v1_rt::contains(k.clone(), "src/v1".to_string())) + { + __found = true; + break; + } + } + __found + } { + __found = true; + break; + } + } + __found + }; + if has_seed { + RustCorpusRepr::HostNative + } else { + RustCorpusRepr::FaithfulFreeMonoid + } + } +} + pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { @@ -13756,6 +13707,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), + corpus_repr: rust_corpus_repr(modules.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 98745ada53b..5aa8cda70bb 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -1,6 +1,7 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.infer_emit_info +use self::RustCorpusRepr::*; use self::TypeRepr::*; pub use crate::v1_compiler_infer_types::{ child_type_node, emit_map_has, node_type_equals, normalize_access_type_node, @@ -62,6 +63,15 @@ pub struct TypeSummary { pub has_fn_fields: bool, } +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum RustCorpusRepr { + HostNative, + FaithfulFreeMonoid, +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EmitGraphInfo { pub type_summaries: Rc>>, @@ -75,6 +85,7 @@ pub struct EmitGraphInfo { pub owned_bindings: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, + pub corpus_repr: RustCorpusRepr, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -96,6 +107,7 @@ pub fn empty_emit_graph_info() -> Rc { read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), + corpus_repr: RustCorpusRepr::FaithfulFreeMonoid, }) } @@ -453,9 +465,8 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((resolved_name.clone().as_str() != "".to_string().as_str()) - && !ft_is_type_var.clone()) - && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) + if (((resolved_name.clone() != "".to_string()) && !ft_is_type_var.clone()) + && (resolved_name.clone() != "Dynamic".to_string())) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -621,3 +632,6 @@ pub fn add_emit_item_summary( None => state, } } + +pub struct HostNative; +pub struct FaithfulFreeMonoid; From 6525026dd5ff9c40d43f08f1ca0b58243ae9cb64 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 05:03:40 +0000 Subject: [PATCH 36/61] Restore known-good stage0 seed (revert premature regen); keep .dag class-3 logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-committed regen'd seed pulled in pre-existing .dag<->seed drift (the extdeps.cargo_version import wiring + faithful-emitted orphan modules) that breaks the v1-compiler build — that drift is the regen-lockstep capstone's domain, not class-3. The class-3 representation-coherence work stays fully in the .dag source; the seed regen lands via the regen-lockstep lane once a class-3 gunbc emits the bundled extdeps modules host-mode. Seed .rs reverted to the committed fixpoint so CI's rust gate is green. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 3725 +++++++---------- src/v1/stage0/src/v1_compiler_infer.rs | 500 ++- .../stage0/src/v1_compiler_infer_emit_info.rs | 20 +- 3 files changed, 1810 insertions(+), 2435 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 3fe26ae05d6..2f8f22d77f7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -1,7 +1,6 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.emit_rust -pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::extdeps_languages_rust_emit::HigherOrderMethodSpec; pub use crate::extdeps_languages_rust_emit::{ rt_bridge_function_names, rt_functions, rt_ref_map_functions, rt_wraps_result, @@ -9,8 +8,8 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_templates, rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_struct_derives, rust_struct_derives_copy, }; +pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::SubValueUnknown; -pub use crate::std_induction::{InductiveField, SubValueRelation}; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{is_container_type, is_kernel_type}; @@ -46,25 +45,19 @@ pub use crate::v1_compiler_emit_core_support::{ pub use crate::v1_compiler_emit_core_support::{EmitResult, TestProjection}; pub use crate::v1_compiler_infer::InferScope; pub use crate::v1_compiler_infer::{ - build_emit_graph_info, build_params_scope, expand_type_for_field_access, expr_span, - extend_scope, resolved_type_name, + build_emit_graph_info, build_params_scope, expr_span, extend_scope, resolved_type_name, }; -use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ find_variant_parent, is_enum_in_summaries, is_known_variant, lookup_emit_type_summary, variant_belongs_to_enum, variant_summary_key, }; -pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, RustCorpusRepr, TypeRepr, TypeSummary, -}; +pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; pub use crate::v1_compiler_infer_env::{authored_name, lookup_type_by_name, lookup_type_for}; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; use crate::v1_compiler_infer_items::ItemKind::{DataItem, OtherItem, TypeItem}; pub use crate::v1_compiler_infer_items::{ItemInfo, ItemKind, ResolvedGraph, TypedModule}; -pub use crate::v1_compiler_infer_resolve::{ - is_width_nat_type_literal, lookup_unit_variant_phantom_type, -}; +pub use crate::v1_compiler_infer_resolve::lookup_unit_variant_phantom_type; pub use crate::v1_compiler_infer_service::{ extract_typed_service_name, is_typed_service_call_receiver, }; @@ -90,6 +83,7 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; +use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -118,16 +112,16 @@ use crate::v1_std_core::VarBindingKind::{ }; pub use crate::v1_std_core::{ arg_name_at, arg_value, arm_body, arm_guard, arm_pattern, authored_name_at, binop_left, - binop_right, cast_expr, cast_target, empty_intern_table, expr_call_func_at, - expr_has_non_tail_self_call, expr_has_self_call, expr_method_name_at, expr_var_name_at, - field_access_base, 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, find_property, foreach_body, foreach_collection, foreach_variable_at, - generic_param_name_at, if_condition, if_else_branch, if_then_branch, import_is_all, - import_specific_names_at, index_base, index_expr, is_compiler_error, is_file_transport, - is_rest_transport, is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, - let_body, let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, - make_span, match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + binop_right, cast_expr, cast_target, expr_call_func_at, expr_has_non_tail_self_call, + expr_has_self_call, expr_method_name_at, expr_var_name_at, field_access_base, + 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, + find_property, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, + if_condition, if_else_branch, if_then_branch, import_is_all, import_specific_names_at, + index_base, index_expr, is_compiler_error, is_file_transport, is_rest_transport, + is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, let_body, + let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, make_span, + match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, module_items, param_node_default_value, param_node_name_at, param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, return_value, service_config_auth, service_config_auth_input, service_config_auth_source, @@ -150,7 +144,6 @@ use std::rc::Rc; pub fn render_rust_type( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match n.inferred.clone().as_deref().cloned() { @@ -166,26 +159,12 @@ pub fn render_rust_type( applied.clone(), Rc::new(vec![]), shared_types, - corpus_repr, source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::< - String, - Rc>>, - >(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } else { render_rust_type_without_applied_binding( n.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } @@ -193,7 +172,6 @@ pub fn render_rust_type( None => render_rust_type_without_applied_binding( n.clone(), shared_types, - corpus_repr, source_indices.clone(), ), }, @@ -203,7 +181,6 @@ pub fn render_rust_type( pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if (((n.connective.clone() == Connective::NoConnective) @@ -214,17 +191,7 @@ pub fn render_rust_type_without_applied_binding( n.clone(), Rc::new(vec![]), shared_types, - corpus_repr, source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -264,20 +231,19 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { + let tn = authored_name_at(source_indices.clone(), n.clone()); + if (tn.clone().as_str() == "String".to_string().as_str() + && ((n.children.clone().len() as i64) == 0) + && rust_emit_faithful_text_carrier(source_indices.clone())) { - let tn = authored_name_at(source_indices.clone(), n.clone()); - if (((tn == "String".to_string()) && ((n.children.clone().len() as i64) == 0)) - && corpus_repr_is_faithful(corpus_repr)) - { - render_rust_text_carrier(shared_types) - } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) - } + render_rust_text_carrier(shared_types.clone()) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) } } } @@ -289,21 +255,22 @@ pub fn empty_string_bool_map() -> Rc> { pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { ((v1_rt::string_length(&type_name) >= 3) - && (v1_rt::substring(&type_name, 0, 3) == "Rc<".to_string())) + && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) } -pub fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> bool { - match corpus_repr { - RustCorpusRepr::FaithfulFreeMonoid => true, - RustCorpusRepr::HostNative => false, - } +pub fn rust_corpus_includes_v1_compiler( + source_indices: Rc>>, +) -> bool { + v1_rt::map_keys(&source_indices) + .iter() + .cloned() + .any(|k| k.contains("/v1/") || k.contains("src/v1")) } -pub fn corpus_repr_is_host(corpus_repr: RustCorpusRepr) -> bool { - match corpus_repr { - RustCorpusRepr::HostNative => true, - RustCorpusRepr::FaithfulFreeMonoid => false, - } +pub fn rust_emit_faithful_text_carrier( + source_indices: Rc>>, +) -> bool { + !rust_corpus_includes_v1_compiler(source_indices) } pub fn render_rust_text_carrier(shared_types: Rc>) -> String { @@ -316,9 +283,9 @@ pub fn render_rust_text_carrier(shared_types: Rc>>, ) -> String { - if corpus_repr_is_faithful(corpus_repr) { + if rust_emit_faithful_text_carrier(source_indices) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), @@ -333,9 +300,9 @@ pub fn emit_rust_host_to_dag_string_via_seam( pub fn emit_rust_dag_string_to_host_via_seam( dag_expr: String, - corpus_repr: RustCorpusRepr, + source_indices: Rc>>, ) -> String { - if corpus_repr_is_faithful(corpus_repr) { + if rust_emit_faithful_text_carrier(source_indices) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), @@ -349,52 +316,57 @@ pub fn emit_rust_dag_string_to_host_via_seam( } pub fn rust_host_string_seam_fn_emit(name: String) -> Option { - if (name.clone() == "host_string_text_from_rust_host".to_string()) { - Some(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string()), "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string()), "}\n".to_string())) + if name.as_str() == "host_string_text_from_rust_host" { + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), + " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), + ), + "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), + ), + "}\n".to_string(), + )) + } else if name.as_str() == "host_string_text_to_rust_host" { + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), + " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), + ), + "}\n".to_string(), + ), + "".to_string(), + )) } else { - if (name.clone() == "host_string_text_to_rust_host".to_string()) { - Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) - } else { - None - } + None } } pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if ((name.clone() == "Json".to_string()) || (name.clone() == "Bytes".to_string())) { + if (name.clone().as_str() == "Json".to_string().as_str()) + || (name.clone().as_str() == "Bytes".to_string().as_str()) + { Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { None } } -pub fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> Option { - if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) - && corpus_repr_is_host(corpus_repr)) +pub fn rust_named_type_base( + name: String, + source_indices: Rc>>, +) -> String { + if ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) { - Some("i64".to_string()) - } else { - None - } -} - -pub fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> Option { - if ((name == "List".to_string()) && corpus_repr_is_host(corpus_repr)) { - Some("Vec".to_string()) - } else { - None - } -} - -pub fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { - if ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) { "Witness".to_string() + } else if name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices) + { + "FreeMonoid".to_string() } else { - if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr)) { - "FreeMonoid".to_string() - } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) - } + coerce_primitive_type(RenderTarget::Rust, name.clone()) } } @@ -422,112 +394,15 @@ 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()), - None => false, - } -} - -pub fn is_parametric_opaque_type_base( - type_name: String, - def_mod_filename: String, - typed_modules: Rc>>, - source_indices: Rc>>, - module_index: Rc, -) -> bool { - match type_item_by_name_in_module_filename( - type_name, - def_mod_filename, - typed_modules, - source_indices.clone(), - module_index, - ) { - Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), - None => false, - } -} - -pub fn render_rust_phantom_opaque_applied_type_arg( - n: Rc, - generic_param_names: Rc>, - shared_types: Rc>, - corpus_repr: RustCorpusRepr, - source_indices: Rc>>, - scope: Rc, - imports: Rc>>, - registry: Rc>>, - module_name: String, - export_sets: Rc>>>, - typed_modules: Rc>>, - module_index: Rc, - variant_to_enum: Rc>, -) -> String { - if is_width_nat_type_literal(n.clone()) { - "()".to_string() - } else { - render_rust_alias_rhs_type( - n.clone(), - generic_param_names, - shared_types, - corpus_repr, - source_indices, - scope, - imports, - registry, - module_name, - export_sets, - typed_modules, - module_index, - variant_to_enum, - ) - } -} - -pub fn render_rust_phantom_opaque_applied_decl_arg( - n: Rc, - generic_param_names: Rc>, - shared_types: Rc>, - corpus_repr: RustCorpusRepr, - source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_width_nat_type_literal(n.clone()) { - "()".to_string() - } else { - render_rust_decl_type( - n.clone(), - generic_param_names, - shared_types, - corpus_repr, - source_indices, - variant_to_enum, - env, - ) - } -} - pub fn render_rust_applied_type_arg( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type( - n.clone(), - generic_param_names, - shared_types, - corpus_repr, - source_indices, - variant_to_enum, - env, - ), + _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), } } @@ -535,46 +410,26 @@ pub fn render_rust_applied_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { - let base_name = authored_name_at(source_indices.clone(), n.clone()); - let base = 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()), - }; + let base = rust_named_type_base( + authored_name_at(source_indices.clone(), n.clone()), + source_indices.clone(), + ); if ((n.children.clone().len() as i64) == 0) { base } else { { - 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() { - __result.push(if peel.clone() { - render_rust_phantom_opaque_applied_decl_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - } else { - render_rust_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - }); + __result.push(render_rust_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + )); } __result }) @@ -605,20 +460,14 @@ pub fn render_rust_applied_type_shared( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { let rendered = render_rust_applied_type( n.clone(), generic_param_names, shared_types.clone(), - corpus_repr, source_indices.clone(), - variant_to_enum, - env, ); let type_name = authored_name_at(source_indices.clone(), n.clone()); render_rust_shared_type_if_needed(type_name, rendered, shared_types.clone()) @@ -629,10 +478,7 @@ pub fn render_rust_decl_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -640,7 +486,8 @@ pub fn render_rust_decl_type( "__applied_type_args".to_string(), source_indices.clone(), ); - let applied_overlay = match applied_prop.clone() { + let has_applied_prop = applied_prop.is_some(); + let applied_overlay = match applied_prop { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) @@ -655,10 +502,7 @@ pub fn render_rust_decl_type( applied.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -667,7 +511,7 @@ pub fn render_rust_decl_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone() == name.clone()) { + if (g.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -676,103 +520,67 @@ pub fn render_rust_decl_type( }) { name.clone() + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && !has_applied_prop + && name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices.clone())) + { + render_rust_text_carrier(shared_types.clone()) + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && !has_applied_prop + && v1_rt::set_contains(&shared_types, name.clone())) + { + let stub_env = Rc::new(TypeEnv { + bindings: Rc::new(HashMap::new()), + recursive_types: Rc::new(vec![]), + recursive_type_set: Rc::new(HashMap::new()), + inductive_fields: Rc::new(HashMap::new()), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }); + let rendered = rust_render_type_leaf_name( + name.clone(), + v1_rt::rc_empty_map::(), + stub_env, + ); + render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) } else { - if (((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && (name.clone() == "String".to_string())) - && corpus_repr_is_faithful(corpus_repr.clone())) + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) { - render_rust_text_carrier(shared_types.clone()) - } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && v1_rt::set_contains(&shared_types, name.clone())) { - { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - env.clone(), - ); - render_rust_shared_type_if_needed( - name.clone(), - rendered, - shared_types.clone(), - ) - } - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - if (!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(), + let base = rust_named_type_base(name.clone(), source_indices.clone()); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), shared_types.clone(), - ) - } else { - { - let base = - rust_named_type_base(name.clone(), corpus_repr.clone()); - let peel = is_parametric_opaque_type_by_name( - env.clone(), - name.clone(), - ); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(if peel.clone() { - render_rust_phantom_opaque_applied_decl_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - } else { - render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - }); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat( - v1_rt::concat(base, "<".to_string()), - args, - ), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) - } + source_indices.clone(), + )); } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - ) - } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) } + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + source_indices.clone(), + ) } } } @@ -781,78 +589,53 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - if (name.clone() == "String".to_string()) { - return false; - } - let binding = match lookup_type_for(env.clone(), n.clone()) { - 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()) { - Some(b) => b.clone(), - None => return false, - } - } - }; - ((binding.params.clone().len() as i64) == 0) + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if name.clone().as_str() == "String".to_string().as_str() { + return false; } + let binding = match lookup_type_for(env.clone(), n.clone()) { + Some(b) => b, + None => { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + match lookup_type_by_name(env.clone(), name) { + Some(b) => b, + None => return false, + } + } + }; + (binding.params.clone().len() as i64) == 0 } pub fn render_rust_fn_sig_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices.clone())) { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (name.clone() == "String".to_string())) - && corpus_repr_is_faithful(corpus_repr.clone())) - { - render_rust_text_carrier(shared_types) - } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !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) - } else { - if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type( - n.clone(), - generic_param_names.clone(), - shared_types, - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum, - env.clone(), - ) - } else { - render_rust_fn_sig_type_applied_binding( - n.clone(), - shared_types, - corpus_repr.clone(), - source_indices.clone(), - env.clone(), - ) - } - } - } + render_rust_text_carrier(shared_types.clone()) + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0) + && !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()) + } else if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) + } else { + render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) } } pub fn render_rust_fn_sig_type_applied_binding( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, env: Rc, ) -> String { @@ -863,42 +646,25 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if outer_name.as_str() != "" + && n.connective.clone() == Connective::NoConnective + && (n.children.clone().len() as i64) == 0 + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if ((((outer_name.clone() != "".to_string()) - && (n.connective.clone() == Connective::NoConnective)) - && ((n.children.clone().len() as i64) == 0)) - && rust_fn_sig_peel_closed_alias(env, n.clone())) - { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name.clone(), - shared_types, - ) - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ) - } + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name, + shared_types.clone(), + ) + } else { + render_rust_type_with_applied_binding(n, shared_types, source_indices) } } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ) + render_rust_type_with_applied_binding(n, shared_types, source_indices) } } - None => render_rust_type_with_applied_binding( - n.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ), + None => render_rust_type_with_applied_binding(n, shared_types, source_indices), } } @@ -906,7 +672,6 @@ pub fn render_rust_alias_rhs_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, scope: Rc, imports: Rc>>, @@ -924,7 +689,7 @@ pub fn render_rust_alias_rhs_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone() == name.clone()) { + if (g.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -933,140 +698,85 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + { + if name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices.clone()) { - match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { - Some(host) => host.clone(), - None => { - if ((name.clone() == "String".to_string()) - && corpus_repr_is_faithful(corpus_repr.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else { - 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(), - scope.type_env.clone(), - ); - render_rust_shared_type_if_needed( - name.clone(), - rendered, - shared_types.clone(), - ) - } - } - } - } - } + render_rust_text_carrier(shared_types.clone()) + } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { + carrier } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + scope.type_env.clone(), + ); + render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) + } + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let base = if (def_mod.clone().as_str() != local_mod.as_str()) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + }; + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), scope.clone(), + imports.clone(), registry.clone(), + module_name.clone(), export_sets.clone(), typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = match rust_seed_host_container_base( - name.clone(), - corpus_repr.clone(), - ) { - Some(host) => host.clone(), - None => { - if (def_mod.clone() != local_mod) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - } - } - }; - let peel = is_parametric_opaque_type_base( - name.clone(), - def_mod.clone(), - typed_modules.clone(), - source_indices.clone(), module_index.clone(), - ); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(if peel.clone() { - render_rust_phantom_opaque_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - variant_to_enum.clone(), - ) - } else { - render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - variant_to_enum.clone(), - ) - }); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) - } else { - applied_ty.clone() - } + variant_to_enum.clone(), + )); } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - ) + applied_ty.clone() } } + } else { + render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -1193,14 +903,14 @@ pub fn rust_nominal_identity_carrier_def(name: String) -> String { } pub fn rust_nominal_identity_carrier_type_eligible(type_name: String) -> bool { - (type_name == "Symbol".to_string()) + (type_name.as_str() == "Symbol".to_string().as_str()) } pub fn rust_nominal_identity_carrier_shape_eligible( n: Rc, source_indices: Rc>>, ) -> bool { - ((((authored_name_at(source_indices, n.clone()) == "Symbol".to_string()) + ((((authored_name_at(source_indices, n.clone()).as_str() == "Symbol".to_string().as_str()) && ((n.children.clone().len() as i64) == 0)) && ((n.params.clone().len() as i64) == 0)) && (n.connective.clone() == Connective::NoConnective)) @@ -1211,7 +921,8 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( children: Rc>>, source_indices: Rc>>, ) -> bool { - if ((name != "DiffId".to_string()) || ((children.clone().len() as i64) != 1)) { + if ((name.as_str() != "DiffId".to_string().as_str()) || ((children.clone().len() as i64) != 1)) + { false } else { match children.clone().first().cloned() { @@ -1245,8 +956,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.clone() == "DiffId".to_string()))) + && ((type_name.clone().as_str() == "Symbol".to_string().as_str()) + || (type_name.clone().as_str() == "DiffId".to_string().as_str()))) } } @@ -1347,7 +1058,9 @@ pub fn field_value_by_name( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at(fi.clone(), source_indices.clone()) == field_name.clone()) { + if (field_init_node_name_at(fi.clone(), source_indices.clone()).as_str() + == field_name.clone().as_str()) + { __result.push(fi); } } @@ -1417,16 +1130,18 @@ pub fn rust_string_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone() == "AsAuthored".to_string()) { + if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { rust_string_as_authored_policy() } else { - if (naming_name.clone() == "SnakeCase".to_string()) { + if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { rust_snake_string_policy() } else { - if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { + if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { rust_screaming_snake_string_policy() } else { - if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripPrefixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1443,7 +1158,9 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripSuffixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1460,15 +1177,35 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) + if (naming_name.clone().as_str() + == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - 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())), - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), -}, - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), -} + 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()), + ), + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal suffix" + .to_string(), + ), + }, + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal prefix" + .to_string(), + ), + } } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1490,7 +1227,7 @@ pub fn rust_internal_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone() == "AsAuthored".to_string()) { + if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1501,7 +1238,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone() == "SnakeCase".to_string()) { + if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1512,7 +1249,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { + if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1523,7 +1260,9 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripPrefixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1543,7 +1282,9 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripSuffixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1563,15 +1304,41 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) + if (naming_name.clone().as_str() + == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - 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())), - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), -}, - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), -} + 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()), + ), + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal suffix" + .to_string(), + ), + }, + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal prefix" + .to_string(), + ), + } } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1617,10 +1384,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ) -> Rc { { let encoding_name = authored_name_at(source_indices.clone(), ve.clone()); - if (encoding_name.clone() == "InternallyTaggedObject".to_string()) { + if (encoding_name.clone().as_str() == "InternallyTaggedObject".to_string().as_str()) { rust_internal_policy_for_encoding(ve.clone(), source_indices.clone()) } else { - if (encoding_name.clone() == "StringVariant".to_string()) { + if (encoding_name.clone().as_str() == "StringVariant".to_string().as_str()) { match naming_policy_node(ve.clone(), source_indices.clone()) { Some(nv) => rust_string_policy_for_naming(nv.clone(), source_indices.clone()), None => rust_serde_error_policy( @@ -1628,10 +1395,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ), } } else { - if (encoding_name.clone() == "UntaggedVariant".to_string()) { + if (encoding_name.clone().as_str() == "UntaggedVariant".to_string().as_str()) { rust_untagged_policy() } else { - if (encoding_name.clone() == "TaggedVariant".to_string()) { + if (encoding_name.clone().as_str() == "TaggedVariant".to_string().as_str()) { rust_tagged_object_policy() } else { rust_serde_error_policy(v1_rt::concat( @@ -1661,7 +1428,8 @@ pub fn resolve_wire_serde_policy( } pub fn item_binding_is_named(env: Rc, node: Rc, name: String) -> bool { - ((authored_name(env, node.clone()) == name.clone()) || (node.name.clone() == name.clone())) + ((authored_name(env, node.clone()).as_str() == name.clone().as_str()) + || (node.name.clone().as_str() == name.clone().as_str())) } pub fn resolve_wire_serde_policy_for_coproduct( @@ -1854,7 +1622,7 @@ pub fn variant_encoding_is_string_variant( encoding: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, encoding) == "StringVariant".to_string()) + (authored_name_at(source_indices, encoding).as_str() == "StringVariant".to_string().as_str()) } pub fn coproduct_wire_contract_targets( @@ -1865,7 +1633,7 @@ pub fn coproduct_wire_contract_targets( match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { - Some(target_name) => (target_name.clone() == coproduct_name), + Some(target_name) => (target_name.clone().as_str() == coproduct_name.as_str()), None => false, } } @@ -1894,15 +1662,15 @@ pub fn module_imports_std_serialization_coproduct_wire_contract( { let mut __found = false; for imp in imports.iter().cloned() { - if ((authored_name_at(source_indices.clone(), imp.clone()) - == "std.serialization".to_string()) + if ((authored_name_at(source_indices.clone(), imp.clone()).as_str() + == "std.serialization".to_string().as_str()) && (import_is_all(imp.clone()) || { let mut __found = false; for name in import_specific_names_at(imp.clone(), source_indices.clone()) .iter() .cloned() { - if (name.clone() == "CoproductWireContract".to_string()) { + if (name.clone().as_str() == "CoproductWireContract".to_string().as_str()) { __found = true; break; } @@ -1925,8 +1693,8 @@ 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.clone()) - == "CoproductWireContract".to_string()) + ((authored_name_at(source_indices.clone(), type_node.clone()).as_str() + == "CoproductWireContract".to_string().as_str()) && module_imports_std_serialization_coproduct_wire_contract( imports, source_indices.clone(), @@ -1946,8 +1714,8 @@ pub fn module_defines_local_coproduct_wire_contract_type( if (((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), item.clone()) - == "CoproductWireContract".to_string())) + && (authored_name_at(source_indices.clone(), item.clone()).as_str() + == "CoproductWireContract".to_string().as_str())) { __found = true; break; @@ -2008,7 +1776,7 @@ pub fn emit_coproduct_wire_contract_target_validation( if { let mut __found = false; for name in local_coproduct_names.iter().cloned() { - if (name.clone() == target_name.clone()) { + if (name.clone().as_str() == target_name.clone().as_str()) { __found = true; break; } @@ -2073,7 +1841,7 @@ pub fn emit_coproduct_wire_contract_validations( .iter() .cloned() { - if (text.clone() != "".to_string()) { + if (text.clone().as_str() != "".to_string().as_str()) { __result.push(text); } } @@ -2398,198 +2166,51 @@ pub fn emit_rust_init_block_stmts( remaining .clone() .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ); - match rest.clone().first().cloned() { - None => { - break Rc::new(BlockEmitState { - text: text, - scope: scope.clone(), - }); - } - Some(_) => { - let raw_line = emit_typed_expr( - stmt.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let is_let = match (*stmt.expr_data.clone()).clone() { - ExprData::ExprLet => true, - _ => false, - }; - let line = if is_let { - raw_line - } else { - 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); - let __tco_2 = next_scope; - remaining = __tco_0; - text = __tco_1; - scope = __tco_2; - continue; - } - } - } - } - } - } -} - -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - 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(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name.clone() - } else { - match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier.clone(), - None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum), - } - } -} - -pub fn rust_phantom_zst_marker_def(vname: String) -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]\n".to_string(), rust_visibility_prefix()), rust_items().struct_keyword.clone()), " ".to_string()), vname), ";".to_string()) -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - { - let markers = Rc::new({ - let mut __result = Vec::new(); - for child in Rc::new({ - let mut __result = Vec::new(); - for child in Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if ((child.children.clone().len() as i64) == 0) { - __result.push(child); - } - } - __result - }) - .iter() - .cloned() - { - if is_phantom_unit_variant_type_arg( - env.clone(), - authored_name(env.clone(), child.clone()), - ) { - __result.push(child); - } - } - __result - }) - .iter() - .cloned() - { - __result.push({ - let vname = authored_name(env.clone(), child.clone()); - rust_phantom_zst_marker_def(vname.clone()) - }); - } - __result - }) - .join(&"\n".to_string()); - markers - } -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for item in items.iter().cloned() { - if (is_type_def_item(item.clone()) && { - let mut __all = true; - for c in item.children.clone().iter().cloned() { - if !((c.children.clone().len() as i64) == 0) { - __all = false; - break; - } - } - __all - }) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { - item.children.clone().iter().cloned().fold( - acc, - |inner: Rc>, child: Rc| { - if ((child.children.clone().len() as i64) == 0) { - { - let vname = authored_name(env.clone(), child.clone()); - if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !{ - let mut __found = false; - for n in inner.clone().iter().cloned() { - if (n.clone() == vname.clone()) { - __found = true; - break; - } - } - __found - }) - { - v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + .cloned() + .skip(1 as usize) + .collect::>(), + ); + match rest.clone().first().cloned() { + None => { + break Rc::new(BlockEmitState { + text: text, + scope: scope.clone(), + }); + } + Some(_) => { + let raw_line = emit_typed_expr( + stmt.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ); + let is_let = match (*stmt.expr_data.clone()).clone() { + ExprData::ExprLet => true, + _ => false, + }; + let line = if is_let { + raw_line } else { - inner.clone() + 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); + let __tco_2 = next_scope; + remaining = __tco_0; + text = __tco_1; + scope = __tco_2; + continue; } } - } else { - inner.clone() } - }, - ) - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { - __result.push(rust_phantom_zst_marker_def(vname.clone())); + } } - __result - }) - .join(&"\n".to_string()) + } } pub fn has_complex_variants(item: Rc) -> bool { @@ -2731,8 +2352,9 @@ pub fn build_shared_types( .iter() .cloned() { - if ((sharing.needs_sharing.clone() && (k.clone() != "optional".to_string())) - && (k.clone() != "boolean_algebra".to_string())) + if ((sharing.needs_sharing.clone() + && (k.clone().as_str() != "optional".to_string().as_str())) + && (k.clone().as_str() != "boolean_algebra".to_string().as_str())) { __result.push(k); } @@ -2910,7 +2532,6 @@ pub fn emit_rust(typed: Rc) -> Rc { owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let registry = typed.item_registry.clone(); @@ -2991,18 +2612,18 @@ pub fn emit_rust(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone() + if (p.module_name.clone().as_str() == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - )) + ) + .as_str()) { __result.push(p); } } __result }), - emit_info.corpus_repr.clone(), )); } __result @@ -3010,7 +2631,7 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone() != "".to_string()) { + if (f.path.clone().as_str() != "".to_string().as_str()) { __result.push(f); } } @@ -3021,7 +2642,8 @@ pub fn emit_rust(typed: Rc) -> Rc { 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()) + .as_str() + == "v1.compiler.compile".to_string().as_str()) { __found = true; break; @@ -3130,7 +2752,7 @@ pub fn emit_lib_rs_from_files( __result }); let hand_maintained_mods = if has_compiler_tests.clone() { - "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod languages_consumer_census;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() + "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() } else { "".to_string() }; @@ -3140,6 +2762,9 @@ pub fn emit_lib_rs_from_files( "".to_string() }; let shared_types = emit_non_empty_wrappers(); + // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (single authority): + // crate-root #![recursion_limit = "256"] added (serde_json::json! recursion fix). + // DISSOLUTION lane adhoc-1bdd0259-2e3; a clean regen reproduces this from the .dag. let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); Rc::new(TextFile { path: v1_rt::concat( @@ -3174,7 +2799,6 @@ pub fn emit_module( owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let export_sets = build_module_export_sets(Rc::new(vec![typed_module.clone()])); @@ -3271,7 +2895,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), module_index.clone(), ); - let imports_section = if (imports_str.clone() == "".to_string()) { + let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { v1_rt::concat("\n".to_string(), imports_str.clone()) @@ -3301,7 +2925,7 @@ pub fn emit_module_full( __result.extend( (*match v1_rt::map_get(&svc_module_map, sn.clone()) { Some(mod_file) => { - if (mod_file.clone() == this_mod_filename.clone()) { + if (mod_file.clone().as_str() == this_mod_filename.clone().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![v1_rt::concat( @@ -3388,7 +3012,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = - if (coproduct_wire_contract_validations.clone() == "".to_string()) { + if (coproduct_wire_contract_validations.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { v1_rt::concat( @@ -3449,19 +3073,19 @@ 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()); - let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { + let phantom_section = if phantom_zst_markers.as_str() == "" { "".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 filename = if (raw_filename.clone() == "main".to_string()) { + let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) - == "std.error_primitives".to_string()) + let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()).as_str() + == "std.error_primitives".to_string().as_str()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { @@ -3663,10 +3287,10 @@ pub fn has_physical_type_def_in_module_filename( if { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) - == rhs_name.clone()) - && ((is_type_def_item(item.clone()) - || is_type_alias_item(item.clone(), source_indices.clone())) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == rhs_name.clone().as_str()) + && (is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone()) || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; @@ -3718,8 +3342,8 @@ pub fn find_variant_parent_in_module( 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()) + if (authored_name_at(source_indices.clone(), child.clone()).as_str() + == variant_name.clone().as_str()) { __found = true; break; @@ -3761,7 +3385,8 @@ pub fn type_name_is_export_source_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == name.clone().as_str()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3794,7 +3419,8 @@ pub fn type_name_is_rust_importable_in_module( Some(tm) => match Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == name.clone().as_str()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3876,7 +3502,7 @@ pub fn name_in_transitive_export_surface( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone() == module_name.clone()) { + if (v.clone().as_str() == module_name.clone().as_str()) { __found = true; break; } @@ -3971,7 +3597,7 @@ pub fn reexport_source_module_name_with_visited( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone() == import_module.clone()) { + if (v.clone().as_str() == import_module.clone().as_str()) { __found = true; break; } @@ -4025,7 +3651,8 @@ pub fn reexport_source_module_name_with_visited( .iter() .cloned() { - if (n.clone() == name.clone()) { + if (n.clone().as_str() == name.clone().as_str()) + { __found = true; break; } @@ -4199,7 +3826,7 @@ pub fn import_module_enum_scope( .iter() .cloned() { - if (p.clone() != "".to_string()) { + if (p.clone().as_str() != "".to_string().as_str()) { __result.push(p); } } @@ -4274,7 +3901,8 @@ pub fn enum_physically_defined_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if (((authored_name_at(source_indices.clone(), item.clone()) == enum_name.clone()) + if (((authored_name_at(source_indices.clone(), item.clone()).as_str() + == enum_name.clone().as_str()) && is_type_def_item(item.clone())) && is_coproduct_type(item.clone())) { @@ -4299,7 +3927,7 @@ pub fn wildcard_import_pool_surface_names( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone() == module_name.clone()) { + if (v.clone().as_str() == module_name.clone().as_str()) { __found = true; break; } @@ -4396,7 +4024,7 @@ pub fn wildcard_reexport_surface_names( source_indices.clone(), module_index.clone(), ) { - Some(src) => (src.clone() != import_module.clone()), + Some(src) => (src.clone().as_str() != import_module.clone().as_str()), None => false, } { __result.push(n); @@ -4469,7 +4097,7 @@ pub fn variant_defining_module_filename_for_import( module_index.clone(), ) { Some(hop) => { - if (hop.clone() != import_module.clone()) { + if (hop.clone().as_str() != import_module.clone().as_str()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4507,7 +4135,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone() == parent_enum.clone()) { + if (local_parent.clone().as_str() == parent_enum.clone().as_str()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -4559,7 +4187,7 @@ pub fn explicit_import_source_module_for_name( .iter() .cloned() { - if (n.clone() == name.clone()) { + if (n.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -4672,7 +4300,7 @@ pub fn reexport_variant_parent_in_import_module( module_index.clone(), ) { Some(hop) => { - if (hop.clone() != src_mod.clone()) { + if (hop.clone().as_str() != src_mod.clone().as_str()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4763,7 +4391,7 @@ pub fn alias_rhs_base_module_filename( let local_mod = module_to_filename(alias_module.clone()); match lookup_item(scope.item_registry.clone(), name.clone()) { Some(info) => { - if ((info.module_name.clone() == alias_module.clone()) + if ((info.module_name.clone().as_str() == alias_module.clone().as_str()) && ((info.kind.clone() == ItemKind::TypeItem) || (info.kind.clone() == ItemKind::OtherItem))) { @@ -4816,7 +4444,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .iter() .cloned() { - if (n.clone() == name.clone()) { + if (n.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -4923,8 +4551,8 @@ pub fn type_item_by_name_in_module_filename( Some(tm) => Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) - == rhs_name.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == rhs_name.clone().as_str()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -4971,12 +4599,28 @@ pub fn type_item_has_rust_nominal_shell_authority( { true } else { + let rhs = resolved_type(item.clone()); + if is_type_alias_return_node(rhs.clone(), source_indices.clone()) + && ((rhs.children.clone().len() as i64) > 0) { - let rhs = resolved_type(item.clone()); - if (is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && ((rhs.children.clone().len() as i64) > 0)) - { - alias_rhs_nominal_shell_has_rust_authority( + alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + ) + } else if is_type_alias_return_node(rhs.clone(), source_indices.clone()) + { + let rhs_name = + authored_name_at(source_indices.clone(), rhs.clone()); + (rhs_name.as_str() != item_text.as_str()) + && rhs_name.as_str() != "" + && alias_rhs_nominal_shell_has_rust_authority( rhs.clone(), module_name, imports, @@ -4987,34 +4631,8 @@ pub fn type_item_has_rust_nominal_shell_authority( source_indices.clone(), module_index, ) - } else { - if is_type_alias_return_node( - rhs.clone(), - source_indices.clone(), - ) { - { - let rhs_name = authored_name_at( - source_indices.clone(), - rhs.clone(), - ); - (((rhs_name.clone() != item_text.clone()) - && (rhs_name.clone() != "".to_string())) - && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - )) - } - } else { - false - } - } + } else { + false } } } else { @@ -5212,7 +4830,9 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( } else { { let name = authored_name_at(source_indices.clone(), n.clone()); - if ((name.clone() == "".to_string()) || is_kernel_type(name.clone())) { + if ((name.clone().as_str() == "".to_string().as_str()) + || is_kernel_type(name.clone())) + { true } else { if is_phantom_unit_variant_type_arg( @@ -5261,100 +4881,91 @@ pub fn is_self_referential_opaque_type_resolved( item: Rc, source_indices: Rc>>, ) -> bool { - { - 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)) - } + 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 } pub fn is_zero_param_self_referential_opaque_decl( item: Rc, source_indices: Rc>>, ) -> bool { - (is_bare_leaf_item(item.clone()) - && is_self_referential_opaque_type_resolved(item.clone(), source_indices)) + is_bare_leaf_item(item.clone()) + && is_self_referential_opaque_type_resolved(item.clone(), source_indices) } 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.children.clone().len() as i64) == 0)) + ((item.params.clone().len() as i64) > 0) + && item.body.is_none() + && item.transport.is_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()))) + || is_self_referential_opaque_type_resolved(item.clone(), source_indices)) } pub fn emit_zero_param_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - { - let item_text = authored_name_at(source_indices, item); + let item_text = authored_name_at(source_indices.clone(), item.clone()); + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), - ), - rust_items().struct_keyword.clone(), + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), ), - " ".to_string(), + rust_items().struct_keyword.clone(), + ), + v1_rt::concat( + v1_rt::concat(" ".to_string(), item_text), + "(pub std::marker::PhantomData<()>);".to_string(), ), - item_text, ), - "(pub std::marker::PhantomData<()>);".to_string(), - ) - } + "".to_string(), + ), + "".to_string(), + ) } pub fn emit_parametric_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - let type_params = emit_type_params(item.params.clone(), source_indices.clone()); - 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(), g.clone()), - ">".to_string(), - ), - None => "std::marker::PhantomData<()>".to_string(), - }; + let item_text = authored_name_at(source_indices.clone(), item.clone()); + let type_params = emit_type_params(item.params.clone(), source_indices.clone()); + 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(), g), + ">".to_string(), + ), + None => "std::marker::PhantomData<()>".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( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n" - .to_string(), - rust_visibility_prefix(), - ), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - item_text, - ), - type_params, + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), ), - "(pub ".to_string(), + rust_items().struct_keyword.clone(), ), - marker_ty, + v1_rt::concat(v1_rt::concat(" ".to_string(), item_text), type_params), ), - ");".to_string(), - ) - } + v1_rt::concat( + v1_rt::concat("(pub ".to_string(), marker_ty), + ");".to_string(), + ), + ), + "".to_string(), + ) } pub fn is_emittable_parametric_type_alias_item( @@ -5384,21 +4995,37 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs_name = authored_name_at(source_indices.clone(), rhs.clone()); - ((rhs_name.clone() != item_text) - && (((rhs.children.clone().len() as i64) > 0) - || ((((rhs.children.clone().len() as i64) == 0) - && (rhs_name.clone() != "".to_string())) - && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - )))) + if rhs_name.as_str() != item_text.as_str() { + if (rhs.children.clone().len() as i64) > 0 { + alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + ) + } else if rhs_name.as_str() != "" { + alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + ) + } else { + false + } + } else { + false + } } } } @@ -5426,7 +5053,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for ln in local_names.clone().iter().cloned() { - if !(ln.clone() != n.clone()) { + if !(ln.clone().as_str() != n.clone().as_str()) { __all = false; break; } @@ -5568,7 +5195,7 @@ pub fn emit_specific_import_block( .iter() .cloned() { - if (p.clone() != "".to_string()) { + if (p.clone().as_str() != "".to_string().as_str()) { __result.push(p); } } @@ -5602,7 +5229,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => false, } { __found = true; @@ -5624,7 +5251,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for n in direct_names.clone().iter().cloned() { - if !(n.clone() != p.clone()) { + if !(n.clone().as_str() != p.clone().as_str()) { __all = false; break; } @@ -5649,7 +5276,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => false, } { __found = true; @@ -5733,7 +5360,9 @@ pub fn emit_specific_import_block( export_sets.clone(), source_indices.clone(), module_index.clone(), - ) == def_mod.clone()) + ) + .as_str() + == def_mod.clone().as_str()) { __result.push(n); } @@ -5811,13 +5440,13 @@ pub fn emit_specific_import_block( Rc::new({ let mut __result = Vec::new(); for l in type_direct_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } __result }), - if (other_direct_line.clone() != "".to_string()) { + if (other_direct_line.clone().as_str() != "".to_string().as_str()) { Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) @@ -5837,7 +5466,9 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => { + (found.clone().as_str() == p.clone().as_str()) + } None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -5848,7 +5479,9 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => { + (found.clone().as_str() == p.clone().as_str()) + } None => false, }, } { @@ -5887,15 +5520,15 @@ pub fn emit_specific_import_block( __result.push({ let group = Rc::new({ let mut __result = Vec::new(); for p in remote_parent_list.clone().iter().cloned() { if { let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => false, }, } { __result.push(n); } } __result }).first().cloned(); match rep_variant.clone() { - Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()) == def_mod.clone()), - None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()) == def_mod.clone()), + Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()).as_str() == def_mod.clone().as_str()), + None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()).as_str() == def_mod.clone().as_str()), } } { __result.push(p); } } __result }); if ((group.clone().len() as i64) > 0) { @@ -5916,7 +5549,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -5927,7 +5560,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -5963,7 +5596,10 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == parent.clone()), + Some(found) => { + (found.clone().as_str() + == parent.clone().as_str()) + } None => { match reexport_variant_parent_in_import_module( n.clone(), @@ -5976,7 +5612,8 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib module_index.clone(), ) { Some(found) => { - (found.clone() == parent.clone()) + (found.clone().as_str() + == parent.clone().as_str()) } None => match find_variant_parent( type_summaries.clone(), @@ -6055,7 +5692,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib if ({ let mut __found = false; for p in parent_list.clone().iter().cloned() { - if (p.clone() == en.clone()) { + if (p.clone().as_str() == en.clone().as_str()) { __found = true; break; } @@ -6089,7 +5726,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in main_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -6098,7 +5735,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in variant_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -6222,7 +5859,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { } pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: String) -> bool { - (((rust_pub_use_module_name(line.clone()) == mod_name) + (((rust_pub_use_module_name(line.clone()).as_str() == mod_name.as_str()) && v1_rt::contains(line.clone(), "::{".to_string())) && (((v1_rt::contains( line.clone(), @@ -6255,7 +5892,9 @@ pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> b { let mod_name = rust_pub_use_module_name(line.clone()); let name = rust_pub_use_singleton_name(line.clone()); - if ((mod_name.clone() == "".to_string()) || (name.clone() == "".to_string())) { + if ((mod_name.clone().as_str() == "".to_string().as_str()) + || (name.clone().as_str() == "".to_string().as_str())) + { false } else { { @@ -6280,14 +5919,17 @@ pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone() == "".to_string()) || ((names.clone().len() as i64) == 0)) { + if ((mod_name.clone().as_str() == "".to_string().as_str()) + || ((names.clone().len() as i64) == 0)) + { false } else { { let mut __found = false; for other in lines.iter().cloned() { - if (((((other.clone() != line.clone()) - && (rust_pub_use_module_name(other.clone()) == mod_name.clone())) + if (((((other.clone().as_str() != line.clone().as_str()) + && (rust_pub_use_module_name(other.clone()).as_str() + == mod_name.clone().as_str())) && v1_rt::contains(other.clone(), "::{".to_string())) && ((rust_pub_use_braced_names(other.clone()).len() as i64) > (names.clone().len() as i64))) @@ -6326,7 +5968,9 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> Rc> { let exact = unique_strings(Rc::new({ let mut __result = Vec::new(); for line in lines.iter().cloned() { - if (line.clone() != "".to_string()) { + if (line.clone().as_str() != "".to_string().as_str()) { __result.push(line); } } @@ -6439,7 +6083,8 @@ pub fn emit_imports( let mut __result = Vec::new(); for imp in imports.clone().iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - == import_module.clone()) + .as_str() + == import_module.clone().as_str()) { __result.push(imp); } @@ -6509,7 +6154,8 @@ pub fn emit_imports( source_indices.clone(), module_index.clone(), ); - if (specific_block.clone() != "".to_string()) { + if (specific_block.clone().as_str() != "".to_string().as_str()) + { v1_rt::concat( v1_rt::concat(wildcard_line.clone(), "\n".to_string()), specific_block.clone(), @@ -6639,74 +6285,44 @@ pub fn emit_typed_item( && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { rust_nominal_identity_carrier_def(item_text.clone()) + } else if is_zero_param_self_referential_opaque_decl( + item.clone(), + env.source_indices.clone(), + ) { + emit_zero_param_phantom_opaque_struct(item.clone(), env.source_indices.clone()) } else { - if is_zero_param_self_referential_opaque_decl( - item.clone(), - env.source_indices.clone(), - ) { - emit_zero_param_phantom_opaque_struct( - item.clone(), - env.source_indices.clone(), - ) - } else { - match rust_seed_host_numeric_alias( - item_text.clone(), - emit_info.corpus_repr.clone(), - ) { - Some(host) => v1_rt::concat( + 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(), - rust_items().type_alias_keyword.clone(), - ), - " ".to_string(), - ), - item_text.clone(), + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), ), - " = ".to_string(), + " ".to_string(), ), - host.clone(), + item_text.clone(), ), - ";".to_string(), + " = ".to_string(), ), - None => v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), - ), - " ".to_string(), - ), - item_text.clone(), - ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - Rc::new(vec![]), - shared_types, - emit_info.corpus_repr.clone(), - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), - ), - ), - ";".to_string(), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + Rc::new(vec![]), + shared_types, + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), ), - } - } + ), + ";".to_string(), + ) } } else { if is_type_decl_item(item.clone(), env.source_indices.clone()) { @@ -6715,11 +6331,19 @@ pub fn emit_typed_item( { rust_nominal_identity_carrier_def(item_text.clone()) } else { - match rust_seed_host_container_base( + if is_emittable_parametric_type_alias_item( + item.clone(), item_text.clone(), - emit_info.corpus_repr.clone(), + env.source_indices.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), ) { - Some(host) => { + { let type_params = emit_type_params( item.params.clone(), env.source_indices.clone(), @@ -6727,113 +6351,53 @@ pub fn emit_typed_item( let generic_names = item_generic_param_names( item.clone(), env.source_indices.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( - rust_visibility_prefix(), - rust_items() - .type_alias_keyword - .clone(), - ), - " ".to_string(), - ), - item_text.clone(), - ), - type_params, - ), - " = ".to_string(), - ), - host.clone(), - ), - "<".to_string(), - ), - generic_names.join(&", ".to_string()), - ), - ">;".to_string(), - ) - } - None => { - if is_emittable_parametric_type_alias_item( - item.clone(), - item_text.clone(), - env.source_indices.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - ) { - { - let type_params = emit_type_params( - item.params.clone(), - env.source_indices.clone(), - ); - let generic_names = item_generic_param_names( - item.clone(), - env.source_indices.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( - rust_visibility_prefix(), - rust_items() - .type_alias_keyword - .clone(), - ), - " ".to_string(), - ), - item_text.clone(), + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), ), - type_params, + " ".to_string(), ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - generic_names, - shared_types, - emit_info.corpus_repr.clone(), - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + item_text.clone(), ), + type_params, ), - ";".to_string(), - ) - } - } else { - if is_parametric_opaque_type_decl_item( - item.clone(), - env.source_indices.clone(), - ) { - emit_parametric_phantom_opaque_struct( - item.clone(), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + generic_names, + shared_types, env.source_indices.clone(), - ) - } else { - "".to_string() - } - } + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), + ) } + } else if is_parametric_opaque_type_decl_item( + item.clone(), + env.source_indices.clone(), + ) { + emit_parametric_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + "".to_string() } } } else { @@ -6877,7 +6441,6 @@ pub fn emit_typed_item( owned_bindings: v1_rt::rc_empty_set::(), 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(), @@ -6932,17 +6495,11 @@ pub fn emit_typed_item( item.clone(), registry.clone(), shared_types, - emit_info.corpus_repr.clone(), env.clone(), ) } else { if is_resource_def_item(item.clone()) { - emit_resource_def( - item.clone(), - shared_types, - emit_info.corpus_repr.clone(), - env.clone(), - ) + emit_resource_def(item.clone(), shared_types, env.clone()) } else { v1_rt::concat( v1_rt::concat( @@ -6973,7 +6530,9 @@ pub fn needs_box_wrapping( if v1_rt::set_contains(&shared_types, name.clone()) { break false; } else { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()).as_str() + != name.clone().as_str()) + { break false; } else { break v1_rt::set_contains(&recursive_types, name.clone()); @@ -7024,11 +6583,12 @@ pub fn is_function_type_param(param: Rc) -> bool { Some(inf) => is_type_variable(inf.clone()), None => false, }; - let same_source_span = (((param.span.clone().file.clone() - == type_expr.span.clone().file.clone()) + let same_source_span = (((param.span.clone().file.clone().as_str() + == type_expr.span.clone().file.clone().as_str()) && (param.span.clone().start.clone() == type_expr.span.clone().start.clone())) && (param.span.clone().end.clone() == type_expr.span.clone().end.clone())); - (((param.name.clone() != "".to_string()) && (param.name.clone() == type_expr.name.clone())) + (((param.name.clone().as_str() != "".to_string().as_str()) + && (param.name.clone().as_str() == type_expr.name.clone().as_str())) && (type_expr_is_var || same_source_span)) } } @@ -7149,10 +6709,11 @@ pub fn emit_type_def_from_connective( Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; - let validations = if (policy_validation.clone() == "".to_string()) { + let validations = if (policy_validation.clone().as_str() == "".to_string().as_str()) + { rename_validations.clone() } else { - if (rename_validations.clone() == "".to_string()) { + if (rename_validations.clone().as_str() == "".to_string().as_str()) { policy_validation.clone() } else { v1_rt::concat( @@ -7179,7 +6740,7 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), emit_info, ); - if (validations.clone() == "".to_string()) { + if (validations.clone().as_str() == "".to_string().as_str()) { enum_text } else { v1_rt::concat( @@ -7192,73 +6753,6 @@ pub fn emit_type_def_from_connective( } } -pub fn type_node_mentions_name( - n: Rc, - target: String, - source_indices: Rc>>, -) -> bool { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - if (authored_name_at(source_indices.clone(), n.clone()) == target.clone()) { - true - } else { - { - let mut __found = false; - for c in n.children.clone().iter().cloned() { - if type_node_mentions_name(c.clone(), target.clone(), source_indices.clone()) { - __found = true; - break; - } - } - __found - } - } - }) -} - -pub fn struct_unused_param_names( - generic_param_names: Rc>, - children: Rc>>, - source_indices: Rc>>, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for p in generic_param_names.iter().cloned() { - if !{ - let mut __found = false; - for child in children.clone().iter().cloned() { - if type_node_mentions_name( - field_node_type_expr(child.clone()), - p.clone(), - source_indices.clone(), - ) { - __found = true; - break; - } - } - __found - } { - __result.push(p); - } - } - __result - }) -} - -pub fn rust_phantom_marker_inner(unused: Rc>) -> String { - if ((unused.clone().len() as i64) == 1) { - unused.clone().join(&", ".to_string()) - } else { - v1_rt::concat( - v1_rt::concat("(".to_string(), unused.clone().join(&", ".to_string())), - ")".to_string(), - ) - } -} - -pub fn rust_phantom_field_name() -> String { - "_phantom".to_string() -} - pub fn emit_struct_from_children( name: String, type_params: String, @@ -7281,7 +6775,9 @@ pub fn emit_struct_from_children( name.clone(), children.clone(), env.source_indices.clone(), - ) != "".to_string()) + ) + .as_str() + != "".to_string().as_str()) { rust_nominal_ord_derives_for_shape( name.clone(), @@ -7333,32 +6829,7 @@ pub fn emit_struct_from_children( } __result }); - let unused_params = struct_unused_param_names( - generic_param_names.clone(), - children.clone(), - env.source_indices.clone(), - ); - let all_field_lines = if ((unused_params.clone().len() as i64) > 0) { - v1_rt::concat( - field_lines, - Rc::new(vec![v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(" ".to_string(), rust_visibility_prefix()), - rust_phantom_field_name(), - ), - ": std::marker::PhantomData<".to_string(), - ), - rust_phantom_marker_inner(unused_params.clone()), - ), - ">,".to_string(), - )]), - ) - } else { - field_lines - }; - let fields_str = all_field_lines.join(&"\n".to_string()); + let fields_str = field_lines.join(&"\n".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7392,7 +6863,6 @@ pub fn emit_struct_from_children( pub fn render_rust_type_with_applied_binding( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match find_property( @@ -7402,93 +6872,51 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if outer_name.as_str() != "" + && n.connective.clone() == Connective::NoConnective + && (n.children.clone().len() as i64) == 0 { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if (((outer_name.clone() != "".to_string()) - && (n.connective.clone() == Connective::NoConnective)) - && ((n.children.clone().len() as i64) == 0)) - { - if (outer_name.clone() != applied_name) { - render_rust_shared_type_if_needed( - outer_name.clone(), - 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.clone(), - shared_types.clone(), - ) - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types.clone(), - corpus_repr, - source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::< - String, - Rc>>, - >( - ), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), - ) - } - } + if outer_name != applied_name { + render_rust_shared_type_if_needed( + 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, + shared_types.clone(), + ) } else { render_rust_applied_type_shared( applied.clone(), Rc::new(vec![]), - shared_types.clone(), - corpus_repr, + shared_types, source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::< - String, - Rc>>, - >(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types, + source_indices.clone(), + ) } } else { - render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr, - source_indices.clone(), - ) + render_rust_type(n.clone(), shared_types, source_indices.clone()) } } - None => render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr, - source_indices.clone(), - ), + None => render_rust_type(n.clone(), shared_types, source_indices.clone()), } } pub fn render_rust_field_type_with_applied_binding( field: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -7502,7 +6930,6 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( field.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } else { @@ -7515,24 +6942,17 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( authored_type.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } else { if ((authored_type.connective.clone() == Connective::NoConnective) && ((authored_type.children.clone().len() as i64) > 0)) { - render_rust_type( - authored_type.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ) + render_rust_type(authored_type.clone(), shared_types, source_indices.clone()) } else { render_rust_type_with_applied_binding( resolved_type(field.clone()), shared_types, - corpus_repr, source_indices.clone(), ) } @@ -7570,7 +6990,6 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7583,7 +7002,6 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( authored_child_type.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7596,7 +7014,6 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7643,7 +7060,6 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7651,7 +7067,6 @@ pub fn emit_struct_field_from_child( None => render_rust_type( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ), } @@ -7660,7 +7075,6 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7668,7 +7082,7 @@ pub fn emit_struct_field_from_child( } } }; - let generic_ty = if (struct_name == "PartialFunction".to_string()) { + let generic_ty = if (struct_name.as_str() == "PartialFunction".to_string().as_str()) { rust_normalize_partial_function_field_type_text(rust_normalize_witness_type_text(ty)) } else { ty @@ -7699,8 +7113,8 @@ pub fn emit_struct_field_from_child( let rename_attr = match Rc::new({ let mut __result = Vec::new(); for p in child.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), env.source_indices.clone()) - == "from_key".to_string()) + if (field_init_node_name_at(p.clone(), env.source_indices.clone()).as_str() + == "from_key".to_string().as_str()) { __result.push(p); } @@ -7745,18 +7159,19 @@ pub fn emit_rust_field_definition( { let snake = to_snake(authored.clone()); let emitted = emit_ident(authored.clone(), RenderTarget::Rust); - let keyword_rename = - if ((emitted.clone() != snake.clone()) && (rename_attr.clone() == "".to_string())) { + let keyword_rename = if ((emitted.clone().as_str() != snake.clone().as_str()) + && (rename_attr.clone().as_str() == "".to_string().as_str())) + { + v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), + snake.clone(), + ), + "\")]\n".to_string(), + ) + } else { + "".to_string() + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7826,7 +7241,7 @@ pub fn emit_enum_from_children( __result }); let variants_str = variant_lines.join(&"\n".to_string()); - let tag_line = if (serde_policy.enum_attr.clone() == "".to_string()) { + let tag_line = if (serde_policy.enum_attr.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) @@ -7868,7 +7283,7 @@ pub fn emit_enum_from_children( env.clone(), emit_info.clone(), ); - if (accessor_impl.clone() == "".to_string()) { + if (accessor_impl.clone().as_str() == "".to_string().as_str()) { enum_def } else { v1_rt::concat( @@ -7917,7 +7332,9 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> if !({ let mut __found = false; for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()) == fname.clone()) { + if (authored_name(env.clone(), f.clone()).as_str() + == fname.clone().as_str()) + { __found = true; break; } @@ -7981,7 +7398,8 @@ pub fn emit_enum_shared_accessors( match Rc::new({ let mut __result = Vec::new(); for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()) == fname.clone()) + if (authored_name(env.clone(), f.clone()).as_str() + == fname.clone().as_str()) { __result.push(f); } @@ -7994,7 +7412,6 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "".to_string(), @@ -8010,7 +7427,7 @@ pub fn emit_enum_shared_accessors( { let mut __all = true; for t in types.clone().iter().cloned() { - if !(t.clone() == first_type.clone()) { + if !(t.clone().as_str() == first_type.clone().as_str()) { __all = false; break; } @@ -8033,7 +7450,9 @@ pub fn emit_enum_shared_accessors( let ty = match Rc::new({ let mut __result = Vec::new(); for f in first_fielded.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()) == fname.clone()) { + if (authored_name(env.clone(), f.clone()).as_str() + == fname.clone().as_str()) + { __result.push(f); } } @@ -8045,7 +7464,6 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "compile_error!(\"enum shared accessor missing field metadata\")" @@ -8191,7 +7609,8 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) - && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)) == prefix.clone())) + && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)).as_str() + == prefix.clone().as_str())) { Some(v1_rt::substring( &value, @@ -8213,7 +7632,9 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { &value, (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), v1_rt::string_length(&value), - ) == suffix.clone())) + ) + .as_str() + == suffix.clone().as_str())) { Some(v1_rt::substring( &value, @@ -8226,120 +7647,67 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } -pub fn string_index_of_from(mut haystack: String, mut needle: String, mut pos: i64) -> Option { - loop { - if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { - break None; - } else { - if (v1_rt::substring( - &haystack, - pos.clone(), - (pos.clone() + v1_rt::string_length(&needle)), - ) == needle.clone()) - { - break Some(pos.clone()); - } else { - { - let __tco_0 = (pos + 1); - pos = __tco_0; - continue; - } - } - } - } -} - -pub fn string_index_of(haystack: String, needle: String) -> Option { - string_index_of_from(haystack, needle, 0) -} - pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, ) -> Option { - if (policy.error_message.clone() != None) { - None - } else { - match policy.rename_style.clone() { - Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { - { - let without_prefix = match policy.rename_prefix.clone() { - 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.clone()) { - Some(stripped) => stripped.clone(), - None => return None, - } - } - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } - } else { - None - } + if policy.error_message.is_some() { + return None; + } + match policy.rename_style.clone() { + Some(style) => { + if style.as_str() == "StripAffixAndSnakeCase" { + let without_prefix = match policy.rename_prefix.clone() { + Some(prefix) => match string_without_prefix(authored, prefix) { + Some(stripped) => stripped, + 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, + }, + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } else { + None } - None => { - if v1_rt::contains( - policy.enum_attr.clone(), - "rename_all = \"snake_case\"".to_string(), - ) { - Some(to_snake(authored)) - } else { - if (((policy.enum_attr.clone() == "".to_string()) - && (policy.rename_prefix.clone() == None)) - && (policy.rename_suffix.clone() == None)) - { - Some(authored) - } else { - None - } - } + } + None => { + if policy.enum_attr.contains("rename_all = \"snake_case\"") { + Some(to_snake(authored)) + } else if policy.enum_attr.is_empty() + && policy.rename_prefix.is_none() + && policy.rename_suffix.is_none() + { + Some(authored) + } else { + None } } } } -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)); - 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(), - )), - None => None, - } - } - None => None, - } - } +pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { + let needle = "tag = \""; + let start = policy.enum_attr.find(needle)? + needle.len(); + let rest = &policy.enum_attr[start..]; + let end = rest.find('"')?; + Some(rest[..end].to_string()) } -pub fn policy_is_untagged(policy: Rc) -> bool { - v1_rt::contains(policy.enum_attr.clone(), "untagged".to_string()) +pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { + policy.enum_attr.contains("untagged") } -pub fn policy_is_string_variant(policy: Rc) -> bool { - (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) - && (policy.rename_prefix.clone() == None)) - && (policy.rename_suffix.clone() == None)) - && (policy.rename_style.clone() == None)) +pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { + !policy.enum_attr.contains("tag =") + && policy.rename_prefix.is_none() + && policy.rename_suffix.is_none() + && policy.rename_style.is_none() } pub fn wire_variant_rename_attr_for_policy( @@ -8349,9 +7717,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.as_str() == "StripAffixAndSnakeCase" { v1_rt::concat( - v1_rt::concat(" #[serde(rename = \"".to_string(), tag.clone()), + v1_rt::concat(" #[serde(rename = \"".to_string(), tag), "\")]\n".to_string(), ) } else { @@ -8370,7 +7738,7 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { @@ -8433,7 +7801,7 @@ pub fn variant_rename_validations_for_policy( .iter() .cloned() { - if (text.clone() != "".to_string()) { + if (text.clone().as_str() != "".to_string().as_str()) { __result.push(text); } } @@ -8475,7 +7843,6 @@ pub fn enum_variant_field_type_node( pub fn render_variant_payload_type( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if ((n.connective.clone() == Connective::NoConnective) @@ -8489,7 +7856,6 @@ pub fn render_variant_payload_type( __result.push(render_rust_type( child_type_node(c.clone()), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), )); } @@ -8508,12 +7874,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.clone(), source_indices.clone()) } } @@ -8525,7 +7886,9 @@ 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.clone(), source_indices).as_str() == "0".to_string().as_str()) + } None => false, } } @@ -8560,7 +7923,8 @@ pub fn emit_variant_from_child( env.source_indices.clone(), ); let tuple_style = (positional_payload.clone() - || (serde_policy.enum_attr.clone() == "#[serde(untagged)]".to_string())); + || (serde_policy.enum_attr.clone().as_str() + == "#[serde(untagged)]".to_string().as_str())); if tuple_style { match child.children.clone().first().cloned() { Some(f) => { @@ -8581,14 +7945,12 @@ pub fn emit_variant_from_child( render_variant_payload_type( type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { render_rust_type( type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) }; @@ -8601,7 +7963,6 @@ pub fn emit_variant_from_child( render_rust_type_with_applied_binding( type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -8652,7 +8013,6 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8706,7 +8066,6 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8763,78 +8122,71 @@ pub fn emit_fn_def( shared_types: Rc>, emit_info: Rc, ) -> String { + if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { + if rust_emit_faithful_text_carrier(scope.type_env.source_indices.clone()) { + return seam_fn; + } else { + return "".to_string(); + } + } { - let si = scope.type_env.clone().source_indices.clone(); - 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() - } else { - "".to_string() - } - } - None => { - let type_params = function_type_params(params.clone()); - let value_params = function_value_params(params.clone()); - if function_type_params_have_collision(type_params.clone()) { - return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); - } - let type_params_str = emit_type_params(type_params.clone(), si.clone()); - let generic_param_names = Rc::new({ - let mut __result = Vec::new(); - for p in type_params.clone().iter().cloned() { - __result.push(generic_param_name_at(p.clone(), si.clone())); - } - __result - }); - let params_str = emit_params( + let si = scope.type_env.clone().source_indices.clone(); + let type_params = function_type_params(params.clone()); + let value_params = function_value_params(params.clone()); + if function_type_params_have_collision(type_params.clone()) { + return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); + } + let type_params_str = emit_type_params(type_params.clone(), si.clone()); + let generic_param_names = Rc::new({ + let mut __result = Vec::new(); + for p in type_params.clone().iter().cloned() { + __result.push(generic_param_name_at(p.clone(), si.clone())); + } + __result + }); + let params_str = emit_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + emit_info.read_only_params.clone(), + scope.type_env.clone(), + ); + let ret_str = emit_inferred( + inferred, + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + scope.type_env.clone(), + ); + let body_scope = build_params_scope(scope.clone(), value_params.clone()); + let depth = 0; + let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); + let needs_stacker = + (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) + && (use_tco.clone() == false)); + if use_tco.clone() { + { + let tco_params_str = emit_tco_params( value_params.clone(), generic_param_names.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), si.clone(), - emit_info.read_only_params.clone(), - emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); - let ret_str = emit_inferred( - inferred, - generic_param_names.clone(), + let body_str = emit_typed_tco_body( + body.clone(), + name.clone(), + value_params.clone(), + registry.clone(), + body_scope, + (depth.clone() + 1), shared_types.clone(), - emit_info.corpus_repr.clone(), - si.clone(), - emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + emit_info.clone(), ); - let body_scope = build_params_scope(scope.clone(), value_params.clone()); - let depth = 0; - let use_tco = - is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); - let needs_stacker = - (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) - && (use_tco.clone() == false)); - if use_tco.clone() { - { - let tco_params_str = emit_tco_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - emit_info.corpus_repr.clone(), - 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.clone(), - registry.clone(), - body_scope, - (depth.clone() + 1), - shared_types.clone(), - emit_info.clone(), - ); - let kw = rust_items().func_keyword.clone(); + let kw = rust_items().func_keyword.clone(); + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -8845,53 +8197,49 @@ pub fn emit_fn_def( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - kw, - ), - " ".to_string(), - ), - emit_ident( - name.clone(), - RenderTarget::Rust, - ), + rust_visibility_prefix(), + kw, ), - type_params_str, + " ".to_string(), + ), + emit_ident( + name.clone(), + RenderTarget::Rust, ), - "(".to_string(), ), - tco_params_str, + type_params_str, ), - ")".to_string(), + "(".to_string(), ), - ret_str, + tco_params_str, ), - " {\n".to_string(), + ")".to_string(), ), - make_indent((depth.clone() + 1)), + ret_str, ), - body_str, + " {\n".to_string(), ), - "\n}".to_string(), - ) - } - } else { - emit_fn_def_non_tco( - name.clone(), - type_params_str, - params_str, - ret_str, - body.clone(), - registry.clone(), - body_scope, - depth.clone(), - shared_types.clone(), - emit_info.clone(), - needs_stacker, - ) - } + make_indent((depth.clone() + 1)), + ), + body_str, + ), + "\n}".to_string(), + ) } + } else { + emit_fn_def_non_tco( + name.clone(), + type_params_str, + params_str, + ret_str, + body.clone(), + registry.clone(), + body_scope, + depth.clone(), + shared_types.clone(), + emit_info.clone(), + needs_stacker, + ) } } } @@ -9051,16 +8399,13 @@ pub fn emit_func_def( uses.clone(), service_names, shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), - emit_info.variant_to_enum.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(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -9274,9 +8619,7 @@ pub fn emit_tco_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9287,9 +8630,7 @@ pub fn emit_tco_params( p.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9303,9 +8644,7 @@ pub fn emit_tco_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9315,19 +8654,15 @@ pub fn emit_tco_param( authored.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, env, ) }; @@ -9352,10 +8687,8 @@ pub fn emit_func_params( uses: Rc>>, service_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9366,10 +8699,8 @@ pub fn emit_func_params( p.clone(), Rc::new(vec![]), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9389,7 +8720,6 @@ pub fn emit_func_params( render_rust_type( resource_use_resource(u.clone()), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), ), )); @@ -9414,13 +8744,12 @@ pub fn emit_func_params( pub fn emit_func_inferred( inferred: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { v1_rt::concat( v1_rt::concat( " -> Result<".to_string(), - render_rust_type(inferred, shared_types, corpus_repr, source_indices), + render_rust_type(inferred, shared_types, source_indices), ), ", Box>".to_string(), ) @@ -9430,10 +8759,8 @@ pub fn emit_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9444,10 +8771,8 @@ pub fn emit_params( p.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9461,20 +8786,16 @@ pub fn render_rust_param_sig_type( param: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param); + let type_node = resolved_type(param.clone()); render_rust_fn_sig_type( type_node, generic_param_names, shared_types, - corpus_repr, source_indices, - variant_to_enum, env, ) } @@ -9484,9 +8805,7 @@ pub fn emit_rust_param_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -9498,9 +8817,7 @@ pub fn emit_rust_param_type( param_node_type_expr(p.clone()), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9512,9 +8829,7 @@ pub fn emit_rust_param_type( rt.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -9535,10 +8850,8 @@ pub fn emit_rust_param_type( n.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), + env, ) } } @@ -9547,10 +8860,8 @@ pub fn emit_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9560,19 +8871,15 @@ pub fn emit_param( authored.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, env, ) }; @@ -9591,9 +8898,7 @@ pub fn emit_inferred( inferred: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -9602,9 +8907,7 @@ pub fn emit_inferred( inferred, generic_param_names, shared_types, - corpus_repr, source_indices, - variant_to_enum, env, ), ) @@ -9687,11 +8990,12 @@ pub fn collect_field_binding_string_guards( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone() == "0".to_string()) { - v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) - } else { - v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) - }; + let field_path = + if (fb_name.clone().as_str() == "0".to_string().as_str()) { + v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) + } else { + v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) + }; let bind_name = pattern_string_binding_name(field_path.clone()); match positional_payload_string_guard( fb_pat.clone(), @@ -9710,7 +9014,7 @@ pub fn collect_field_binding_string_guards( nested_path.clone(), source_indices.clone(), ); - if (nested.clone() == "".to_string()) { + if (nested.clone().as_str() == "".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![nested.clone()]) @@ -9741,7 +9045,7 @@ pub fn collect_pattern_string_guards( field_bindings: fbs, .. } => { - if (((n.clone() == "Present".to_string()) + if (((n.clone().as_str() == "Present".to_string().as_str()) && (parent.clone().as_deref() == Some("Optional".to_string()).as_deref())) && ((fbs.clone().len() as i64) == 1)) { @@ -9784,7 +9088,8 @@ pub fn collect_pattern_string_guards( match fbs.clone().first().cloned() { Some(fb) => { if (field_binding_name_at(fb.clone(), source_indices.clone()) - == "0".to_string()) + .as_str() + == "0".to_string().as_str()) { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( @@ -9925,7 +9230,7 @@ pub fn pattern_parent_enum( type_summaries: Rc>>, ) -> Option { { - let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) + let scrut_is_known_enum = ((scrut_type.clone().as_str() != "".to_string().as_str()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { parent_enum.clone() @@ -9968,12 +9273,13 @@ pub fn unique_variant_parent( } pub fn is_optional_variant_name(name: String) -> bool { - ((name.clone() == "Present".to_string()) || (name.clone() == "Absent".to_string())) + ((name.clone().as_str() == "Present".to_string().as_str()) + || (name.clone().as_str() == "Absent".to_string().as_str())) } pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent.clone() == "Optional".to_string()), + Some(parent) => (parent.clone().as_str() == "Optional".to_string().as_str()), None => false, } } @@ -10031,7 +9337,7 @@ pub fn emit_variant_pattern( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone() == "Present".to_string()) { + if (name.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -10044,7 +9350,7 @@ pub fn emit_variant_pattern( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone() == "Witness".to_string()) { + if (parent.clone().as_str() == "Witness".to_string().as_str()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -10056,7 +9362,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10087,8 +9393,8 @@ pub fn emit_variant_pattern( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()) - == "0".to_string()) + if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() + == "0".to_string().as_str()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10291,24 +9597,25 @@ pub fn emit_variant_pattern( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone() == "0".to_string()) { + let field_path = if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -10319,13 +9626,15 @@ pub fn emit_variant_pattern( } } else { { - let is_shorthand = - match (*fb_pat.clone()).clone() { - MatchPattern::Bind { - name: n, .. - } => (n.clone() == fb_name.clone()), - _ => false, - }; + let is_shorthand = match (*fb_pat.clone()) + .clone() + { + MatchPattern::Bind { name: n, .. } => { + (n.clone().as_str() + == fb_name.clone().as_str()) + } + _ => false, + }; if is_shorthand.clone() { emit_ident( fb_name.clone(), @@ -10333,25 +9642,26 @@ pub fn emit_variant_pattern( ) } else { { - let field_path = if (fb_name.clone() - == "0".to_string()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let pat_str = emit_pattern( fb_pat.clone(), field_path.clone(), @@ -10422,7 +9732,7 @@ pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc { let mut __found = false; for name in rc_analysis.ref_bound_fields.clone().iter().cloned() { - if (name.clone() == field_name.clone()) { + if (name.clone().as_str() == field_name.clone().as_str()) { __found = true; break; } @@ -10458,7 +9768,8 @@ pub fn analyze_rc_pattern( ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone() == "Present".to_string()) + matches_option_rc_variant: ((n.clone().as_str() + == "Present".to_string().as_str()) && inner.matches_rc_variant.clone()), needs_rc_pattern: inner.needs_rc_pattern.clone(), ref_bound_fields: Rc::new(vec![]), @@ -10488,17 +9799,18 @@ pub fn analyze_rc_pattern( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let inner_scrut = if (fb_name.clone() == "0".to_string()) { - positional_payload_scrut_type( - resolved_parent.clone(), - n.clone(), - fb.clone(), - emit_info.clone(), - source_indices.clone(), - ) - } else { - "".to_string() - }; + let inner_scrut = + if (fb_name.clone().as_str() == "0".to_string().as_str()) { + positional_payload_scrut_type( + resolved_parent.clone(), + n.clone(), + fb.clone(), + emit_info.clone(), + source_indices.clone(), + ) + } else { + "".to_string() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -10658,7 +9970,7 @@ pub fn emit_variant_pattern_rc_aware( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone() == "Present".to_string()) { + if (name.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -10671,7 +9983,7 @@ pub fn emit_variant_pattern_rc_aware( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone() == "Witness".to_string()) { + if (parent.clone().as_str() == "Witness".to_string().as_str()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -10683,7 +9995,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10722,8 +10034,8 @@ pub fn emit_variant_pattern_rc_aware( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()) - == "0".to_string()) + if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() + == "0".to_string().as_str()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10958,24 +10270,25 @@ pub fn emit_variant_pattern_rc_aware( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone() == "0".to_string()) { + let field_path = if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -11003,7 +10316,10 @@ pub fn emit_variant_pattern_rc_aware( { MatchPattern::Bind { name: n, .. - } => (n.clone() == fb_name.clone()), + } => { + (n.clone().as_str() + == fb_name.clone().as_str()) + } _ => false, }; if is_shorthand.clone() { @@ -11013,26 +10329,26 @@ pub fn emit_variant_pattern_rc_aware( ) } else { { - let field_path = if (fb_name - .clone() - == "0".to_string()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let inner_analysis = analyze_rc_pattern( fb_pat.clone(), @@ -11140,7 +10456,7 @@ pub fn rc_pattern_preludes( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - if (fb_name.clone() == "0".to_string()) { + if (fb_name.clone().as_str() == "0".to_string().as_str()) { { let payload_scrut = positional_payload_scrut_type( resolved_parent.clone(), @@ -11163,7 +10479,9 @@ pub fn rc_pattern_preludes( source_indices.clone(), emit_info.clone(), ); - if (inner_preludes.clone() == "".to_string()) { + if (inner_preludes.clone().as_str() + == "".to_string().as_str()) + { Rc::new(vec![]) } else { Rc::new(vec![inner_preludes.clone()]) @@ -11248,7 +10566,7 @@ pub fn explicit_record_struct_name( false }; let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { + if (nname.clone().as_str() == "__EmitTypeCacheMiss".to_string().as_str()) { type_name.clone() } else { if n_is_error { @@ -11319,8 +10637,119 @@ pub fn apply_field_clone(expr: String, field: String) -> String { ) } -pub fn clone_iterator_suffix() -> String { - sharing_for_target(RenderTarget::Rust).clone_suffix.clone() +pub fn clone_iterator_suffix() -> String { + sharing_for_target(RenderTarget::Rust).clone_suffix.clone() +} + +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + match v1_rt::map_get(&variant_to_enum, name.clone()) { + Some(parent) => { + if parent.as_str() != "" { + v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name + } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { + carrier + } else { + rust_qualify_type_leaf_name(name, variant_to_enum) + } +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if (child.children.clone().len() as i64) == 0 { + let vname = authored_name(env.clone(), child.clone()); + if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + v1_rt::concat(vname, ";".to_string()), + )); + } + } + } + __result + }) + .join("\n") +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut names: Vec = Vec::new(); + for item in items.iter().cloned() { + if is_type_def_item(item.clone()) + && item + .children + .clone() + .iter() + .all(|c| c.children.clone().len() as i64 == 0) + { + for child in item.children.clone().iter().cloned() { + if (child.children.clone().len() as i64) == 0 { + let vname = authored_name(env.clone(), child.clone()); + if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !names.iter().any(|n| n == &vname) + { + names.push(vname); + } + } + } + } + } + names + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env.clone()) + .iter() + .cloned() + { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + v1_rt::concat(vname, ";".to_string()), + )); + } + __result + }) + .join("\n") } pub fn effective_variant_parent( @@ -11333,7 +10762,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()) { + if (p.clone().as_str() != "".to_string().as_str()) { Some(p.clone()) } else { None @@ -11346,7 +10775,8 @@ pub fn effective_variant_parent( None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); - if (((rt.ident_span.clone() != None) && (rt_name.clone() != name.clone())) + if (((rt.ident_span.clone() != None) + && (rt_name.clone().as_str() != name.clone().as_str())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), name.clone(), @@ -11373,10 +10803,14 @@ pub fn emit_var_ref( emit_info: Rc, source_indices: Rc>>, ) -> String { - if ((name.clone() == "none".to_string()) || (name.clone() == "None".to_string())) { + if ((name.clone().as_str() == "none".to_string().as_str()) + || (name.clone().as_str() == "None".to_string().as_str())) + { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((name.clone() == "true".to_string()) || (name.clone() == "false".to_string())) { + if ((name.clone().as_str() == "true".to_string().as_str()) + || (name.clone().as_str() == "false".to_string().as_str())) + { emit_keyword(name.clone(), RenderTarget::Rust) } else { { @@ -11392,9 +10826,9 @@ pub fn emit_var_ref( let ref_str = match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(name.clone()) - && (enum_name.clone() == "Optional".to_string())) + && (enum_name.clone().as_str() == "Optional".to_string().as_str())) { - if (name.clone() == "Present".to_string()) { + if (name.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -11484,10 +10918,14 @@ pub fn emit_typed_expr_base( .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { + if ((n.clone().as_str() == "none".to_string().as_str()) + || (n.clone().as_str() == "None".to_string().as_str())) + { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { + if ((n.clone().as_str() == "true".to_string().as_str()) + || (n.clone().as_str() == "false".to_string().as_str())) + { emit_keyword(n.clone(), RenderTarget::Rust) } else { { @@ -11501,9 +10939,10 @@ pub fn emit_typed_expr_base( match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(n.clone()) - && (enum_name.clone() == "Optional".to_string())) + && (enum_name.clone().as_str() + == "Optional".to_string().as_str())) { - if (n.clone() == "Present".to_string()) { + if (n.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -11552,35 +10991,6 @@ pub fn emit_typed_expr_base( } } -pub fn field_access_field_is_boxed( - base: Rc, - field: String, - scope: Rc, - shared_types: Rc>, - emit_info: Rc, -) -> bool { - { - let base_struct = expand_type_for_field_access( - resolved_type(base), - scope.type_env.clone(), - scope.module_name.clone(), - ); - match find_child_named( - base_struct, - field, - scope.type_env.clone().source_indices.clone(), - ) { - Some(field_child) => needs_box_wrapping( - resolved_type(field_child.clone()), - emit_info.recursive_type_set.clone(), - shared_types, - scope.type_env.clone().source_indices.clone(), - ), - None => false, - } - } -} - pub fn emit_typed_field_access( base: Rc, field: String, @@ -11643,7 +11053,9 @@ pub fn emit_typed_field_access( if (authored_name_at( scope.type_env.clone().source_indices.clone(), pair.1.clone(), - ) == field.clone()) + ) + .as_str() + == field.clone().as_str()) { __result.push(pair); } @@ -11713,39 +11125,19 @@ pub fn emit_typed_field_access( } _ => false, }; - let field_is_boxed = field_access_field_is_boxed( - base.clone(), - field.clone(), - scope.clone(), - shared_types.clone(), - emit_info.clone(), - ); - if field_is_boxed { + if base_is_owned { v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(*".to_string(), base_str), - ".".to_string(), - ), - emit_ident(field.clone(), RenderTarget::Rust), - ), - ").clone()".to_string(), + v1_rt::concat(base_str, ".".to_string()), + emit_ident(field.clone(), RenderTarget::Rust), ) } else { - if base_is_owned { + apply_type_template1( + sharing.clone_value.clone(), v1_rt::concat( v1_rt::concat(base_str, ".".to_string()), emit_ident(field.clone(), RenderTarget::Rust), - ) - } else { - apply_type_template1( - sharing.clone_value.clone(), - v1_rt::concat( - v1_rt::concat(base_str, ".".to_string()), - emit_ident(field.clone(), RenderTarget::Rust), - ), - ) - } + ), + ) } } }, @@ -11800,7 +11192,7 @@ pub fn type_needs_rc_seen( } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); if (normed.inferred.clone() != None) { - let next_seen = if (canonical.clone() == "".to_string()) { + let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11813,12 +11205,12 @@ pub fn type_needs_rc_seen( continue; } } else { - if ((canonical.clone() != "".to_string()) + if ((canonical.clone().as_str() != "".to_string().as_str()) && emit_map_has(seen.clone(), canonical.clone())) { break false; } else { - let next_seen = if (canonical.clone() == "".to_string()) { + let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11856,7 +11248,6 @@ pub fn rust_runtime_bridge_name(function_name: String) -> String { pub fn rust_empty_map_value_type_str( map_type: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match map_type.children.clone().get(1 as usize).cloned() { @@ -11864,10 +11255,9 @@ pub fn rust_empty_map_value_type_str( let rendered = render_rust_type( child_type_node(value_child.clone()), shared_types, - corpus_repr, source_indices, ); - if (rendered.clone() == "".to_string()) { + if (rendered.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { rendered.clone() @@ -11880,7 +11270,6 @@ pub fn rust_empty_map_value_type_str( pub fn rust_empty_map_kv_type_str( map_type: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -11888,7 +11277,6 @@ pub fn rust_empty_map_kv_type_str( Some(key_child) => render_rust_type( child_type_node(key_child.clone()), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), ), None => "".to_string(), @@ -11896,10 +11284,11 @@ pub fn rust_empty_map_kv_type_str( let val_str = rust_empty_map_value_type_str( map_type.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), ); - if ((key_str.clone() != "".to_string()) && (val_str.clone() != "".to_string())) { + if ((key_str.clone().as_str() != "".to_string().as_str()) + && (val_str.clone().as_str() != "".to_string().as_str())) + { v1_rt::concat( v1_rt::concat(key_str.clone(), ", ".to_string()), val_str.clone(), @@ -11927,12 +11316,12 @@ pub fn rust_btree_set_element_ord_eligible( ) -> bool { { let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); - (((((((elem_name.clone() == "String".to_string()) - || (elem_name.clone() == "Int".to_string())) - || (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.clone().as_str() == "String".to_string().as_str()) + || (elem_name.clone().as_str() == "Int".to_string().as_str())) + || (elem_name.clone().as_str() == "Bool".to_string().as_str())) + || (elem_name.clone().as_str() == "Unit".to_string().as_str())) + || (elem_name.clone().as_str() == "Secret".to_string().as_str())) + || (elem_name.clone().as_str() == "Bytes".to_string().as_str())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -12005,7 +11394,7 @@ pub fn emit_rust_empty_set_expr( shared_types, source_indices.clone(), ); - if (elem_str.clone() != "".to_string()) { + if (elem_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_set::<".to_string(), @@ -12308,70 +11697,36 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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.module_name.clone(), - ); - let variant_name = match tn.clone() { - Some(n) => n.clone(), - None => "".to_string(), - }; - let peeled_type_name = if (((parent_enum.clone() == None) - && (expanded_rt.connective.clone() == Connective::Conj)) - && (expanded_rt.ident_span.clone() != None)) - { - { - let concrete = authored_name_at(si.clone(), expanded_rt.clone()); - if ((concrete.clone() != "".to_string()) - && (concrete.clone() != variant_name.clone())) - { - Some(concrete.clone()) - } else { - tn.clone() - } - } - } else { - tn.clone() - }; let raw = emit_typed_record_lit( - peeled_type_name, + tn.clone(), fs, parent_enum.clone(), - expanded_rt.clone(), + resolved_type(expr.clone()), registry, scope.clone(), depth, shared_types.clone(), emit_info.clone(), ); + let si = scope.type_env.clone().source_indices.clone(); + let variant_name = match tn.clone() { + Some(n) => n.clone(), + None => "".to_string(), + }; let rc_name = match parent_enum.clone() { Some(en) => en.clone(), None => match contextual_variant_parent( variant_name.clone(), parent_enum.clone(), - expanded_rt.clone(), + resolved_type(expr.clone()), emit_info.clone(), si.clone(), ) { - Some(p) => p.clone(), - None => { - 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.clone() - } else { - variant_name.clone() - } - } + Some(p) => p, + None => variant_name.clone(), }, }; - if ((rc_name.clone() != "".to_string()) + if ((rc_name.clone().as_str() != "".to_string().as_str()) && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) @@ -12806,7 +12161,7 @@ pub fn contextual_variant_parent( None => { let rt_name = authored_name_at(source_indices, resolved_type.clone()); if (((resolved_type.ident_span.clone() != None) - && (rt_name.clone() != variant_name.clone())) + && (rt_name.clone().as_str() != variant_name.clone().as_str())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), variant_name.clone(), @@ -12849,7 +12204,7 @@ pub fn emit_discriminant_call_lowering( scope.clone(), depth, shared_types.clone(), - emit_info.clone(), + emit_info, 1024, ); let ty_name = @@ -12911,7 +12266,7 @@ pub fn emit_discriminant_call_lowering( ), "\"".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ",".to_string(), @@ -12948,7 +12303,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ) } } @@ -12957,7 +12312,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ), } } @@ -12974,16 +12329,15 @@ pub fn emit_typed_call_expr( emit_info: Rc, ) -> String { { - let call_str = if (func.clone() == "empty_map".to_string()) { + let call_str = if (func.clone().as_str() == "empty_map".to_string().as_str()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( ret_type.clone(), shared_types, - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone() != "".to_string()) { + if (kv_type_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -13000,7 +12354,7 @@ pub fn emit_typed_call_expr( .to_string(), } } else { - if (func.clone() == "empty_set".to_string()) { + if (func.clone().as_str() == "empty_set".to_string().as_str()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( @@ -13044,7 +12398,7 @@ pub fn emit_typed_call( emit_info: Rc, ) -> String { { - if (func.clone() == "get".to_string()) { + if (func.clone().as_str() == "get".to_string().as_str()) { { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); @@ -13088,7 +12442,7 @@ pub fn emit_typed_call( return get_result; } } - if (func.clone() == "with".to_string()) { + if (func.clone().as_str() == "with".to_string().as_str()) { { let with_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); if ((with_args.clone().len() as i64) == 0) { @@ -13186,7 +12540,7 @@ pub fn emit_typed_call( } } } - if (func.clone() == "to_string".to_string()) { + if (func.clone().as_str() == "to_string".to_string().as_str()) { { let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -13207,24 +12561,45 @@ pub fn emit_typed_call( ), ").to_string()".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ), None => "compile_error!(\"to_string call missing value argument\")".to_string(), }; return ts_result; } } - if (func.clone() == "utf8_decode_bytes".to_string()) { + if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { { let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let decode_result = match decode_args.first().cloned() { - Some(value_arg) => v1_rt::concat(v1_rt::concat("String::from_utf8(".to_string(), emit_typed_expr(arg_value(value_arg.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)), ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?".to_string()), - None => "compile_error!(\"utf8_decode_bytes call missing value argument\")".to_string(), -}; + Some(value_arg) => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "String::from_utf8(".to_string(), + emit_typed_expr( + arg_value(value_arg.clone()), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ), + ), + ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" + .to_string(), + ), + "".to_string(), + ), + None => { + "compile_error!(\"utf8_decode_bytes call missing value argument\")" + .to_string() + } + }; return decode_result; } } - if (func.clone() == "discriminant".to_string()) { + if (func.clone().as_str() == "discriminant".to_string().as_str()) { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { @@ -13243,10 +12618,10 @@ pub fn emit_typed_call( return disc_result; } } - let collection_scope = if ((((func.clone() == "map".to_string()) - || (func.clone() == "filter".to_string())) - || (func.clone() == "flat_map".to_string())) - || (func.clone() == "fold".to_string())) + let collection_scope = if ((((func.clone().as_str() == "map".to_string().as_str()) + || (func.clone().as_str() == "filter".to_string().as_str())) + || (func.clone().as_str() == "flat_map".to_string().as_str())) + || (func.clone().as_str() == "fold".to_string().as_str())) { { let call_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -13421,7 +12796,8 @@ 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.clone() + && (func.clone().as_str() == "concat".to_string().as_str())) && ((all_args.clone().len() as i64) > 2)) { emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) @@ -13477,11 +12853,12 @@ pub fn fill_default_args( let is_provided = { let mut __found = false; for n in provided_names.clone().iter().cloned() { - if (n.clone() + if (n.clone().as_str() == param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - )) + ) + .as_str()) { __found = true; break; @@ -13594,7 +12971,7 @@ pub fn emit_nested_rt_concat( break acc.clone(); } Some(arg) => { - let next_acc = if (acc.clone() == "".to_string()) { + let next_acc = if (acc.clone().as_str() == "".to_string().as_str()) { arg.clone() } else { v1_rt::concat( @@ -13794,7 +13171,6 @@ pub fn emit_typed_slice( pub fn collection_element_type( receiver_type: Option>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match receiver_type.as_deref().cloned() { @@ -13820,7 +13196,6 @@ pub fn collection_element_type( render_rust_type( elem_node.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } @@ -13877,7 +13252,6 @@ pub fn lambda_param_type_strs( param_nodes: Rc>>, fallback_types: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> Rc> { Rc::new({ @@ -13917,7 +13291,6 @@ pub fn lambda_param_type_strs( Some(render_rust_type( param_type.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), )) } @@ -13981,7 +13354,6 @@ pub fn emit_typed_collection_lambda( pn.clone(), Rc::new(vec![elem_type_str]), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13992,7 +13364,7 @@ pub fn emit_typed_collection_lambda( lambda_scope, depth, shared_types.clone(), - emit_info.clone(), + emit_info, 1024, ); v1_rt::concat( @@ -14006,7 +13378,7 @@ pub fn emit_typed_collection_lambda( scope.clone(), depth, shared_types.clone(), - emit_info.clone(), + emit_info, 1024, ), } @@ -14038,9 +13410,10 @@ pub fn emit_typed_fold_lambda( .skip(1 as usize) .collect::>(), ); - let safe_acc_type = if (((acc_type_str.clone() == "Rc>".to_string()) - || (acc_type_str.clone() == "Vec<()>".to_string())) - || (acc_type_str.clone() == "Option<()>".to_string())) + let safe_acc_type = if (((acc_type_str.clone().as_str() + == "Rc>".to_string().as_str()) + || (acc_type_str.clone().as_str() == "Vec<()>".to_string().as_str())) + || (acc_type_str.clone().as_str() == "Option<()>".to_string().as_str())) { "_".to_string() } else { @@ -14072,7 +13445,6 @@ pub fn emit_typed_fold_lambda( Rc::new(vec![]), fallback_types, shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -14090,7 +13462,7 @@ pub fn emit_typed_fold_lambda( Some(n) => n.clone(), None => "".to_string(), }; - let needs_unwrap = ((acc_name.clone() != "".to_string()) + let needs_unwrap = ((acc_name.clone().as_str() != "".to_string().as_str()) && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); if needs_unwrap { { @@ -14162,7 +13534,6 @@ pub fn emit_rust_fold_method_call( let elem_type_str = collection_element_type( receiver.inferred.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { @@ -14314,7 +13685,6 @@ pub fn emit_rust_fold_method_call( ), 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(), }), None => emit_info.clone(), } @@ -14347,7 +13717,6 @@ pub fn emit_rust_fold_method_call( owned_bindings: emit_info.owned_bindings.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(), }), None => emit_info.clone(), } @@ -14361,7 +13730,6 @@ pub fn emit_rust_fold_method_call( let acc_type_str = render_rust_type( acc_type_node.clone(), shared_types.clone(), - 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) { @@ -14422,19 +13790,18 @@ pub fn emit_rust_fold_method_call( arg_value(init_arg.clone()), scope.type_env.clone().source_indices.clone(), ); - if ((((init_func.clone() == "empty_map".to_string()) - && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str.clone() != "".to_string())) + if ((((init_func.clone().as_str() == "empty_map".to_string().as_str()) + && (acc_type_str.clone().as_str() != "_".to_string().as_str())) + && (acc_type_str.clone().as_str() != "".to_string().as_str())) && !acc_has_unit_child.clone()) { { let kv_type_str = rust_empty_map_kv_type_str( acc_type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone() != "".to_string()) { + if (kv_type_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -14447,12 +13814,13 @@ pub fn emit_rust_fold_method_call( } } } else { - if (init_func.clone() == "empty_map".to_string()) { + if (init_func.clone().as_str() == "empty_map".to_string().as_str()) { "Rc::new(HashMap::new()) /* BRIDGE: fold empty_map accumulator type unresolved */".to_string() } else { - if ((((init_func.clone() == "empty_set".to_string()) - && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str.clone() != "".to_string())) + if ((((init_func.clone().as_str() + == "empty_set".to_string().as_str()) + && (acc_type_str.clone().as_str() != "_".to_string().as_str())) + && (acc_type_str.clone().as_str() != "".to_string().as_str())) && !acc_has_unit_child.clone()) { emit_rust_empty_set_expr( @@ -14461,7 +13829,8 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func.clone() == "empty_set".to_string()) { + if (init_func.clone().as_str() == "empty_set".to_string().as_str()) + { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -14558,7 +13927,6 @@ pub fn emit_rust_sort_by_method_call( render_rust_type( elem.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ) } else { @@ -14583,7 +13951,7 @@ pub fn emit_rust_sort_by_method_call( let iter_str = apply_type_template1(sharing.iter_owned.clone(), recv_str); let a_clone = apply_type_template1(sharing.clone_value.clone(), "a".to_string()); let b_clone = apply_type_template1(sharing.clone_value.clone(), "b".to_string()); - if (elem_type_str.clone() == "_".to_string()) { + if (elem_type_str.clone().as_str() == "_".to_string().as_str()) { 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()) @@ -15070,7 +14438,9 @@ pub fn emit_rust_first_method_call( if (expr_method_name_at( receiver.clone(), scope.type_env.clone().source_indices.clone(), - ) == "skip".to_string()) + ) + .as_str() + == "skip".to_string().as_str()) { { let skip_recv = method_receiver(receiver.clone()); @@ -15308,7 +14678,9 @@ pub fn emit_typed_method_call( if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), - ) == "serde_json::Value".to_string()) + ) + .as_str() + == "serde_json::Value".to_string().as_str()) { __result.push(p); } @@ -15405,7 +14777,7 @@ pub fn emit_typed_method_call( scope.type_env.clone().source_indices.clone(), method_def.clone(), ); - if (method_name.clone() == "fold".to_string()) { + if (method_name.clone().as_str() == "fold".to_string().as_str()) { emit_rust_fold_method_call( method_call_node, fold_accumulator_type.clone(), @@ -15419,7 +14791,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "sort_by".to_string()) { + if (method_name.clone().as_str() == "sort_by".to_string().as_str()) { emit_rust_sort_by_method_call( receiver.clone(), args.clone(), @@ -15430,7 +14802,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "map".to_string()) { + if (method_name.clone().as_str() == "map".to_string().as_str()) { emit_rust_map_method_call( receiver.clone(), args.clone(), @@ -15444,7 +14816,9 @@ pub fn emit_typed_method_call( match Rc::new({ let mut __result = Vec::new(); for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone() == method_name.clone()) { + if (s.method_name.clone().as_str() + == method_name.clone().as_str()) + { __result.push(s); } } @@ -15464,7 +14838,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ), None => { - if (method_name.clone() == "get".to_string()) { + if (method_name.clone().as_str() == "get".to_string().as_str()) + { emit_rust_get_method_call( receiver.clone(), args.clone(), @@ -15475,7 +14850,9 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "with".to_string()) { + if (method_name.clone().as_str() + == "with".to_string().as_str()) + { emit_rust_with_method_call( receiver.clone(), args.clone(), @@ -15486,8 +14863,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() - == "string_contains".to_string()) + if (method_name.clone().as_str() + == "string_contains".to_string().as_str()) { emit_rust_generic_method_call( "string_contains".to_string(), @@ -15501,7 +14878,9 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "concat".to_string()) { + if (method_name.clone().as_str() + == "concat".to_string().as_str()) + { { let recv_str = emit_typed_expr( receiver.clone(), @@ -15538,7 +14917,8 @@ pub fn emit_typed_method_call( ) } } else { - if (method_name.clone() == "first".to_string()) + if (method_name.clone().as_str() + == "first".to_string().as_str()) { emit_rust_first_method_call( receiver.clone(), @@ -15929,8 +15309,8 @@ pub fn emit_typed_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone() != "".to_string()) - && (arm_guard_str.clone() != "".to_string())) + let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) + && (arm_guard_str.clone().as_str() != "".to_string().as_str())) { v1_rt::concat( v1_rt::concat( @@ -15940,10 +15320,10 @@ pub fn emit_typed_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone() != "".to_string()) { + if (field_guards.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone() != "".to_string()) { + if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -16205,13 +15585,14 @@ pub fn wrap_rust_record_field_value( field_name: String, ) -> String { { - let is_bounded_lattice_field = (struct_name.clone() == "BoundedLattice".to_string()); + let is_bounded_lattice_field = + (struct_name.clone().as_str() == "BoundedLattice".to_string().as_str()); if rust_record_field_needs_fn_rc(scope.clone(), struct_name.clone(), field_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone() == "meet".to_string()) - || (field_name.clone() == "join".to_string()))) + && ((field_name.clone().as_str() == "meet".to_string().as_str()) + || (field_name.clone().as_str() == "join".to_string().as_str()))) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -16225,8 +15606,8 @@ pub fn wrap_rust_record_field_value( v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone() == "top".to_string()) - || (field_name.clone() == "bottom".to_string()))) + && ((field_name.clone().as_str() == "top".to_string().as_str()) + || (field_name.clone().as_str() == "bottom".to_string().as_str()))) { v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { @@ -16257,13 +15638,16 @@ pub fn is_already_optional( binding_kind: binding_kind, .. } => { - if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) + if (((n.clone().as_str() == "Present".to_string().as_str()) + || (n.clone().as_str() == "Absent".to_string().as_str())) && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true } else { - if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { + if ((n.clone().as_str() == "none".to_string().as_str()) + || (n.clone().as_str() == "None".to_string().as_str())) + { true } else { match texpr.inferred.clone().as_deref().cloned() { @@ -16287,8 +15671,8 @@ pub fn is_already_optional( } => match tn { Some(name) => { ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) - && ((name.clone() == "Present".to_string()) - || (name.clone() == "Absent".to_string()))) + && ((name.clone().as_str() == "Present".to_string().as_str()) + || (name.clone().as_str() == "Absent".to_string().as_str()))) } None => false, }, @@ -16510,7 +15894,7 @@ pub fn emit_field_value_with_context( Some(en) => en.clone(), None => variant_name.clone(), }; - if ((rc_name.clone() != "".to_string()) + if ((rc_name.clone().as_str() != "".to_string().as_str()) && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) @@ -16762,15 +16146,10 @@ pub fn emit_typed_record_lit( false }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); - if (((((resolved_type.ident_span.clone() != None) - && (rt_name.clone() != tn.clone())) + if ((((resolved_type.ident_span.clone() != None) + && (rt_name.clone().as_str() != tn.clone().as_str())) && !rt_is_type_var) - && (rt_name.clone() != "Error".to_string())) - && variant_belongs_to_enum( - emit_info.type_summaries.clone(), - tn.clone(), - rt_name.clone(), - )) + && (rt_name.clone().as_str() != "Error".to_string().as_str())) { Some(rt_name.clone()) } else { @@ -16782,7 +16161,7 @@ pub fn emit_typed_record_lit( && (is_optional_parent(parent_enum.clone()) || is_optional_parent(effective_parent.clone()))); let rust_tn = if optional_variant.clone() { - if (tn.clone() == "Present".to_string()) { + if (tn.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -16801,7 +16180,8 @@ pub fn emit_typed_record_lit( None => rust_tn, } }; - if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) + if ((optional_variant.clone() + && (tn.clone().as_str() == "Present".to_string().as_str())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -16841,8 +16221,8 @@ pub fn emit_typed_record_lit( let is_positional_ctor = (((fields.clone().len() as i64) == 1) && match fields.clone().first().cloned() { Some(f) => { - (field_init_node_name_at(f.clone(), si.clone()) - == "0".to_string()) + (field_init_node_name_at(f.clone(), si.clone()).as_str() + == "0".to_string().as_str()) } None => false, }); @@ -17004,13 +16384,18 @@ pub fn emit_typed_record_lit( &ftm, fname.clone(), ) { - Some(ft) => match rust_zero_value( - ft.clone(), - emit_info.corpus_repr.clone(), - ) { - Some(_) => true, - None => false, - }, + Some(ft) => { + match rust_zero_value( + ft.clone(), + scope + .type_env + .source_indices + .clone(), + ) { + Some(_) => true, + None => false, + } + } None => false, }; (has_zv.clone() @@ -17034,7 +16419,10 @@ pub fn emit_typed_record_lit( Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { match v1_rt::map_get(&ftm, fname.clone()) { - Some(ft) => match rust_zero_value(ft.clone(), emit_info.corpus_repr.clone()) { + Some(ft) => match rust_zero_value( + ft.clone(), + scope.type_env.source_indices.clone(), + ) { Some(zv) => Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": ".to_string()), zv.clone()), ",".to_string())]), None => Rc::new(vec![]), }, @@ -17050,48 +16438,7 @@ pub fn emit_typed_record_lit( } None => Rc::new(vec![]), }; - let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), - tn.clone(), - ) { - Some(struct_decl) => { - let is_struct = (struct_decl.connective.clone() - == Connective::Conj); - let pnames = Rc::new({ - let mut __result = Vec::new(); - for p in struct_decl.params.clone().iter().cloned() - { - __result.push(generic_param_name_at( - p.clone(), - si.clone(), - )); - } - __result - }); - let unused = struct_unused_param_names( - pnames, - struct_decl.children.clone(), - si.clone(), - ); - let has_unused = ((unused.len() as i64) > 0); - if (is_struct && has_unused) { - Rc::new(vec![v1_rt::concat( - v1_rt::concat( - " ".to_string(), - rust_phantom_field_name(), - ), - ": std::marker::PhantomData,".to_string(), - )]) - } else { - Rc::new(vec![]) - } - } - None => Rc::new(vec![]), - }; - let all_field_strs = v1_rt::concat( - v1_rt::concat(field_strs, default_strs), - phantom_strs, - ); + let all_field_strs = v1_rt::concat(field_strs, default_strs); let fields_str = all_field_strs.join(&"\n".to_string()); let raw = v1_rt::concat( v1_rt::concat( @@ -17111,15 +16458,18 @@ pub fn emit_typed_record_lit( } } -pub fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> Option { - if (type_name.clone() == "Int".to_string()) { +pub fn rust_zero_value( + type_name: String, + source_indices: Rc>>, +) -> Option { + if (type_name.clone().as_str() == "Int".to_string().as_str()) { Some("0".to_string()) } else { - if (type_name.clone() == "Bool".to_string()) { + if (type_name.clone().as_str() == "Bool".to_string().as_str()) { Some("false".to_string()) } else { - if (type_name.clone() == "String".to_string()) { - if corpus_repr_is_faithful(corpus_repr) { + if (type_name.clone().as_str() == "String".to_string().as_str()) { + if rust_emit_faithful_text_carrier(source_indices) { Some( "crate::v2_std_algebra::freemonoid_empty::()" .to_string(), @@ -17187,8 +16537,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str, - emit_info.corpus_repr.clone(), + l_str.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ")".to_string(), @@ -17201,8 +16551,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str, - emit_info.corpus_repr.clone(), + r_str.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ")".to_string(), @@ -17234,8 +16584,12 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str, - emit_info.corpus_repr.clone(), + l_str.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), ), ), " ".to_string(), @@ -17245,8 +16599,8 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str, - emit_info.corpus_repr.clone(), + r_str.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ")".to_string(), @@ -17379,7 +16733,7 @@ pub fn emit_typed_string_interp( .iter() .cloned() { - if (a.clone() != "".to_string()) { + if (a.clone().as_str() != "".to_string().as_str()) { __result.push(a); } } @@ -17388,7 +16742,7 @@ pub fn emit_typed_string_interp( if ((args.clone().len() as i64) == 0) { emit_rust_host_to_dag_string_via_seam( v1_rt::concat(v1_rt::concat("\"".to_string(), fmt_str), "\"".to_string()), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { { @@ -17404,7 +16758,7 @@ pub fn emit_typed_string_interp( ), ")".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ) } } @@ -17565,7 +16919,9 @@ pub fn emit_tco_init_stmt( if (param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) == n.clone()) + ) + .as_str() + == n.clone().as_str()) { __found = true; break; @@ -17919,7 +17275,9 @@ pub fn emit_rust_tco_let( if (param_node_name_at( p.clone(), frame.scope.clone().type_env.clone().source_indices.clone(), - ) == n.clone()) + ) + .as_str() + == n.clone().as_str()) { __found = true; break; @@ -18206,8 +17564,8 @@ pub fn emit_typed_tco_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone() != "".to_string()) - && (arm_guard_str.clone() != "".to_string())) + let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) + && (arm_guard_str.clone().as_str() != "".to_string().as_str())) { v1_rt::concat( v1_rt::concat( @@ -18217,10 +17575,10 @@ pub fn emit_typed_tco_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone() != "".to_string()) { + if (field_guards.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone() != "".to_string()) { + if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -18290,7 +17648,10 @@ 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.clone()).as_str() + == var_name.clone().as_str()) + } _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -18477,7 +17838,6 @@ pub fn emit_service_def( item: Rc, registry: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -18497,7 +17857,6 @@ pub fn emit_service_def( op_children.clone(), registry, shared_types, - corpus_repr, env.clone(), item.clone(), ); @@ -18577,7 +17936,6 @@ pub fn emit_service_impl( op_children: Rc>>, registry: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18600,7 +17958,6 @@ pub fn emit_service_impl( registry.clone(), (depth.clone() + 1), shared_types.clone(), - corpus_repr.clone(), env.clone(), service_item.clone(), )); @@ -18666,7 +18023,7 @@ pub fn emit_service_new_method( }, None => "".to_string(), }; - let base_url_default = if (from_config.clone() != "".to_string()) { + let base_url_default = if (from_config.clone().as_str() != "".to_string().as_str()) { from_config.clone() } else { if fs.has_rest.clone() { @@ -18691,7 +18048,7 @@ pub fn emit_service_new_method( } else { "".to_string() }; - if (from_fallback.clone() != "".to_string()) { + if (from_fallback.clone().as_str() != "".to_string().as_str()) { from_fallback.clone() } else { "http://localhost".to_string() @@ -18759,7 +18116,7 @@ pub fn emit_auth_source_ctor( ) -> String { match (*source_expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { - Some(variant) => if (variant.clone() == "EnvVar".to_string()) { + Some(variant) => if (variant.clone().as_str() == "EnvVar".to_string().as_str()) { 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()) }, @@ -18803,7 +18160,6 @@ pub fn emit_operation_method( registry: Rc>>, depth: i64, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18824,17 +18180,15 @@ pub fn emit_operation_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), - v1_rt::rc_empty_map::(), - env.clone().clone(), + env.clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone() == "".to_string()) { + let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -18842,7 +18196,6 @@ pub fn emit_operation_method( let ret_type = render_rust_type( resolved_type(op_node.clone()), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), ); let eff_transport = effective_operation_transport(op_node.clone(), transport); @@ -18857,7 +18210,6 @@ pub fn emit_operation_method( op_node.clone(), env.source_indices.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), ); let mock_props = Rc::new({ @@ -18881,7 +18233,6 @@ pub fn emit_operation_method( op_node.clone(), env.clone(), shared_types.clone(), - corpus_repr.clone(), ); let body = v1_rt::concat( v1_rt::concat( @@ -18963,7 +18314,6 @@ pub fn emit_dry_run_branch_from_props( op_node: Rc, env: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, ) -> String { { let log_line = v1_rt::concat( @@ -19001,7 +18351,7 @@ let prelude = match wire_opt.clone() { 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()) +v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let __rest_wire: ".to_string(), render_rust_type(wire_ty, shared_types, source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) } }, None => v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()), @@ -19020,7 +18370,7 @@ let raw = match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed dry-run: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for mock field: ".to_string()), ch_name.clone()), "\");".to_string()), }; @@ -19043,6 +18393,13 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } } } else { + // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single + // authority): compile_error! -> panic! in the dry-run missing-fixture branch. + // Applied by hand because regen-fixpoint is temporarily broken (§7 hole). + // DISSOLUTION lane: bright-stag's adhoc-1bdd0259-2e3 (re-repair the hole + add a + // regen-equals-committed CI drift-gate). When it lands, a clean regen reproduces + // this line from the .dag — delete this hand-patch; the dissolution check is + // regen-output == this mirror modulo HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19067,7 +18424,6 @@ pub fn emit_transport_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { if is_rest_transport(transport.clone(), source_indices.clone()) { @@ -19080,7 +18436,6 @@ pub fn emit_transport_call( op_node, source_indices.clone(), shared_types, - corpus_repr, env, ) } else { @@ -19092,7 +18447,6 @@ pub fn emit_transport_call( depth, inferred, op_node, - corpus_repr, source_indices.clone(), ) } else { @@ -19114,7 +18468,6 @@ pub fn emit_rest_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19129,11 +18482,7 @@ pub fn emit_rest_call( http_method, source_indices.clone(), ); - let query_line = emit_rest_query_line( - transport.clone(), - corpus_repr.clone(), - source_indices.clone(), - ); + let query_line = emit_rest_query_line(transport.clone(), source_indices.clone()); let body_line = emit_rest_body_line(transport.clone(), source_indices.clone()); let headers = transport_headers(transport.clone(), source_indices.clone()); let header_lines = Rc::new({ @@ -19166,7 +18515,6 @@ pub fn emit_rest_call( transport.clone(), source_indices.clone(), shared_types, - corpus_repr.clone(), env, ); let all_lines = Rc::new({ @@ -19181,7 +18529,7 @@ pub fn emit_rest_call( .iter() .cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -19426,7 +18774,6 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_rest_query_line( transport: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match transport_query(transport, source_indices.clone()) { @@ -19449,7 +18796,7 @@ pub fn emit_rest_query_line( RenderTarget::Rust, source_indices.clone(), ), - corpus_repr.clone(), + source_indices.clone(), ), ), ")".to_string(), @@ -19512,7 +18859,7 @@ pub fn has_response_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 9) { false } else { - (v1_rt::substring(&name, 0, 9) == "response_".to_string()) + (v1_rt::substring(&name, 0, 9).as_str() == "response_".to_string().as_str()) } } @@ -19523,8 +18870,8 @@ pub fn child_from_key( match Rc::new({ let mut __result = Vec::new(); for p in ch.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "from_key".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "from_key".to_string().as_str()) { __result.push(p); } @@ -19578,8 +18925,8 @@ pub fn has_response_200_property( { let mut __found = false; for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "response_200".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "response_200".to_string().as_str()) { __found = true; break; @@ -19597,8 +18944,8 @@ pub fn operation_response_200_resolved_type( match Rc::new({ let mut __result = Vec::new(); for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "response_200".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "response_200".to_string().as_str()) { __result.push(p); } @@ -19617,7 +18964,7 @@ pub fn operation_response_200_resolved_type( source_indices.clone(), normalize_access_type_node(v.clone()), ); - if (type_name.clone() == "".to_string()) { + if (type_name.clone().as_str() == "".to_string().as_str()) { None } else { lookup_type_by_name(env, type_name.clone()) @@ -19635,7 +18982,7 @@ pub fn is_json_wire_declaration_type( ) -> bool { { let n = authored_name_at(source_indices, normalize_access_type_node(t)); - if (n.clone() == "Json".to_string()) { + if (n.clone().as_str() == "Json".to_string().as_str()) { true } else { { @@ -19646,7 +18993,7 @@ pub fn is_json_wire_declaration_type( .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone() == "Json".to_string()), + Some(last) => (last.clone().as_str() == "Json".to_string().as_str()), None => false, } } @@ -19697,7 +19044,7 @@ pub fn wire_child_for_segment( Some(k) => k.clone(), None => authored.clone(), }; - (wire_key.clone() == seg.clone()) + (wire_key.clone().as_str() == seg.clone().as_str()) } { __result.push(ch); } @@ -19813,7 +19160,7 @@ pub fn emit_wire_struct_path_chain( .iter() .cloned() { - if (s.clone() != "".to_string()) { + if (s.clone().as_str() != "".to_string().as_str()) { __result.push(s); } } @@ -19879,7 +19226,6 @@ pub fn emit_json_value_extract( var_name: String, from_path: String, dag_type_name: String, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19901,8 +19247,9 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); - let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name.clone()); - let accessor = if (dag_type_name.clone() == "String".to_string()) { + let is_dag_string = dag_type_name.as_str() == "String"; + let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); + let accessor = if is_dag_string { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19910,7 +19257,7 @@ pub fn emit_json_value_extract( ".and_then(|v| v.as_str()).map(|s| ".to_string(), emit_rust_host_to_dag_string_via_seam( "s.to_string()".to_string(), - corpus_repr, + source_indices.clone(), ), ), ").ok_or(\"missing field: ".to_string(), @@ -19920,7 +19267,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "i64".to_string()) { + if (rust_type.clone().as_str() == "i64".to_string().as_str()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_i64()).ok_or(\"missing field: ".to_string(), @@ -19929,7 +19276,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "f64".to_string()) { + if (rust_type.clone().as_str() == "f64".to_string().as_str()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_f64()).ok_or(\"missing field: ".to_string(), @@ -19938,7 +19285,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "bool".to_string()) { + if (rust_type.clone().as_str() == "bool".to_string().as_str()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -19975,7 +19322,6 @@ pub fn emit_from_key_extraction( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20013,7 +19359,6 @@ pub fn emit_from_key_extraction( render_rust_type( wire_ty, shared_types, - corpus_repr.clone(), source_indices.clone(), ), ), @@ -20043,7 +19388,7 @@ match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed response: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for output field: ".to_string()), ch_name.clone()), "\");".to_string()), } @@ -20098,7 +19443,8 @@ pub fn emit_plain_response_body( { let is_text = match transport_response_format(transport, source_indices.clone()) { Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) + (authored_name_at(source_indices.clone(), fmt.clone()).as_str() + == "Text".to_string().as_str()) } None => false, }; @@ -20115,7 +19461,6 @@ pub fn emit_response_code_handling( transport: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20135,7 +19480,6 @@ pub fn emit_response_code_handling( op_node.clone(), source_indices.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), ) } else { @@ -20153,7 +19497,6 @@ pub fn emit_response_code_handling( transport.clone(), source_indices.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), )); } @@ -20185,22 +19528,21 @@ pub fn emit_response_arm( transport: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 9, v1_rt::string_length(&name)); let is_success = if (v1_rt::string_length(&code_str) >= 1) { - (v1_rt::substring(&code_str, 0, 1) == "2".to_string()) + (v1_rt::substring(&code_str, 0, 1).as_str() == "2".to_string().as_str()) } else { false }; - let pattern = if (code_str.clone() == "nonzero".to_string()) { + let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { "_".to_string() } else { if ((v1_rt::string_length(&code_str) == 3) - && (v1_rt::substring(&code_str, 1, 3) == "xx".to_string())) + && (v1_rt::substring(&code_str, 1, 3).as_str() == "xx".to_string().as_str())) { { let prefix = v1_rt::substring(&code_str, 0, 1); @@ -20228,7 +19570,6 @@ pub fn emit_response_arm( op_node, source_indices.clone(), shared_types, - corpus_repr, env, ), ), @@ -20256,14 +19597,13 @@ pub fn has_exit_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5) == "exit_".to_string()) + (v1_rt::substring(&name, 0, 5).as_str() == "exit_".to_string().as_str()) } } pub fn emit_exit_code_handling( op_node: Rc, inferred: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -20283,8 +19623,8 @@ pub fn emit_exit_code_handling( let has_nonzero = { let mut __found = false; for p in exit_props.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "exit_nonzero".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "exit_nonzero".to_string().as_str()) { __found = true; break; @@ -20298,7 +19638,6 @@ pub fn emit_exit_code_handling( __result.push(emit_exit_arm( p.clone(), inferred.clone(), - corpus_repr.clone(), source_indices.clone(), )); } @@ -20307,7 +19646,16 @@ pub fn emit_exit_code_handling( let default_arm = if has_nonzero { "".to_string() } else { - v1_rt::concat(v1_rt::concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr.clone())), ") },".to_string()) + v1_rt::concat( + v1_rt::concat( + "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), + emit_rust_host_to_dag_string_via_seam( + "stderr".to_string(), + source_indices.clone(), + ), + ), + ") },".to_string(), + ) }; v1_rt::concat( v1_rt::concat( @@ -20330,18 +19678,17 @@ pub fn emit_exit_code_handling( pub fn emit_exit_arm( prop: Rc, inferred: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 5, v1_rt::string_length(&name)); - let pattern = if (code_str.clone() == "nonzero".to_string()) { + let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { "_".to_string() } else { code_str.clone() }; - let is_success = (code_str.clone() == "0".to_string()); + let is_success = (code_str.clone().as_str() == "0".to_string().as_str()); if is_success { v1_rt::concat( v1_rt::concat( @@ -20354,7 +19701,22 @@ pub fn emit_exit_arm( " },".to_string(), ) } else { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string()), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr)), ") },".to_string()) + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(" ".to_string(), pattern), + " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), + ), + emit_rust_host_to_dag_string_via_seam( + "stderr".to_string(), + source_indices.clone(), + ), + ), + ") },".to_string(), + ), + "".to_string(), + ) } } } @@ -20366,7 +19728,6 @@ pub fn emit_shell_call( depth: i64, inferred: Rc, op_node: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -20411,7 +19772,6 @@ pub fn emit_shell_call( emit_shell_argv_element( first_arg.clone(), optional_params.clone(), - corpus_repr.clone(), source_indices.clone(), ), ), @@ -20453,7 +19813,6 @@ pub fn emit_shell_call( emit_shell_argv_element( arg.clone(), optional_params.clone(), - corpus_repr.clone(), source_indices.clone(), ), ), @@ -20514,12 +19873,8 @@ pub fn emit_shell_call( let wait_line = "let output = output.wait_with_output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = emit_exit_code_handling( - op_node.clone(), - inferred, - corpus_repr.clone(), - source_indices.clone(), - ); + let return_line = + emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![ @@ -20539,12 +19894,8 @@ pub fn emit_shell_call( let output_line = " .output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = emit_exit_code_handling( - op_node.clone(), - inferred, - corpus_repr.clone(), - source_indices.clone(), - ); + let return_line = + emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![wd_line, output_line, check_line, return_line]), @@ -20558,7 +19909,6 @@ pub fn emit_shell_call( pub fn emit_shell_argv_element( arg: Rc, optional_params: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match (*arg.expr_data.clone()).clone() { @@ -20657,10 +20007,10 @@ pub fn emit_shell_argv_element( if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), - corpus_repr, + source_indices.clone(), ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), source_indices.clone()) } } _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), @@ -20727,7 +20077,7 @@ pub fn emit_shell_return( } __result }); - let lines = if (stderr_line.clone() != "".to_string()) { + let lines = if (stderr_line.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() @@ -20754,13 +20104,13 @@ pub fn emit_shell_return( pub fn emit_shell_channel_expr(channel: String, is_optional: bool) -> String { { - let base = if (channel.clone() == "exit_success".to_string()) { + let base = if (channel.clone().as_str() == "exit_success".to_string().as_str()) { "output.status.success()".to_string() } else { - if (channel.clone() == "stderr".to_string()) { + if (channel.clone().as_str() == "stderr".to_string().as_str()) { "stderr.clone()".to_string() } else { - if (channel.clone() == "stdout_lines".to_string()) { + if (channel.clone().as_str() == "stdout_lines".to_string().as_str()) { "Rc::new(stdout.lines().filter(|l| !l.is_empty()).map(|l| l.trim().to_string()).collect())".to_string() } else { "stdout.clone()".to_string() @@ -20832,7 +20182,6 @@ pub fn emit_local_call(op_name: String) -> String { pub fn emit_resource_def( item: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20855,7 +20204,6 @@ pub fn emit_resource_def( __result.push(emit_capability_method( c.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), )); } @@ -20886,7 +20234,6 @@ pub fn emit_resource_def( pub fn emit_capability_method( cap_node: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20905,17 +20252,15 @@ pub fn emit_capability_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), - v1_rt::rc_empty_map::(), - env.clone().clone(), + env.clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone() == "".to_string()) { + let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -20923,7 +20268,6 @@ pub fn emit_capability_method( let ret = render_rust_type( resolved_type(cap_node.clone()), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), ); let items = rust_items(); @@ -21012,11 +20356,10 @@ pub fn emit_data_def( let raw_ty_str = render_rust_type_with_applied_binding( render_type_node, shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) - || (raw_ty_str.clone() == "Rc".to_string())) + let ty_str = if ((raw_ty_str.clone().as_str() == "BoundedLattice".to_string().as_str()) + || (raw_ty_str.clone().as_str() == "Rc".to_string().as_str())) { match field_value_by_name( value.clone(), @@ -21028,10 +20371,12 @@ pub fn emit_data_def( scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); - if (top_type_name.clone() == "".to_string()) { + if (top_type_name.clone().as_str() == "".to_string().as_str()) { raw_ty_str.clone() } else { - if (raw_ty_str.clone() == "Rc".to_string()) { + if (raw_ty_str.clone().as_str() + == "Rc".to_string().as_str()) + { v1_rt::concat( v1_rt::concat( "Rc { let lattice_value = field_value_by_name( @@ -21334,31 +20678,38 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( + v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), - ), - ), "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), ), - emit_info.corpus_repr.clone(), + "\"".to_string(), ), + scope + .type_env + .clone() + .source_indices + .clone(), + ), + ), + v1_rt::concat( + v1_rt::concat( + ", ".to_string(), + val_str.clone(), ), - ", ".to_string(), + ");".to_string(), ), - val_str.clone(), ), - ");".to_string(), + "".to_string(), ) }); } @@ -21434,18 +20785,13 @@ pub fn emit_data_def_body( pub fn emit_test_file( module_name: String, projections: Rc>>, - corpus_repr: RustCorpusRepr, ) -> Rc { { let depth = 0; let test_fns = Rc::new({ let mut __result = Vec::new(); for p in projections.iter().cloned() { - __result.push(emit_operation_test( - p.clone(), - (depth.clone() + 1), - corpus_repr.clone(), - )); + __result.push(emit_operation_test(p.clone(), (depth.clone() + 1))); } __result }); @@ -21496,16 +20842,13 @@ pub fn emit_test_file( } } -pub fn rust_test_signature_comment( - projection: Rc, - corpus_repr: RustCorpusRepr, -) -> String { +pub fn rust_test_signature_comment(projection: Rc) -> String { { let stub_env = Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), + bindings: Rc::new(HashMap::new()), recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), + recursive_type_set: Rc::new(HashMap::new()), + inductive_fields: Rc::new(HashMap::new()), source_indices: projection.source_indices.clone(), intern_table: empty_intern_table(), }); @@ -21521,9 +20864,7 @@ pub fn rust_test_signature_comment( param_node_type_expr(p.clone()), Rc::new(vec![]), v1_rt::rc_empty_set::(), - corpus_repr.clone(), projection.source_indices.clone(), - v1_rt::rc_empty_map::(), stub_env.clone(), ), )); @@ -21560,11 +20901,7 @@ pub fn rust_test_signature_comment( } } -pub fn emit_operation_test( - projection: Rc, - depth: i64, - corpus_repr: RustCorpusRepr, -) -> String { +pub fn emit_operation_test(projection: Rc, depth: i64) -> String { { let test_name = rust_test_name(projection.clone()); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -21581,12 +20918,12 @@ pub fn emit_operation_test( __result }); let args_str = param_args.join(&", ".to_string()); - let call_args = if (args_str.clone() == "".to_string()) { + let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { 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.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())), "\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()) } } @@ -21683,8 +21020,8 @@ pub fn emit_cargo_dep(name: String, version: String, features: Rc>) pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { { let header = v1_rt::concat( - render_cargo_package_header_prefix(crate_name), - "\nedition = \"2021\"\n".to_string(), + v1_rt::concat("[package]\nname = \"".to_string(), crate_name), + "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n".to_string(), ); let workspace = "\n[workspace]\n".to_string(); let base_deps = Rc::new(vec![ @@ -21784,8 +21121,8 @@ pub fn resolve_param_default( ItemKind::DataItem => match Rc::new({ let mut __result = Vec::new(); for i in module_items.iter().cloned() { - if (authored_name_at(source_indices.clone(), i.clone()) - == authored_name_at(source_indices.clone(), dv.clone())) + if (authored_name_at(source_indices.clone(), i.clone()).as_str() + == authored_name_at(source_indices.clone(), dv.clone()).as_str()) { __result.push(i); } @@ -21995,7 +21332,9 @@ pub fn find_resource_module(resource_name: String, modules: Rc String { { - let about_attr = if (about.clone() != "".to_string()) { + let about_attr = if (about.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat(", about = \"".to_string(), about.clone()), "\"".to_string(), @@ -22567,18 +21907,11 @@ pub fn emit_cli_param_type_node( if ((n.children.clone().len() as i64) == 0) { { let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone() == "String".to_string()) { - "String".to_string() + let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); + if (mapped.clone().as_str() != nname.clone().as_str()) { + mapped.clone() } else { - { - let mapped = - coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone() != nname.clone()) { - mapped.clone() - } else { - "String".to_string() - } - } + "String".to_string() } } } else { @@ -22649,7 +21982,7 @@ pub fn emit_main_fn( ";".to_string(), ) }; - let body_lines = if (dry_run_line.clone() == "".to_string()) { + let body_lines = if (dry_run_line.clone().as_str() == "".to_string().as_str()) { v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) } else { v1_rt::concat( @@ -22684,7 +22017,15 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) + v1_rt::concat( + v1_rt::concat( + "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" + .to_string(), + " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" + .to_string(), + ), + " },".to_string(), + ) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index e716da211b3..a0c3dd4540f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -35,14 +35,13 @@ pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_access::AccessCheckResultNode; pub use crate::v1_compiler_infer_access::{check_index_access_node, check_slice_access_node}; pub use crate::v1_compiler_infer_cycle::detect_type_cycles_kahn; -use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ add_emit_item_summary, build_enum_field_summaries, build_struct_field_summaries, derive_variant_to_enum, empty_emit_graph_info, lookup_emit_type_summary, }; pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, + EmitGraphInfo, EmitInfoBuildState, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ inductive_fields_for, inductive_fields_list_to_map, is_recursive_type, @@ -164,7 +163,8 @@ use std::collections::HashMap; use std::rc::Rc; pub fn is_witness_type_name(name: String) -> bool { - ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) + ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -547,7 +547,7 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (field_type_name.clone() == parent_name.clone()) { + if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -575,15 +575,17 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = ((value_type.clone() == parent_name.clone()) + let is_recursive_element = ((value_type.clone().as_str() + == parent_name.clone().as_str()) || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = if (value_type.clone() == parent_name.clone()) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = + if (value_type.clone().as_str() == parent_name.clone().as_str()) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -751,8 +753,8 @@ pub fn namespace_root_from_properties( match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "namespace_root".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "namespace_root".to_string().as_str()) { __result.push(p); } @@ -882,7 +884,8 @@ pub fn rejects_string_for_optional_coproduct_field( let expected_is_optional_coproduct = ((expected.return_cardinality.clone() == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); - let got_is_string = (authored_name_at(source_indices, got) == "String".to_string()); + let got_is_string = + (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); (expected_is_optional_coproduct && got_is_string) } } @@ -903,7 +906,9 @@ pub fn record_lit_expected_fields( if (authored_name_at( scope.type_env.clone().source_indices.clone(), v.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) { __result.push(v); } @@ -937,7 +942,9 @@ pub fn record_lit_expanded_from_expected( if (((authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -948,7 +955,9 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), expanded.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) { Some(expanded.clone()) } else { @@ -960,7 +969,9 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), rt.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) { Some(rt.clone()) } else { @@ -1004,7 +1015,8 @@ pub fn record_lit_instantiated_fields( Some(tn) => match expected { Some(exp) => { if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - != tn.clone()) + .as_str() + != tn.clone().as_str()) { None } else { @@ -1174,9 +1186,10 @@ pub fn type_node_is_callable(n: Rc) -> bool { pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (v1_rt::substring(&module_name, 0, 3) == "v2.".to_string())); + && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (v1_rt::substring(&module_name, 0, 13) == "v1.compiler.".to_string())); + && (v1_rt::substring(&module_name, 0, 13).as_str() + == "v1.compiler.".to_string().as_str())); (is_v4 || is_compiler_substrate) } } @@ -1191,11 +1204,13 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (formal_name.clone() != "".to_string())) - && (actual_name.clone() != "".to_string())) - && (formal_name.clone() != actual_name.clone())) + && (formal_name.clone().as_str() != "".to_string().as_str())) + && (actual_name.clone().as_str() != "".to_string().as_str())) + && (formal_name.clone().as_str() != actual_name.clone().as_str())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) - == structural_carrier_template_name(actual.clone(), source_indices.clone()))) + .as_str() + == structural_carrier_template_name(actual.clone(), source_indices.clone()) + .as_str())) && !is_declared_container_alias_spelling(formal_name.clone())) && !is_declared_container_alias_spelling(actual_name.clone())) } @@ -1210,8 +1225,8 @@ pub fn container_element_nominal_brand_mismatch( ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), formal.clone()) - == authored_name_at(source_indices.clone(), actual.clone()))) + && (authored_name_at(source_indices.clone(), formal.clone()).as_str() + == authored_name_at(source_indices.clone(), actual.clone()).as_str())) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1342,7 +1357,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( scope: Rc, span: Rc, ) -> Rc { - if ((func_name.clone() == "lookup".to_string()) || (func_name.clone() == "map_get".to_string())) + if ((func_name.clone().as_str() == "lookup".to_string().as_str()) + || (func_name.clone().as_str() == "map_get".to_string().as_str())) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1358,7 +1374,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { + if (func_name.clone().as_str() == "lookup".to_string().as_str()) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1374,7 +1390,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (func_name.clone() == "map_keys".to_string()) { + if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1411,7 +1427,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (func_name.clone() == "map_values".to_string()) { + if (func_name.clone().as_str() == "map_values".to_string().as_str()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1449,13 +1465,14 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((func_name.clone() == "set_insert".to_string()) - || (func_name.clone() == "set_union".to_string())) - || (func_name.clone() == "set_contains".to_string())) + if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) + || (func_name.clone().as_str() == "set_union".to_string().as_str())) + || (func_name.clone().as_str() == "set_contains".to_string().as_str())) { { - let operand_elem = if ((func_name.clone() == "set_insert".to_string()) - || (func_name.clone() == "set_contains".to_string())) + let operand_elem = if ((func_name.clone().as_str() + == "set_insert".to_string().as_str()) + || (func_name.clone().as_str() == "set_contains".to_string().as_str())) { match typed_args.clone().get(1 as usize).cloned() { Some(insert_arg) => match arg_value(insert_arg.clone()) @@ -1499,17 +1516,18 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - 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(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + let union_other_bad = + if (func_name.clone().as_str() == "set_union".to_string().as_str()) { + match typed_args.clone().get(1 as usize).cloned() { + Some(other_arg) => set_union_other_operand_is_resolved_non_set( + other_arg.clone(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1572,7 +1590,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (func_name.clone() == "set_contains".to_string()) { + let result_bt = if (func_name.clone().as_str() + == "set_contains".to_string().as_str()) + { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1615,7 +1635,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (func_name.clone() == "set_contains".to_string()) { + let build_diags = if (func_name.clone().as_str() + == "set_contains".to_string().as_str()) + { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1667,7 +1689,7 @@ pub fn method_pipe_map_keys_values_fallback( scope: Rc, span: Rc, ) -> Rc { - if (method_name.clone() == "map_keys".to_string()) { + if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { 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()); @@ -1682,7 +1704,7 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (method_name.clone() == "map_values".to_string()) { + if (method_name.clone().as_str() == "map_values".to_string().as_str()) { 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()); @@ -1730,7 +1752,7 @@ pub fn validate_cast( match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (source_name.clone() == target_name.clone()) { + if (source_name.clone().as_str() == target_name.clone().as_str()) { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1858,18 +1880,23 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (scrutinee_name.clone() != "Optional".to_string())); - let optional_coproduct_subject = ((scrutinee_name.clone() - == "Optional".to_string()) - && ((variant_name.clone() == "Present".to_string()) - || (variant_name.clone() == "Absent".to_string()))); + && (scrutinee_name.clone().as_str() + != "Optional".to_string().as_str())); + let optional_coproduct_subject = ((scrutinee_name.clone().as_str() + == "Optional".to_string().as_str()) + && ((variant_name.clone().as_str() == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((variant_name.clone() == "Holds".to_string()) - || (variant_name.clone() == "Violates".to_string()))); + && ((variant_name.clone().as_str() + == "Holds".to_string().as_str()) + || (variant_name.clone().as_str() + == "Violates".to_string().as_str()))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((variant_name.clone() == "Present".to_string()) - || (variant_name.clone() == "Absent".to_string()))) + && ((variant_name.clone().as_str() == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))) { Some("Optional".to_string()) } else { @@ -2114,7 +2141,7 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (scrut_type_name.clone() == "".to_string()) { + if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2123,8 +2150,8 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.variant_name.clone() == variant_name.clone()) - && (f.field_name.clone() == field_name.clone())) + if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) + && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } @@ -2252,7 +2279,7 @@ pub fn method_name_is(opt: Option, expected: String) -> bool { if (opt.clone() == None) { false } else { - (opt.clone().unwrap() == expected) + (opt.clone().unwrap().as_str() == expected.as_str()) } } @@ -2266,7 +2293,7 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (n.clone().unwrap() == name) + (n.clone().unwrap().as_str() == name.as_str()) } } } @@ -2340,7 +2367,9 @@ pub fn derive_element_provenance( if (authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - ) == "".to_string()) + ) + .as_str() + == "".to_string().as_str()) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2748,18 +2777,11 @@ pub fn infer_expr( ); match field_type_lookup { Some(field_type) => { - let field_summary = match field_summary_for_type( + let field_summary = field_summary_for_type( base_rt.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(), - field_name.clone(), - ), - }; + ); let fa_texpr = make_named_expr_node( field_name.clone(), Rc::new(ExprData::ExprFieldAccess { @@ -3403,7 +3425,7 @@ pub fn infer_expr( }) } } else { - if (func_name.clone() == "empty_map".to_string()) { + if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3467,7 +3489,8 @@ match bare_m { } } } else { - if (func_name.clone() == "empty_set".to_string()) { + if (func_name.clone().as_str() == "empty_set".to_string().as_str()) + { { let bare_s = bare_set_node(); match expected.clone() { @@ -3540,12 +3563,13 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = - if (func_name.clone() == "lookup".to_string()) { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = if (func_name.clone().as_str() + == "lookup".to_string().as_str()) + { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4276,7 +4300,9 @@ match bare_s { (authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - ) == let_name.clone()) + ) + .as_str() + == let_name.clone().as_str()) } _ => false, }, @@ -5280,7 +5306,7 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (pn.clone() == fname.clone()) { + if (pn.clone().as_str() == fname.clone().as_str()) { __found = true; break; } @@ -5354,7 +5380,7 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone() == "".to_string())) + let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5482,8 +5508,8 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((type_name.clone().unwrap() == "Present".to_string()) + let is_present_ctor = ((type_name.clone().unwrap().as_str() + == "Present".to_string().as_str()) && (local_variant_parent.clone().as_deref() == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { @@ -5818,7 +5848,9 @@ pub fn infer_record_lit( if (field_init_node_name_at( fir.typed_field.clone(), scope.type_env.clone().source_indices.clone(), - ) == "value".to_string()) + ) + .as_str() + == "value".to_string().as_str()) { __result.push(fir); } @@ -5910,7 +5942,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()); - if (mname == "count".to_string()) { + if (mname.as_str() == "count".to_string().as_str()) { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6007,7 +6039,7 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone() == param_name.clone()) { + if (p.clone().as_str() == param_name.clone().as_str()) { match (*lit_expr.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { @@ -6063,7 +6095,9 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { + if ((mname.clone().as_str() == "take".to_string().as_str()) + || (mname.clone().as_str() == "skip".to_string().as_str())) + { { let receiver = method_receiver(arg_expr.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6074,7 +6108,7 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (rname == param_name.clone()) { + if (rname.as_str() == param_name.clone().as_str()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { @@ -6088,7 +6122,8 @@ pub fn classify_collection_shrink( unreachable!() }; if ((k.clone() > 0) - && (mname.clone() == "skip".to_string())) + && (mname.clone().as_str() + == "skip".to_string().as_str())) { match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { @@ -6131,7 +6166,9 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p.clone() == param_name.clone()) { + if (p.clone().as_str() + == param_name.clone().as_str()) + { match proportional_divisor_from_int_at_least_two(d.clone()) { Some(div_w) => { let synth_field = Rc::new(InductiveField { @@ -6162,7 +6199,8 @@ Rc::new(SubValueRelation::StrictSubValue { ExprData::ExprBinOp { op, .. } => { match op.clone() { BinOp::Add => { - if (mname.clone() == "skip".to_string()) + if (mname.clone().as_str() + == "skip".to_string().as_str()) { { let left = @@ -6283,15 +6321,16 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (lookup_type.clone() != "".to_string()) { + if (lookup_type.clone().as_str() != "".to_string().as_str()) { { 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() { - if ((f.field_name.clone() == field_label.clone()) - && ((f.variant_name.clone() == vname.clone()) - || (f.variant_name.clone() == "".to_string()))) + if ((f.field_name.clone().as_str() == field_label.clone().as_str()) + && ((f.variant_name.clone().as_str() == vname.clone().as_str()) + || (f.variant_name.clone().as_str() + == "".to_string().as_str()))) { __result.push(f); } @@ -6483,7 +6522,7 @@ pub fn resolve_collection_field( } } }; - if (base_type.clone() != "".to_string()) { + if (base_type.clone().as_str() != "".to_string().as_str()) { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6495,7 +6534,8 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (f.field_name.clone() == fname.clone()) { + if (f.field_name.clone().as_str() == fname.clone().as_str()) + { __result.push(f); } } @@ -6566,12 +6606,12 @@ pub fn resolve_collection_field( } => { 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())); + let is_collection_preserving = (((((inner_mname.clone().as_str() + == "enumerate".to_string().as_str()) + || (inner_mname.clone().as_str() == "skip".to_string().as_str())) + || (inner_mname.clone().as_str() == "take".to_string().as_str())) + || (inner_mname.clone().as_str() == "filter".to_string().as_str())) + || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); if is_collection_preserving { { let __tco_0 = method_receiver(expr); @@ -6625,7 +6665,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (type_name.clone() != "".to_string()) { + if (type_name.clone().as_str() != "".to_string().as_str()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6705,7 +6745,9 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option "".to_string(), }, }; - if (inner_type.clone() != "".to_string()) { + if (inner_type.clone().as_str() + != "".to_string().as_str()) + { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6848,7 +6892,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if ((elem.clone() != "".to_string()) + if ((elem.clone().as_str() != "".to_string().as_str()) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -6993,7 +7037,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if (left_name.clone() != "".to_string()) { + if (left_name.clone().as_str() != "".to_string().as_str()) { match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -7035,12 +7079,12 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - if (mname.clone() == "skip".to_string()) { + if (mname.clone().as_str() == "skip".to_string().as_str()) { { let skip_args = method_arg_nodes(val.clone()); let skip_amount = match skip_args.first().cloned() { @@ -7253,7 +7297,7 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (vname.clone() == param_name.clone()) { + if (vname.clone().as_str() == param_name.clone().as_str()) { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7299,7 +7343,7 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone() == field.clone()) { + if (f.field_name.clone().as_str() == field.clone().as_str()) { __result.push(f); } } @@ -7443,7 +7487,9 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) == param_name.clone()) + ) + .as_str() + == param_name.clone().as_str()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7487,7 +7533,9 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) == param_name.clone()) + ) + .as_str() + == param_name.clone().as_str()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7505,7 +7553,9 @@ pub fn classify_argument( ((expr_var_name_at( inner_left.clone(), ctx.type_env.clone().source_indices.clone(), - ) == param_name.clone()) + ) + .as_str() + == param_name.clone().as_str()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7647,7 +7697,8 @@ pub fn read_arg_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone() == field.clone()) { + if (f.field_name.clone().as_str() == field.clone().as_str()) + { __result.push(f); } } @@ -7787,7 +7838,7 @@ pub fn build_call_evidence( } pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { - if (found.clone() != "".to_string()) { + if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -7834,7 +7885,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let arg_val = arg_value(child.clone()); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLambda => { - if (source_type.clone() != "".to_string()) { + if (source_type.clone().as_str() != "".to_string().as_str()) { { let lparams = lambda_param_names_at( arg_val.clone(), @@ -7851,7 +7902,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }; let lambda_ctx = Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (p2.clone() != "".to_string()) { + param_names: if (p2.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.param_names.clone(), @@ -7862,7 +7915,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { source_type.clone(), ) } else { - if (p1.clone() != "".to_string()) { + if (p1.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( ctx.param_names.clone(), p1.clone(), @@ -7874,7 +7929,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: if (p1.clone() != "".to_string()) { + sub_value_vars: if (p1.clone().as_str() + != "".to_string().as_str()) + { { let source_fields = inductive_fields_for( ctx.type_env.clone(), @@ -7902,7 +7959,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }), None => Rc::new(SubValueRelation::PreservedValue), }; - if (p2.clone() != "".to_string()) { + if (p2.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), @@ -8041,7 +8100,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Some(t) => t.clone(), None => "".to_string(), }; - if (base_type.clone() != "".to_string()) { + if (base_type.clone().as_str() != "".to_string().as_str()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), @@ -8050,7 +8109,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { - if (f.field_name.clone() == fname.clone()) { + if (f.field_name.clone().as_str() + == fname.clone().as_str()) + { __result.push(f); } } @@ -8074,8 +8135,8 @@ 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.clone() == "last".to_string())) + if ((mname.clone().as_str() == "first".to_string().as_str()) + || (mname.clone().as_str() == "last".to_string().as_str())) { { let receiver = method_receiver(scrut.clone()); @@ -8087,7 +8148,8 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } _ => None, }; - let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) + let scrut_has_inductive = (((scrut_type.clone().as_str() + != "".to_string().as_str()) && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) @@ -8128,7 +8190,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (vname.clone() == "Present".to_string()) { + Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8152,9 +8214,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == inner_vname.clone()) && (f.field_name.clone() == inner_field_name.clone())) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (inner_bind_name.clone() != "".to_string()) { + Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { 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()), @@ -8189,9 +8251,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == vname.clone()) && (f.field_name.clone() == field_name.clone())) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (bind_name.clone() != "".to_string()) { + Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8214,7 +8276,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone() != "".to_string()) { + MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8307,7 +8369,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (sub_type.clone() != "".to_string()) { + param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8424,7 +8486,9 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (sub_type.clone() != "".to_string()) { + param_names: if (sub_type.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( acc.ctx.clone().param_names.clone(), bname.clone(), @@ -8528,7 +8592,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (inner_mname == "enumerate".to_string()) { + if (inner_mname.as_str() == "enumerate".to_string().as_str()) { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8574,7 +8638,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota None => "".to_string(), }, }; - if (base_type.clone() != "".to_string()) { + if (base_type.clone().as_str() != "".to_string().as_str()) { Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( @@ -8584,7 +8648,9 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .iter() .cloned() { - if (f.field_name.clone() == fname.clone()) { + if (f.field_name.clone().as_str() + == fname.clone().as_str()) + { __result.push(f); } } @@ -8888,7 +8954,9 @@ pub fn infer_output_provenance( |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone() != "".to_string()) && (ptype.clone() != "".to_string())) { + if ((pname.clone().as_str() != "".to_string().as_str()) + && (ptype.clone().as_str() != "".to_string().as_str())) + { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { acc.clone() @@ -8954,7 +9022,7 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (pn.clone() == vname.clone()) { + if (pn.clone().as_str() == vname.clone().as_str()) { __found = true; break; } @@ -9003,7 +9071,7 @@ pub fn classify_body_provenance( } _ => "".to_string(), }; - if (type_for_lookup.clone() != "".to_string()) { + if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { { let fields = inductive_fields_for( type_env.clone(), @@ -9012,7 +9080,9 @@ pub fn classify_body_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { - if (f.field_name.clone() == field.clone()) { + if (f.field_name.clone().as_str() + == field.clone().as_str()) + { __result.push(f); } } @@ -9168,7 +9238,7 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((bind_name.clone() != "".to_string()) && (field_label.clone() != "".to_string())) { +if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { { let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) @@ -9356,7 +9426,7 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (first_pname.clone() != "".to_string()) { + if (first_pname.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), first_pname.clone(), @@ -9768,8 +9838,8 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((bind_name.clone() == "".to_string()) - || (field_label.clone() == "".to_string())) + if ((bind_name.clone().as_str() == "".to_string().as_str()) + || (field_label.clone().as_str() == "".to_string().as_str())) { c.clone() } else { @@ -9927,8 +9997,8 @@ pub fn compute_variant_provenance( param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone() != "".to_string()) - && (ptype.clone() != "".to_string())) + if ((pname.clone().as_str() != "".to_string().as_str()) + && (ptype.clone().as_str() != "".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -9979,7 +10049,7 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (enum_name.clone() == parent_enum.clone()) { + if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10003,7 +10073,7 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (fname.clone() != "".to_string()) { + if (fname.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -10040,7 +10110,9 @@ pub fn collect_variant_constructors( if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) == parent_enum.clone()) + ) + .as_str() + == parent_enum.clone().as_str()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10324,8 +10396,8 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((ptype.clone() != "".to_string()) - && (pname.clone() != "".to_string())) + if ((ptype.clone().as_str() != "".to_string().as_str()) + && (pname.clone().as_str() != "".to_string().as_str())) { { let fields = inductive_fields_for( @@ -10617,7 +10689,9 @@ pub fn infer_auth_source_properties( if (field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) == "svc_auth_source".to_string()) + ) + .as_str() + == "svc_auth_source".to_string().as_str()) { { let val = field_init_node_value(p.clone()); @@ -11041,10 +11115,11 @@ pub fn infer_items( } pub fn is_type_variable_name(name: String) -> bool { - (((((name.clone() == "T".to_string()) || (name.clone() == "K".to_string())) - || (name.clone() == "V".to_string())) - || (name.clone() == "MappedElement".to_string())) - || (name.clone() == "FoldAccumulator".to_string())) + (((((name.clone().as_str() == "T".to_string().as_str()) + || (name.clone().as_str() == "K".to_string().as_str())) + || (name.clone().as_str() == "V".to_string().as_str())) + || (name.clone().as_str() == "MappedElement".to_string().as_str())) + || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -11059,7 +11134,7 @@ pub fn type_node_label( ) -> String { { let authored = authored_name_at(source_indices, n.clone()); - if (authored.clone() != "".to_string()) { + if (authored.clone().as_str() != "".to_string().as_str()) { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11084,9 +11159,9 @@ pub fn param_is_generic_decl( }; (((((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().as_str() != "".to_string().as_str())) + && ((pname.clone().as_str() == tname.as_str()) + || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) } } @@ -11109,7 +11184,7 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone() == bind_name.clone()) { + if (g.clone().as_str() == bind_name.clone().as_str()) { __found = true; break; } @@ -11168,9 +11243,9 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); 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.clone().as_str() != "".to_string().as_str()) + && (record_name.clone().as_str() != "".to_string().as_str())) + && (formal_name.clone().as_str() == record_name.clone().as_str())) } } } @@ -11195,7 +11270,9 @@ pub fn unify_record_lit_field_walk( if (field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - ) == field_name.clone()) + ) + .as_str() + == field_name.clone().as_str()) { __result.push(fi); } @@ -11250,7 +11327,7 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone() == formal_name.clone()) { + if (g.clone().as_str() == formal_name.clone().as_str()) { __found = true; break; } @@ -11272,8 +11349,8 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((record_type_name.clone() != "".to_string()) - && (formal_name.clone() == record_type_name.clone())) + if ((record_type_name.clone().as_str() != "".to_string().as_str()) + && (formal_name.clone().as_str() == record_type_name.clone().as_str())) { unify_record_lit_field_walk( record_lit_expected_fields( @@ -11746,6 +11823,9 @@ pub fn build_type_env( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); + // §3 single-authority: no implicit std.types base-injection. Resolution + // flows through each module's explicit import graph only (mirrors + // v1.compiler.infer build_type_env in src/v1/04_infer.dag). let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); @@ -11768,7 +11848,7 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone() == "std.types".to_string()) { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12340,7 +12420,8 @@ 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()); + // §3 single-authority: no implicit std.types base-injection (mirrors + // build_type_env_unresolved in src/v1/04_infer.dag). let parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12362,7 +12443,7 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone() == "std.types".to_string()) { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -13276,8 +13357,8 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (dep.clone() == "None".to_string())) - || (dep.clone() == "".to_string())) + || (dep.clone().as_str() == "None".to_string().as_str())) + || (dep.clone().as_str() == "".to_string().as_str())) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13490,7 +13571,9 @@ 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.clone(), source_indices).as_str() == "0".to_string().as_str()) + } None => false, }) } @@ -13617,40 +13700,6 @@ pub fn build_positional_payload_variants( ) } -pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { - { - let has_seed = { - let mut __found = false; - 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() - { - if (v1_rt::contains(k.clone(), "/v1/".to_string()) - || v1_rt::contains(k.clone(), "src/v1".to_string())) - { - __found = true; - break; - } - } - __found - } { - __found = true; - break; - } - } - __found - }; - if has_seed { - RustCorpusRepr::HostNative - } else { - RustCorpusRepr::FaithfulFreeMonoid - } - } -} - pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { @@ -13707,7 +13756,6 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), - corpus_repr: rust_corpus_repr(modules.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 5aa8cda70bb..98745ada53b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -1,7 +1,6 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.infer_emit_info -use self::RustCorpusRepr::*; use self::TypeRepr::*; pub use crate::v1_compiler_infer_types::{ child_type_node, emit_map_has, node_type_equals, normalize_access_type_node, @@ -63,15 +62,6 @@ pub struct TypeSummary { pub has_fn_fields: bool, } -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] -#[serde(tag = "_variant")] -pub enum RustCorpusRepr { - HostNative, - FaithfulFreeMonoid, -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EmitGraphInfo { pub type_summaries: Rc>>, @@ -85,7 +75,6 @@ pub struct EmitGraphInfo { pub owned_bindings: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, - pub corpus_repr: RustCorpusRepr, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -107,7 +96,6 @@ pub fn empty_emit_graph_info() -> Rc { read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), - corpus_repr: RustCorpusRepr::FaithfulFreeMonoid, }) } @@ -465,8 +453,9 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((resolved_name.clone() != "".to_string()) && !ft_is_type_var.clone()) - && (resolved_name.clone() != "Dynamic".to_string())) + if (((resolved_name.clone().as_str() != "".to_string().as_str()) + && !ft_is_type_var.clone()) + && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -632,6 +621,3 @@ pub fn add_emit_item_summary( None => state, } } - -pub struct HostNative; -pub struct FaithfulFreeMonoid; From ad010f6f6d1ed8d2511656f1a020251454182bc5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 05:07:32 +0000 Subject: [PATCH 37/61] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 3692 ++++++++++------- src/v1/stage0/src/v1_compiler_infer.rs | 500 +-- .../stage0/src/v1_compiler_infer_emit_info.rs | 20 +- 3 files changed, 2418 insertions(+), 1794 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 2f8f22d77f7..bdb428d0e1f 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -8,8 +8,8 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_templates, rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_struct_derives, rust_struct_derives_copy, }; -pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::SubValueUnknown; +pub use crate::std_induction::{InductiveField, SubValueRelation}; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{is_container_type, is_kernel_type}; @@ -45,19 +45,25 @@ pub use crate::v1_compiler_emit_core_support::{ pub use crate::v1_compiler_emit_core_support::{EmitResult, TestProjection}; pub use crate::v1_compiler_infer::InferScope; pub use crate::v1_compiler_infer::{ - build_emit_graph_info, build_params_scope, expr_span, extend_scope, resolved_type_name, + build_emit_graph_info, build_params_scope, expand_type_for_field_access, expr_span, + extend_scope, resolved_type_name, }; +use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ find_variant_parent, is_enum_in_summaries, is_known_variant, lookup_emit_type_summary, variant_belongs_to_enum, variant_summary_key, }; -pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; +pub use crate::v1_compiler_infer_emit_info::{ + EmitGraphInfo, RustCorpusRepr, TypeRepr, TypeSummary, +}; pub use crate::v1_compiler_infer_env::{authored_name, lookup_type_by_name, lookup_type_for}; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; use crate::v1_compiler_infer_items::ItemKind::{DataItem, OtherItem, TypeItem}; pub use crate::v1_compiler_infer_items::{ItemInfo, ItemKind, ResolvedGraph, TypedModule}; -pub use crate::v1_compiler_infer_resolve::lookup_unit_variant_phantom_type; +pub use crate::v1_compiler_infer_resolve::{ + is_width_nat_type_literal, lookup_unit_variant_phantom_type, +}; pub use crate::v1_compiler_infer_service::{ extract_typed_service_name, is_typed_service_call_receiver, }; @@ -83,7 +89,6 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -112,16 +117,16 @@ use crate::v1_std_core::VarBindingKind::{ }; pub use crate::v1_std_core::{ arg_name_at, arg_value, arm_body, arm_guard, arm_pattern, authored_name_at, binop_left, - binop_right, cast_expr, cast_target, expr_call_func_at, expr_has_non_tail_self_call, - expr_has_self_call, expr_method_name_at, expr_var_name_at, field_access_base, - 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, - find_property, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, - if_condition, if_else_branch, if_then_branch, import_is_all, import_specific_names_at, - index_base, index_expr, is_compiler_error, is_file_transport, is_rest_transport, - is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, let_body, - let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, make_span, - match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + binop_right, cast_expr, cast_target, empty_intern_table, expr_call_func_at, + expr_has_non_tail_self_call, expr_has_self_call, expr_method_name_at, expr_var_name_at, + field_access_base, 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, find_property, foreach_body, foreach_collection, foreach_variable_at, + generic_param_name_at, if_condition, if_else_branch, if_then_branch, import_is_all, + import_specific_names_at, index_base, index_expr, is_compiler_error, is_file_transport, + is_rest_transport, is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, + let_body, let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, + make_span, match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, module_items, param_node_default_value, param_node_name_at, param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, return_value, service_config_auth, service_config_auth_input, service_config_auth_source, @@ -144,6 +149,7 @@ use std::rc::Rc; pub fn render_rust_type( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match n.inferred.clone().as_deref().cloned() { @@ -159,12 +165,26 @@ pub fn render_rust_type( applied.clone(), Rc::new(vec![]), shared_types, + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { render_rust_type_without_applied_binding( n.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -172,6 +192,7 @@ pub fn render_rust_type( None => render_rust_type_without_applied_binding( n.clone(), shared_types, + corpus_repr, source_indices.clone(), ), }, @@ -181,6 +202,7 @@ pub fn render_rust_type( pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if (((n.connective.clone() == Connective::NoConnective) @@ -191,7 +213,17 @@ pub fn render_rust_type_without_applied_binding( n.clone(), Rc::new(vec![]), shared_types, + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::>>>(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -231,19 +263,20 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { - let tn = authored_name_at(source_indices.clone(), n.clone()); - if (tn.clone().as_str() == "String".to_string().as_str() - && ((n.children.clone().len() as i64) == 0) - && rust_emit_faithful_text_carrier(source_indices.clone())) { - render_rust_text_carrier(shared_types.clone()) - } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) + let tn = authored_name_at(source_indices.clone(), n.clone()); + if (((tn == "String".to_string()) && ((n.children.clone().len() as i64) == 0)) + && corpus_repr_is_faithful(corpus_repr)) + { + render_rust_text_carrier(shared_types) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) + } } } } @@ -255,22 +288,21 @@ pub fn empty_string_bool_map() -> Rc> { pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { ((v1_rt::string_length(&type_name) >= 3) - && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) + && (v1_rt::substring(&type_name, 0, 3) == "Rc<".to_string())) } -pub fn rust_corpus_includes_v1_compiler( - source_indices: Rc>>, -) -> bool { - v1_rt::map_keys(&source_indices) - .iter() - .cloned() - .any(|k| k.contains("/v1/") || k.contains("src/v1")) +pub fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> bool { + match corpus_repr { + RustCorpusRepr::FaithfulFreeMonoid => true, + RustCorpusRepr::HostNative => false, + } } -pub fn rust_emit_faithful_text_carrier( - source_indices: Rc>>, -) -> bool { - !rust_corpus_includes_v1_compiler(source_indices) +pub fn corpus_repr_is_host(corpus_repr: RustCorpusRepr) -> bool { + match corpus_repr { + RustCorpusRepr::HostNative => true, + RustCorpusRepr::FaithfulFreeMonoid => false, + } } pub fn render_rust_text_carrier(shared_types: Rc>) -> String { @@ -283,9 +315,9 @@ pub fn render_rust_text_carrier(shared_types: Rc>>, + corpus_repr: RustCorpusRepr, ) -> String { - if rust_emit_faithful_text_carrier(source_indices) { + if corpus_repr_is_faithful(corpus_repr) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), @@ -300,9 +332,9 @@ pub fn emit_rust_host_to_dag_string_via_seam( pub fn emit_rust_dag_string_to_host_via_seam( dag_expr: String, - source_indices: Rc>>, + corpus_repr: RustCorpusRepr, ) -> String { - if rust_emit_faithful_text_carrier(source_indices) { + if corpus_repr_is_faithful(corpus_repr) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), @@ -316,57 +348,52 @@ pub fn emit_rust_dag_string_to_host_via_seam( } pub fn rust_host_string_seam_fn_emit(name: String) -> Option { - if name.as_str() == "host_string_text_from_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), - " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), - ), - "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), - ), - "}\n".to_string(), - )) - } else if name.as_str() == "host_string_text_to_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), - " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), - ), - "}\n".to_string(), - ), - "".to_string(), - )) + if (name.clone() == "host_string_text_from_rust_host".to_string()) { + Some(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string()), "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string()), "}\n".to_string())) } else { - None + if (name.clone() == "host_string_text_to_rust_host".to_string()) { + Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) + } else { + None + } } } pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if (name.clone().as_str() == "Json".to_string().as_str()) - || (name.clone().as_str() == "Bytes".to_string().as_str()) - { + if ((name.clone() == "Json".to_string()) || (name.clone() == "Bytes".to_string())) { Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { None } } -pub fn rust_named_type_base( - name: String, - source_indices: Rc>>, -) -> String { - if ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> Option { + if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) + && corpus_repr_is_host(corpus_repr)) { + Some("i64".to_string()) + } else { + None + } +} + +pub fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> Option { + if ((name == "List".to_string()) && corpus_repr_is_host(corpus_repr)) { + Some("Vec".to_string()) + } else { + None + } +} + +pub fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { + if ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) { "Witness".to_string() - } else if name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices) - { - "FreeMonoid".to_string() } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) + if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr)) { + "FreeMonoid".to_string() + } else { + coerce_primitive_type(RenderTarget::Rust, name.clone()) + } } } @@ -394,15 +421,112 @@ 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()), + None => false, + } +} + +pub fn is_parametric_opaque_type_base( + type_name: String, + def_mod_filename: String, + typed_modules: Rc>>, + source_indices: Rc>>, + module_index: Rc, +) -> bool { + match type_item_by_name_in_module_filename( + type_name, + def_mod_filename, + typed_modules, + source_indices.clone(), + module_index, + ) { + Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), + None => false, + } +} + +pub fn render_rust_phantom_opaque_applied_type_arg( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + corpus_repr: RustCorpusRepr, + source_indices: Rc>>, + scope: Rc, + imports: Rc>>, + registry: Rc>>, + module_name: String, + export_sets: Rc>>>, + typed_modules: Rc>>, + module_index: Rc, + variant_to_enum: Rc>, +) -> String { + if is_width_nat_type_literal(n.clone()) { + "()".to_string() + } else { + render_rust_alias_rhs_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + scope, + imports, + registry, + module_name, + export_sets, + typed_modules, + module_index, + variant_to_enum, + ) + } +} + +pub fn render_rust_phantom_opaque_applied_decl_arg( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + corpus_repr: RustCorpusRepr, + source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_width_nat_type_literal(n.clone()) { + "()".to_string() + } else { + render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + variant_to_enum, + env, + ) + } +} + pub fn render_rust_applied_type_arg( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), + _ => render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + variant_to_enum, + env, + ), } } @@ -410,26 +534,46 @@ pub fn render_rust_applied_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { - let base = rust_named_type_base( - authored_name_at(source_indices.clone(), n.clone()), - source_indices.clone(), - ); + let base_name = authored_name_at(source_indices.clone(), n.clone()); + let base = 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()), + }; if ((n.children.clone().len() as i64) == 0) { base } else { { + 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() { - __result.push(render_rust_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - )); + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_decl_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + }); } __result }) @@ -460,14 +604,20 @@ pub fn render_rust_applied_type_shared( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { let rendered = render_rust_applied_type( n.clone(), generic_param_names, shared_types.clone(), + corpus_repr, source_indices.clone(), + variant_to_enum, + env, ); let type_name = authored_name_at(source_indices.clone(), n.clone()); render_rust_shared_type_if_needed(type_name, rendered, shared_types.clone()) @@ -478,7 +628,10 @@ pub fn render_rust_decl_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -486,8 +639,7 @@ pub fn render_rust_decl_type( "__applied_type_args".to_string(), source_indices.clone(), ); - let has_applied_prop = applied_prop.is_some(); - let applied_overlay = match applied_prop { + let applied_overlay = match applied_prop.clone() { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) @@ -502,7 +654,10 @@ pub fn render_rust_decl_type( applied.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -511,7 +666,7 @@ pub fn render_rust_decl_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (g.clone() == name.clone()) { __found = true; break; } @@ -520,67 +675,103 @@ pub fn render_rust_decl_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && v1_rt::set_contains(&shared_types, name.clone())) - { - let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), - recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }); - let rendered = rust_render_type_leaf_name( - name.clone(), - v1_rt::rc_empty_map::(), - stub_env, - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + if (((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && (name.clone() == "String".to_string())) + && corpus_repr_is_faithful(corpus_repr.clone())) { + render_rust_text_carrier(shared_types.clone()) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && v1_rt::set_contains(&shared_types, name.clone())) { - let base = rust_named_type_base(name.clone(), source_indices.clone()); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), + { + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + if (!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(), - source_indices.clone(), - )); + ) + } else { + { + let base = + rust_named_type_base(name.clone(), corpus_repr.clone()); + let peel = is_parametric_opaque_type_by_name( + env.clone(), + name.clone(), + ); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_decl_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + }); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base, "<".to_string()), + args, + ), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) + } } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - ) } } } @@ -589,53 +780,78 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - if name.clone().as_str() == "String".to_string().as_str() { - return false; - } - let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b, - None => { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b, - None => return false, - } + { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if (name.clone() == "String".to_string()) { + return false; } - }; - (binding.params.clone().len() as i64) == 0 + let binding = match lookup_type_for(env.clone(), n.clone()) { + 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()) { + Some(b) => b.clone(), + None => return false, + } + } + }; + ((binding.params.clone().len() as i64) == 0) + } } pub fn render_rust_fn_sig_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0) - && !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()) - } else if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) - } else { - render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (name.clone() == "String".to_string())) + && corpus_repr_is_faithful(corpus_repr.clone())) + { + render_rust_text_carrier(shared_types) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !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) + } else { + if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types, + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum, + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types, + corpus_repr.clone(), + source_indices.clone(), + env.clone(), + ) + } + } + } } } pub fn render_rust_fn_sig_type_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, env: Rc, ) -> String { @@ -646,25 +862,42 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if ((((outer_name.clone() != "".to_string()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + && rust_fn_sig_peel_closed_alias(env, n.clone())) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) + } } } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) } } - None => render_rust_type_with_applied_binding(n, shared_types, source_indices), + None => render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ), } } @@ -672,6 +905,7 @@ pub fn render_rust_alias_rhs_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, scope: Rc, imports: Rc>>, @@ -689,7 +923,7 @@ pub fn render_rust_alias_rhs_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (g.clone() == name.clone()) { __found = true; break; } @@ -698,85 +932,140 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - { - if name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone()) + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) { - render_rust_text_carrier(shared_types.clone()) - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier + match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { + Some(host) => host.clone(), + None => { + if ((name.clone() == "String".to_string()) + && corpus_repr_is_faithful(corpus_repr.clone())) + { + render_rust_text_carrier(shared_types.clone()) + } else { + 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(), + scope.type_env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } + } + } + } } else { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - scope.type_env.clone(), - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) - } - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = if (def_mod.clone().as_str() != local_mod.as_str()) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - }; - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - scope.clone(), + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), imports.clone(), + scope.clone(), registry.clone(), - module_name.clone(), export_sets.clone(), typed_modules.clone(), + source_indices.clone(), module_index.clone(), - variant_to_enum.clone(), - )); + ); + let base = match rust_seed_host_container_base( + name.clone(), + corpus_repr.clone(), + ) { + Some(host) => host.clone(), + None => { + if (def_mod.clone() != local_mod) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + } + } + }; + let peel = is_parametric_opaque_type_base( + name.clone(), + def_mod.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + ) + } else { + render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + ) + }); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + } else { + applied_ty.clone() + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - applied_ty.clone() + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } - } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -903,14 +1192,14 @@ pub fn rust_nominal_identity_carrier_def(name: String) -> String { } pub fn rust_nominal_identity_carrier_type_eligible(type_name: String) -> bool { - (type_name.as_str() == "Symbol".to_string().as_str()) + (type_name == "Symbol".to_string()) } pub fn rust_nominal_identity_carrier_shape_eligible( n: Rc, source_indices: Rc>>, ) -> bool { - ((((authored_name_at(source_indices, n.clone()).as_str() == "Symbol".to_string().as_str()) + ((((authored_name_at(source_indices, n.clone()) == "Symbol".to_string()) && ((n.children.clone().len() as i64) == 0)) && ((n.params.clone().len() as i64) == 0)) && (n.connective.clone() == Connective::NoConnective)) @@ -921,8 +1210,7 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( children: Rc>>, source_indices: Rc>>, ) -> bool { - if ((name.as_str() != "DiffId".to_string().as_str()) || ((children.clone().len() as i64) != 1)) - { + if ((name != "DiffId".to_string()) || ((children.clone().len() as i64) != 1)) { false } else { match children.clone().first().cloned() { @@ -956,8 +1244,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().as_str() == "Symbol".to_string().as_str()) - || (type_name.clone().as_str() == "DiffId".to_string().as_str()))) + && ((type_name.clone() == "Symbol".to_string()) + || (type_name.clone() == "DiffId".to_string()))) } } @@ -1058,9 +1346,7 @@ pub fn field_value_by_name( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at(fi.clone(), source_indices.clone()).as_str() - == field_name.clone().as_str()) - { + if (field_init_node_name_at(fi.clone(), source_indices.clone()) == field_name.clone()) { __result.push(fi); } } @@ -1130,18 +1416,16 @@ pub fn rust_string_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (naming_name.clone() == "AsAuthored".to_string()) { rust_string_as_authored_policy() } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (naming_name.clone() == "SnakeCase".to_string()) { rust_snake_string_policy() } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { rust_screaming_snake_string_policy() } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1158,9 +1442,7 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1177,35 +1459,15 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) + if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) { - 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()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + 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())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1227,7 +1489,7 @@ pub fn rust_internal_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (naming_name.clone() == "AsAuthored".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1238,7 +1500,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (naming_name.clone() == "SnakeCase".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1249,7 +1511,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1260,9 +1522,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1282,9 +1542,7 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1304,41 +1562,15 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) + if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) { - 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()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + 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())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1384,10 +1616,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ) -> Rc { { let encoding_name = authored_name_at(source_indices.clone(), ve.clone()); - if (encoding_name.clone().as_str() == "InternallyTaggedObject".to_string().as_str()) { + if (encoding_name.clone() == "InternallyTaggedObject".to_string()) { rust_internal_policy_for_encoding(ve.clone(), source_indices.clone()) } else { - if (encoding_name.clone().as_str() == "StringVariant".to_string().as_str()) { + 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()), None => rust_serde_error_policy( @@ -1395,10 +1627,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ), } } else { - if (encoding_name.clone().as_str() == "UntaggedVariant".to_string().as_str()) { + if (encoding_name.clone() == "UntaggedVariant".to_string()) { rust_untagged_policy() } else { - if (encoding_name.clone().as_str() == "TaggedVariant".to_string().as_str()) { + if (encoding_name.clone() == "TaggedVariant".to_string()) { rust_tagged_object_policy() } else { rust_serde_error_policy(v1_rt::concat( @@ -1428,8 +1660,7 @@ pub fn resolve_wire_serde_policy( } pub fn item_binding_is_named(env: Rc, node: Rc, name: String) -> bool { - ((authored_name(env, node.clone()).as_str() == name.clone().as_str()) - || (node.name.clone().as_str() == name.clone().as_str())) + ((authored_name(env, node.clone()) == name.clone()) || (node.name.clone() == name.clone())) } pub fn resolve_wire_serde_policy_for_coproduct( @@ -1622,7 +1853,7 @@ pub fn variant_encoding_is_string_variant( encoding: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, encoding).as_str() == "StringVariant".to_string().as_str()) + (authored_name_at(source_indices, encoding) == "StringVariant".to_string()) } pub fn coproduct_wire_contract_targets( @@ -1633,7 +1864,7 @@ pub fn coproduct_wire_contract_targets( match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { - Some(target_name) => (target_name.clone().as_str() == coproduct_name.as_str()), + Some(target_name) => (target_name.clone() == coproduct_name), None => false, } } @@ -1662,15 +1893,15 @@ pub fn module_imports_std_serialization_coproduct_wire_contract( { let mut __found = false; for imp in imports.iter().cloned() { - if ((authored_name_at(source_indices.clone(), imp.clone()).as_str() - == "std.serialization".to_string().as_str()) + if ((authored_name_at(source_indices.clone(), imp.clone()) + == "std.serialization".to_string()) && (import_is_all(imp.clone()) || { let mut __found = false; for name in import_specific_names_at(imp.clone(), source_indices.clone()) .iter() .cloned() { - if (name.clone().as_str() == "CoproductWireContract".to_string().as_str()) { + if (name.clone() == "CoproductWireContract".to_string()) { __found = true; break; } @@ -1693,8 +1924,8 @@ 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.clone()).as_str() - == "CoproductWireContract".to_string().as_str()) + ((authored_name_at(source_indices.clone(), type_node.clone()) + == "CoproductWireContract".to_string()) && module_imports_std_serialization_coproduct_wire_contract( imports, source_indices.clone(), @@ -1714,8 +1945,8 @@ pub fn module_defines_local_coproduct_wire_contract_type( if (((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), item.clone()).as_str() - == "CoproductWireContract".to_string().as_str())) + && (authored_name_at(source_indices.clone(), item.clone()) + == "CoproductWireContract".to_string())) { __found = true; break; @@ -1776,7 +2007,7 @@ pub fn emit_coproduct_wire_contract_target_validation( if { let mut __found = false; for name in local_coproduct_names.iter().cloned() { - if (name.clone().as_str() == target_name.clone().as_str()) { + if (name.clone() == target_name.clone()) { __found = true; break; } @@ -1841,7 +2072,7 @@ pub fn emit_coproduct_wire_contract_validations( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (text.clone() != "".to_string()) { __result.push(text); } } @@ -2198,19 +2429,166 @@ pub fn emit_rust_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; - remaining = __tco_0; - text = __tco_1; - scope = __tco_2; - continue; + let __tco_0 = rest.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; + continue; + } + } + } + } + } + } +} + +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + 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(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name.clone() + } else { + match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum), + } + } +} + +pub fn rust_phantom_zst_marker_def(vname: String) -> String { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]\n".to_string(), rust_visibility_prefix()), rust_items().struct_keyword.clone()), " ".to_string()), vname), ";".to_string()) +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + { + let markers = Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if ((child.children.clone().len() as i64) == 0) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + if is_phantom_unit_variant_type_arg( + env.clone(), + authored_name(env.clone(), child.clone()), + ) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + __result.push({ + let vname = authored_name(env.clone(), child.clone()); + rust_phantom_zst_marker_def(vname.clone()) + }); + } + __result + }) + .join(&"\n".to_string()); + markers + } +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (is_type_def_item(item.clone()) && { + let mut __all = true; + for c in item.children.clone().iter().cloned() { + if !((c.children.clone().len() as i64) == 0) { + __all = false; + break; + } + } + __all + }) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { + item.children.clone().iter().cloned().fold( + acc, + |inner: Rc>, child: Rc| { + if ((child.children.clone().len() as i64) == 0) { + { + let vname = authored_name(env.clone(), child.clone()); + if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !{ + let mut __found = false; + for n in inner.clone().iter().cloned() { + if (n.clone() == vname.clone()) { + __found = true; + break; + } + } + __found + }) + { + v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + } else { + inner.clone() } } + } else { + inner.clone() } - } + }, + ) + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { + __result.push(rust_phantom_zst_marker_def(vname.clone())); } - } + __result + }) + .join(&"\n".to_string()) } pub fn has_complex_variants(item: Rc) -> bool { @@ -2352,9 +2730,8 @@ pub fn build_shared_types( .iter() .cloned() { - if ((sharing.needs_sharing.clone() - && (k.clone().as_str() != "optional".to_string().as_str())) - && (k.clone().as_str() != "boolean_algebra".to_string().as_str())) + if ((sharing.needs_sharing.clone() && (k.clone() != "optional".to_string())) + && (k.clone() != "boolean_algebra".to_string())) { __result.push(k); } @@ -2532,6 +2909,7 @@ pub fn emit_rust(typed: Rc) -> Rc { owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let registry = typed.item_registry.clone(); @@ -2612,18 +2990,18 @@ pub fn emit_rust(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone().as_str() + if (p.module_name.clone() == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ) - .as_str()) + )) { __result.push(p); } } __result }), + emit_info.corpus_repr.clone(), )); } __result @@ -2631,7 +3009,7 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (f.path.clone() != "".to_string()) { __result.push(f); } } @@ -2642,8 +3020,7 @@ pub fn emit_rust(typed: Rc) -> Rc { 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()) - .as_str() - == "v1.compiler.compile".to_string().as_str()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -2752,7 +3129,7 @@ pub fn emit_lib_rs_from_files( __result }); let hand_maintained_mods = if has_compiler_tests.clone() { - "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() + "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod languages_consumer_census;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() } else { "".to_string() }; @@ -2762,9 +3139,6 @@ pub fn emit_lib_rs_from_files( "".to_string() }; let shared_types = emit_non_empty_wrappers(); - // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (single authority): - // crate-root #![recursion_limit = "256"] added (serde_json::json! recursion fix). - // DISSOLUTION lane adhoc-1bdd0259-2e3; a clean regen reproduces this from the .dag. let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); Rc::new(TextFile { path: v1_rt::concat( @@ -2799,6 +3173,7 @@ pub fn emit_module( owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let export_sets = build_module_export_sets(Rc::new(vec![typed_module.clone()])); @@ -2895,7 +3270,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), module_index.clone(), ); - let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { + let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n".to_string(), imports_str.clone()) @@ -2925,7 +3300,7 @@ pub fn emit_module_full( __result.extend( (*match v1_rt::map_get(&svc_module_map, sn.clone()) { Some(mod_file) => { - if (mod_file.clone().as_str() == this_mod_filename.clone().as_str()) { + if (mod_file.clone() == this_mod_filename.clone()) { Rc::new(vec![]) } else { Rc::new(vec![v1_rt::concat( @@ -3012,7 +3387,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = - if (coproduct_wire_contract_validations.clone().as_str() == "".to_string().as_str()) { + if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat( @@ -3073,19 +3448,19 @@ 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()); - let phantom_section = if phantom_zst_markers.as_str() == "" { + 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(authored_name(scope.type_env.clone(), m.clone())); - let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { + 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()).as_str() - == "std.error_primitives".to_string().as_str()) + 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 { @@ -3287,10 +3662,10 @@ pub fn has_physical_type_def_in_module_filename( if { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) - && (is_type_def_item(item.clone()) - || is_type_alias_item(item.clone(), source_indices.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()) + == rhs_name.clone()) + && ((is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; @@ -3342,8 +3717,8 @@ pub fn find_variant_parent_in_module( if { let mut __found = false; for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()).as_str() - == variant_name.clone().as_str()) + if (authored_name_at(source_indices.clone(), child.clone()) + == variant_name.clone()) { __found = true; break; @@ -3385,8 +3760,7 @@ pub fn type_name_is_export_source_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3419,8 +3793,7 @@ pub fn type_name_is_rust_importable_in_module( Some(tm) => match Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3502,7 +3875,7 @@ pub fn name_in_transitive_export_surface( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (v.clone() == module_name.clone()) { __found = true; break; } @@ -3597,7 +3970,7 @@ pub fn reexport_source_module_name_with_visited( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == import_module.clone().as_str()) { + if (v.clone() == import_module.clone()) { __found = true; break; } @@ -3651,8 +4024,7 @@ pub fn reexport_source_module_name_with_visited( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) - { + if (n.clone() == name.clone()) { __found = true; break; } @@ -3826,7 +4198,7 @@ pub fn import_module_enum_scope( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { __result.push(p); } } @@ -3901,8 +4273,7 @@ pub fn enum_physically_defined_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if (((authored_name_at(source_indices.clone(), item.clone()).as_str() - == enum_name.clone().as_str()) + if (((authored_name_at(source_indices.clone(), item.clone()) == enum_name.clone()) && is_type_def_item(item.clone())) && is_coproduct_type(item.clone())) { @@ -3927,7 +4298,7 @@ pub fn wildcard_import_pool_surface_names( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (v.clone() == module_name.clone()) { __found = true; break; } @@ -4024,7 +4395,7 @@ pub fn wildcard_reexport_surface_names( source_indices.clone(), module_index.clone(), ) { - Some(src) => (src.clone().as_str() != import_module.clone().as_str()), + Some(src) => (src.clone() != import_module.clone()), None => false, } { __result.push(n); @@ -4097,7 +4468,7 @@ pub fn variant_defining_module_filename_for_import( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != import_module.clone().as_str()) { + if (hop.clone() != import_module.clone()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4135,7 +4506,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone().as_str() == parent_enum.clone().as_str()) { + if (local_parent.clone() == parent_enum.clone()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -4187,7 +4558,7 @@ pub fn explicit_import_source_module_for_name( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (n.clone() == name.clone()) { __found = true; break; } @@ -4300,7 +4671,7 @@ pub fn reexport_variant_parent_in_import_module( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != src_mod.clone().as_str()) { + if (hop.clone() != src_mod.clone()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4391,7 +4762,7 @@ pub fn alias_rhs_base_module_filename( let local_mod = module_to_filename(alias_module.clone()); match lookup_item(scope.item_registry.clone(), name.clone()) { Some(info) => { - if ((info.module_name.clone().as_str() == alias_module.clone().as_str()) + if ((info.module_name.clone() == alias_module.clone()) && ((info.kind.clone() == ItemKind::TypeItem) || (info.kind.clone() == ItemKind::OtherItem))) { @@ -4444,7 +4815,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (n.clone() == name.clone()) { __found = true; break; } @@ -4551,8 +4922,8 @@ pub fn type_item_by_name_in_module_filename( Some(tm) => Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) + == rhs_name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -4599,28 +4970,12 @@ pub fn type_item_has_rust_nominal_shell_authority( { true } else { - let rhs = resolved_type(item.clone()); - if is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && ((rhs.children.clone().len() as i64) > 0) - { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else if is_type_alias_return_node(rhs.clone(), source_indices.clone()) { - let rhs_name = - authored_name_at(source_indices.clone(), rhs.clone()); - (rhs_name.as_str() != item_text.as_str()) - && rhs_name.as_str() != "" - && alias_rhs_nominal_shell_has_rust_authority( + let rhs = resolved_type(item.clone()); + if (is_type_alias_return_node(rhs.clone(), source_indices.clone()) + && ((rhs.children.clone().len() as i64) > 0)) + { + alias_rhs_nominal_shell_has_rust_authority( rhs.clone(), module_name, imports, @@ -4631,8 +4986,34 @@ pub fn type_item_has_rust_nominal_shell_authority( source_indices.clone(), module_index, ) - } else { - false + } else { + if is_type_alias_return_node( + rhs.clone(), + source_indices.clone(), + ) { + { + let rhs_name = authored_name_at( + source_indices.clone(), + rhs.clone(), + ); + (((rhs_name.clone() != item_text.clone()) + && (rhs_name.clone() != "".to_string())) + && alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + )) + } + } else { + false + } + } } } } else { @@ -4830,9 +5211,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( } else { { let name = authored_name_at(source_indices.clone(), n.clone()); - if ((name.clone().as_str() == "".to_string().as_str()) - || is_kernel_type(name.clone())) - { + if ((name.clone() == "".to_string()) || is_kernel_type(name.clone())) { true } else { if is_phantom_unit_variant_type_arg( @@ -4881,91 +5260,100 @@ pub fn is_self_referential_opaque_type_resolved( item: Rc, source_indices: Rc>>, ) -> bool { - 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 + { + 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)) + } } pub fn is_zero_param_self_referential_opaque_decl( item: Rc, source_indices: Rc>>, ) -> bool { - is_bare_leaf_item(item.clone()) - && is_self_referential_opaque_type_resolved(item.clone(), source_indices) + (is_bare_leaf_item(item.clone()) + && is_self_referential_opaque_type_resolved(item.clone(), source_indices)) } pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((item.params.clone().len() as i64) > 0) - && item.body.is_none() - && item.transport.is_none() - && (item.children.clone().len() as i64) == 0 + ((((((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)) + || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) } pub fn emit_zero_param_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - v1_rt::concat( + { + let item_text = authored_name_at(source_indices, item); v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), + v1_rt::concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), + ), + rust_items().struct_keyword.clone(), ), - rust_items().struct_keyword.clone(), - ), - v1_rt::concat( - v1_rt::concat(" ".to_string(), item_text), - "(pub std::marker::PhantomData<()>);".to_string(), + " ".to_string(), ), + item_text, ), - "".to_string(), - ), - "".to_string(), - ) + "(pub std::marker::PhantomData<()>);".to_string(), + ) + } } pub fn emit_parametric_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - let type_params = emit_type_params(item.params.clone(), source_indices.clone()); - 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(), g), - ">".to_string(), - ), - None => "std::marker::PhantomData<()>".to_string(), - }; - v1_rt::concat( + { + let item_text = authored_name_at(source_indices.clone(), item.clone()); + let type_params = emit_type_params(item.params.clone(), source_indices.clone()); + 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(), g.clone()), + ">".to_string(), + ), + None => "std::marker::PhantomData<()>".to_string(), + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n" + .to_string(), + rust_visibility_prefix(), + ), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + item_text, + ), + type_params, ), - rust_items().struct_keyword.clone(), + "(pub ".to_string(), ), - v1_rt::concat(v1_rt::concat(" ".to_string(), item_text), type_params), + marker_ty, ), - v1_rt::concat( - v1_rt::concat("(pub ".to_string(), marker_ty), - ");".to_string(), - ), - ), - "".to_string(), - ) + ");".to_string(), + ) + } } pub fn is_emittable_parametric_type_alias_item( @@ -4995,37 +5383,21 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs_name = authored_name_at(source_indices.clone(), rhs.clone()); - if rhs_name.as_str() != item_text.as_str() { - if (rhs.children.clone().len() as i64) > 0 { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else if rhs_name.as_str() != "" { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else { - false - } - } else { - false - } + ((rhs_name.clone() != item_text) + && (((rhs.children.clone().len() as i64) > 0) + || ((((rhs.children.clone().len() as i64) == 0) + && (rhs_name.clone() != "".to_string())) + && alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + )))) } } } @@ -5053,7 +5425,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for ln in local_names.clone().iter().cloned() { - if !(ln.clone().as_str() != n.clone().as_str()) { + if !(ln.clone() != n.clone()) { __all = false; break; } @@ -5195,7 +5567,7 @@ pub fn emit_specific_import_block( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { __result.push(p); } } @@ -5229,7 +5601,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, } { __found = true; @@ -5251,7 +5623,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for n in direct_names.clone().iter().cloned() { - if !(n.clone().as_str() != p.clone().as_str()) { + if !(n.clone() != p.clone()) { __all = false; break; } @@ -5276,7 +5648,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, } { __found = true; @@ -5360,9 +5732,7 @@ pub fn emit_specific_import_block( export_sets.clone(), source_indices.clone(), module_index.clone(), - ) - .as_str() - == def_mod.clone().as_str()) + ) == def_mod.clone()) { __result.push(n); } @@ -5440,13 +5810,13 @@ pub fn emit_specific_import_block( Rc::new({ let mut __result = Vec::new(); for l in type_direct_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } __result }), - if (other_direct_line.clone().as_str() != "".to_string().as_str()) { + if (other_direct_line.clone() != "".to_string()) { Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) @@ -5466,9 +5836,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } + Some(found) => (found.clone() == p.clone()), None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -5479,9 +5847,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } + Some(found) => (found.clone() == p.clone()), None => false, }, } { @@ -5520,15 +5886,15 @@ pub fn emit_specific_import_block( __result.push({ let group = Rc::new({ let mut __result = Vec::new(); for p in remote_parent_list.clone().iter().cloned() { if { let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, }, } { __result.push(n); } } __result }).first().cloned(); match rep_variant.clone() { - Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()).as_str() == def_mod.clone().as_str()), - None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()).as_str() == def_mod.clone().as_str()), + Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()) == def_mod.clone()), + None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()) == def_mod.clone()), } } { __result.push(p); } } __result }); if ((group.clone().len() as i64) > 0) { @@ -5549,7 +5915,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5560,7 +5926,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5596,10 +5962,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) - } + Some(found) => (found.clone() == parent.clone()), None => { match reexport_variant_parent_in_import_module( n.clone(), @@ -5612,8 +5975,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib module_index.clone(), ) { Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) + (found.clone() == parent.clone()) } None => match find_variant_parent( type_summaries.clone(), @@ -5692,7 +6054,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib if ({ let mut __found = false; for p in parent_list.clone().iter().cloned() { - if (p.clone().as_str() == en.clone().as_str()) { + if (p.clone() == en.clone()) { __found = true; break; } @@ -5726,7 +6088,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5735,7 +6097,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in variant_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5859,7 +6221,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { } pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: String) -> bool { - (((rust_pub_use_module_name(line.clone()).as_str() == mod_name.as_str()) + (((rust_pub_use_module_name(line.clone()) == mod_name) && v1_rt::contains(line.clone(), "::{".to_string())) && (((v1_rt::contains( line.clone(), @@ -5892,9 +6254,7 @@ pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> b { let mod_name = rust_pub_use_module_name(line.clone()); let name = rust_pub_use_singleton_name(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || (name.clone().as_str() == "".to_string().as_str())) - { + if ((mod_name.clone() == "".to_string()) || (name.clone() == "".to_string())) { false } else { { @@ -5919,17 +6279,14 @@ pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || ((names.clone().len() as i64) == 0)) - { + if ((mod_name.clone() == "".to_string()) || ((names.clone().len() as i64) == 0)) { false } else { { let mut __found = false; for other in lines.iter().cloned() { - if (((((other.clone().as_str() != line.clone().as_str()) - && (rust_pub_use_module_name(other.clone()).as_str() - == mod_name.clone().as_str())) + if (((((other.clone() != line.clone()) + && (rust_pub_use_module_name(other.clone()) == mod_name.clone())) && v1_rt::contains(other.clone(), "::{".to_string())) && ((rust_pub_use_braced_names(other.clone()).len() as i64) > (names.clone().len() as i64))) @@ -5968,9 +6325,7 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> Rc> { let exact = unique_strings(Rc::new({ let mut __result = Vec::new(); for line in lines.iter().cloned() { - if (line.clone().as_str() != "".to_string().as_str()) { + if (line.clone() != "".to_string()) { __result.push(line); } } @@ -6083,8 +6438,7 @@ pub fn emit_imports( let mut __result = Vec::new(); for imp in imports.clone().iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - .as_str() - == import_module.clone().as_str()) + == import_module.clone()) { __result.push(imp); } @@ -6154,8 +6508,7 @@ pub fn emit_imports( source_indices.clone(), module_index.clone(), ); - if (specific_block.clone().as_str() != "".to_string().as_str()) - { + if (specific_block.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat(wildcard_line.clone(), "\n".to_string()), specific_block.clone(), @@ -6285,44 +6638,74 @@ pub fn emit_typed_item( && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { rust_nominal_identity_carrier_def(item_text.clone()) - } else if is_zero_param_self_referential_opaque_decl( - item.clone(), - env.source_indices.clone(), - ) { - emit_zero_param_phantom_opaque_struct(item.clone(), env.source_indices.clone()) } else { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( + if is_zero_param_self_referential_opaque_decl( + item.clone(), + env.source_indices.clone(), + ) { + emit_zero_param_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + match rust_seed_host_numeric_alias( + item_text.clone(), + emit_info.corpus_repr.clone(), + ) { + Some(host) => v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), + ), + " ".to_string(), + ), + item_text.clone(), ), - " ".to_string(), + " = ".to_string(), ), - item_text.clone(), + host.clone(), ), - " = ".to_string(), + ";".to_string(), ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - Rc::new(vec![]), - shared_types, - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), + ), + " ".to_string(), + ), + item_text.clone(), + ), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + Rc::new(vec![]), + shared_types, + emit_info.corpus_repr.clone(), + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), ), - ), - ";".to_string(), - ) + } + } } } else { if is_type_decl_item(item.clone(), env.source_indices.clone()) { @@ -6331,19 +6714,11 @@ pub fn emit_typed_item( { rust_nominal_identity_carrier_def(item_text.clone()) } else { - if is_emittable_parametric_type_alias_item( - item.clone(), + match rust_seed_host_container_base( item_text.clone(), - env.source_indices.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), + emit_info.corpus_repr.clone(), ) { - { + Some(host) => { let type_params = emit_type_params( item.params.clone(), env.source_indices.clone(), @@ -6359,45 +6734,105 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items() + .type_alias_keyword + .clone(), + ), + " ".to_string(), + ), + item_text.clone(), ), - " ".to_string(), + type_params, ), - item_text.clone(), + " = ".to_string(), ), - type_params, + host.clone(), ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - generic_names, - shared_types, - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + "<".to_string(), ), + generic_names.join(&", ".to_string()), ), - ";".to_string(), + ">;".to_string(), ) } - } else if is_parametric_opaque_type_decl_item( - item.clone(), - env.source_indices.clone(), - ) { - emit_parametric_phantom_opaque_struct( - item.clone(), - env.source_indices.clone(), - ) - } else { - "".to_string() + None => { + if is_emittable_parametric_type_alias_item( + item.clone(), + item_text.clone(), + env.source_indices.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + ) { + { + let type_params = emit_type_params( + item.params.clone(), + env.source_indices.clone(), + ); + let generic_names = item_generic_param_names( + item.clone(), + env.source_indices.clone(), + ); + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items() + .type_alias_keyword + .clone(), + ), + " ".to_string(), + ), + item_text.clone(), + ), + type_params, + ), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + generic_names, + shared_types, + emit_info.corpus_repr.clone(), + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), + ) + } + } else { + if is_parametric_opaque_type_decl_item( + item.clone(), + env.source_indices.clone(), + ) { + emit_parametric_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + "".to_string() + } + } + } } } } else { @@ -6441,6 +6876,7 @@ pub fn emit_typed_item( owned_bindings: v1_rt::rc_empty_set::(), 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(), @@ -6495,11 +6931,17 @@ pub fn emit_typed_item( item.clone(), registry.clone(), shared_types, + emit_info.corpus_repr.clone(), env.clone(), ) } else { if is_resource_def_item(item.clone()) { - emit_resource_def(item.clone(), shared_types, env.clone()) + emit_resource_def( + item.clone(), + shared_types, + emit_info.corpus_repr.clone(), + env.clone(), + ) } else { v1_rt::concat( v1_rt::concat( @@ -6530,9 +6972,7 @@ pub fn needs_box_wrapping( if v1_rt::set_contains(&shared_types, name.clone()) { break false; } else { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()).as_str() - != name.clone().as_str()) - { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { break false; } else { break v1_rt::set_contains(&recursive_types, name.clone()); @@ -6583,12 +7023,11 @@ pub fn is_function_type_param(param: Rc) -> bool { Some(inf) => is_type_variable(inf.clone()), None => false, }; - let same_source_span = (((param.span.clone().file.clone().as_str() - == type_expr.span.clone().file.clone().as_str()) + let same_source_span = (((param.span.clone().file.clone() + == type_expr.span.clone().file.clone()) && (param.span.clone().start.clone() == type_expr.span.clone().start.clone())) && (param.span.clone().end.clone() == type_expr.span.clone().end.clone())); - (((param.name.clone().as_str() != "".to_string().as_str()) - && (param.name.clone().as_str() == type_expr.name.clone().as_str())) + (((param.name.clone() != "".to_string()) && (param.name.clone() == type_expr.name.clone())) && (type_expr_is_var || same_source_span)) } } @@ -6709,11 +7148,10 @@ pub fn emit_type_def_from_connective( Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; - let validations = if (policy_validation.clone().as_str() == "".to_string().as_str()) - { + let validations = if (policy_validation.clone() == "".to_string()) { rename_validations.clone() } else { - if (rename_validations.clone().as_str() == "".to_string().as_str()) { + if (rename_validations.clone() == "".to_string()) { policy_validation.clone() } else { v1_rt::concat( @@ -6740,7 +7178,7 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), emit_info, ); - if (validations.clone().as_str() == "".to_string().as_str()) { + if (validations.clone() == "".to_string()) { enum_text } else { v1_rt::concat( @@ -6753,6 +7191,73 @@ pub fn emit_type_def_from_connective( } } +pub fn type_node_mentions_name( + n: Rc, + target: String, + source_indices: Rc>>, +) -> bool { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (authored_name_at(source_indices.clone(), n.clone()) == target.clone()) { + true + } else { + { + let mut __found = false; + for c in n.children.clone().iter().cloned() { + if type_node_mentions_name(c.clone(), target.clone(), source_indices.clone()) { + __found = true; + break; + } + } + __found + } + } + }) +} + +pub fn struct_unused_param_names( + generic_param_names: Rc>, + children: Rc>>, + source_indices: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for p in generic_param_names.iter().cloned() { + if !{ + let mut __found = false; + for child in children.clone().iter().cloned() { + if type_node_mentions_name( + field_node_type_expr(child.clone()), + p.clone(), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + } { + __result.push(p); + } + } + __result + }) +} + +pub fn rust_phantom_marker_inner(unused: Rc>) -> String { + if ((unused.clone().len() as i64) == 1) { + unused.clone().join(&", ".to_string()) + } else { + v1_rt::concat( + v1_rt::concat("(".to_string(), unused.clone().join(&", ".to_string())), + ")".to_string(), + ) + } +} + +pub fn rust_phantom_field_name() -> String { + "_phantom".to_string() +} + pub fn emit_struct_from_children( name: String, type_params: String, @@ -6775,9 +7280,7 @@ pub fn emit_struct_from_children( name.clone(), children.clone(), env.source_indices.clone(), - ) - .as_str() - != "".to_string().as_str()) + ) != "".to_string()) { rust_nominal_ord_derives_for_shape( name.clone(), @@ -6829,7 +7332,32 @@ pub fn emit_struct_from_children( } __result }); - let fields_str = field_lines.join(&"\n".to_string()); + let unused_params = struct_unused_param_names( + generic_param_names.clone(), + children.clone(), + env.source_indices.clone(), + ); + let all_field_lines = if ((unused_params.clone().len() as i64) > 0) { + v1_rt::concat( + field_lines, + Rc::new(vec![v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(" ".to_string(), rust_visibility_prefix()), + rust_phantom_field_name(), + ), + ": std::marker::PhantomData<".to_string(), + ), + rust_phantom_marker_inner(unused_params.clone()), + ), + ">,".to_string(), + )]), + ) + } else { + field_lines + }; + let fields_str = all_field_lines.join(&"\n".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -6863,6 +7391,7 @@ pub fn emit_struct_from_children( pub fn render_rust_type_with_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match find_property( @@ -6872,51 +7401,93 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 { - if outer_name != applied_name { - render_rust_shared_type_if_needed( - 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, - shared_types.clone(), - ) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if (((outer_name.clone() != "".to_string()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + { + if (outer_name.clone() != applied_name) { + render_rust_shared_type_if_needed( + outer_name.clone(), + 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.clone(), + shared_types.clone(), + ) + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >( + ), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), + ) + } + } } else { render_rust_applied_type_shared( applied.clone(), Rc::new(vec![]), - shared_types, + shared_types.clone(), + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types, - source_indices.clone(), - ) } } else { - render_rust_type(n.clone(), shared_types, source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + ) } } - None => render_rust_type(n.clone(), shared_types, source_indices.clone()), + None => render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + ), } } pub fn render_rust_field_type_with_applied_binding( field: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -6930,6 +7501,7 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( field.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } else { @@ -6942,17 +7514,24 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( authored_type.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } else { if ((authored_type.connective.clone() == Connective::NoConnective) && ((authored_type.children.clone().len() as i64) > 0)) { - render_rust_type(authored_type.clone(), shared_types, source_indices.clone()) + render_rust_type( + authored_type.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) } else { render_rust_type_with_applied_binding( resolved_type(field.clone()), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -6990,6 +7569,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7002,6 +7582,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( authored_child_type.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7014,6 +7595,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7060,6 +7642,7 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7067,6 +7650,7 @@ pub fn emit_struct_field_from_child( None => render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), } @@ -7075,6 +7659,7 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7082,7 +7667,7 @@ pub fn emit_struct_field_from_child( } } }; - let generic_ty = if (struct_name.as_str() == "PartialFunction".to_string().as_str()) { + let generic_ty = if (struct_name == "PartialFunction".to_string()) { rust_normalize_partial_function_field_type_text(rust_normalize_witness_type_text(ty)) } else { ty @@ -7113,8 +7698,8 @@ pub fn emit_struct_field_from_child( let rename_attr = match Rc::new({ let mut __result = Vec::new(); for p in child.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), env.source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (field_init_node_name_at(p.clone(), env.source_indices.clone()) + == "from_key".to_string()) { __result.push(p); } @@ -7159,19 +7744,18 @@ pub fn emit_rust_field_definition( { let snake = to_snake(authored.clone()); let emitted = emit_ident(authored.clone(), RenderTarget::Rust); - let keyword_rename = if ((emitted.clone().as_str() != snake.clone().as_str()) - && (rename_attr.clone().as_str() == "".to_string().as_str())) - { - v1_rt::concat( + let keyword_rename = + if ((emitted.clone() != snake.clone()) && (rename_attr.clone() == "".to_string())) { v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + v1_rt::concat( + v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), + snake.clone(), + ), + "\")]\n".to_string(), + ) + } else { + "".to_string() + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7241,7 +7825,7 @@ pub fn emit_enum_from_children( __result }); let variants_str = variant_lines.join(&"\n".to_string()); - let tag_line = if (serde_policy.enum_attr.clone().as_str() == "".to_string().as_str()) { + let tag_line = if (serde_policy.enum_attr.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) @@ -7283,7 +7867,7 @@ pub fn emit_enum_from_children( env.clone(), emit_info.clone(), ); - if (accessor_impl.clone().as_str() == "".to_string().as_str()) { + if (accessor_impl.clone() == "".to_string()) { enum_def } else { v1_rt::concat( @@ -7332,9 +7916,7 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> if !({ let mut __found = false; for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __found = true; break; } @@ -7398,8 +7980,7 @@ pub fn emit_enum_shared_accessors( match Rc::new({ let mut __result = Vec::new(); for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __result.push(f); } @@ -7412,6 +7993,7 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "".to_string(), @@ -7427,7 +8009,7 @@ pub fn emit_enum_shared_accessors( { let mut __all = true; for t in types.clone().iter().cloned() { - if !(t.clone().as_str() == first_type.clone().as_str()) { + if !(t.clone() == first_type.clone()) { __all = false; break; } @@ -7450,9 +8032,7 @@ pub fn emit_enum_shared_accessors( let ty = match Rc::new({ let mut __result = Vec::new(); for f in first_fielded.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __result.push(f); } } @@ -7464,6 +8044,7 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "compile_error!(\"enum shared accessor missing field metadata\")" @@ -7609,8 +8190,7 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) - && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)).as_str() - == prefix.clone().as_str())) + && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)) == prefix.clone())) { Some(v1_rt::substring( &value, @@ -7632,9 +8212,7 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { &value, (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), v1_rt::string_length(&value), - ) - .as_str() - == suffix.clone().as_str())) + ) == suffix.clone())) { Some(v1_rt::substring( &value, @@ -7647,67 +8225,120 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } +pub fn string_index_of_from(mut haystack: String, mut needle: String, mut pos: i64) -> Option { + loop { + if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { + break None; + } else { + if (v1_rt::substring( + &haystack, + pos.clone(), + (pos.clone() + v1_rt::string_length(&needle)), + ) == needle.clone()) + { + break Some(pos.clone()); + } else { + { + let __tco_0 = (pos + 1); + pos = __tco_0; + continue; + } + } + } + } +} + +pub fn string_index_of(haystack: String, needle: String) -> Option { + string_index_of_from(haystack, needle, 0) +} + pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, ) -> Option { - if policy.error_message.is_some() { - return None; - } - match policy.rename_style.clone() { - Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { - let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix) { - Some(stripped) => stripped, - 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, - }, - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } else { - None + if (policy.error_message.clone() != None) { + None + } else { + match policy.rename_style.clone() { + Some(style) => { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + { + let without_prefix = match policy.rename_prefix.clone() { + 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.clone()) { + Some(stripped) => stripped.clone(), + None => return None, + } + } + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } + } else { + None + } } - } - None => { - if policy.enum_attr.contains("rename_all = \"snake_case\"") { - Some(to_snake(authored)) - } else if policy.enum_attr.is_empty() - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - { - Some(authored) - } else { - None + None => { + if v1_rt::contains( + policy.enum_attr.clone(), + "rename_all = \"snake_case\"".to_string(), + ) { + Some(to_snake(authored)) + } else { + if (((policy.enum_attr.clone() == "".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + { + Some(authored) + } else { + None + } + } } } } } -pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { - let needle = "tag = \""; - let start = policy.enum_attr.find(needle)? + needle.len(); - let rest = &policy.enum_attr[start..]; - let end = rest.find('"')?; - Some(rest[..end].to_string()) +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)); + 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(), + )), + None => None, + } + } + None => None, + } + } } -pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { - policy.enum_attr.contains("untagged") +pub fn policy_is_untagged(policy: Rc) -> bool { + v1_rt::contains(policy.enum_attr.clone(), "untagged".to_string()) } -pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { - !policy.enum_attr.contains("tag =") - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - && policy.rename_style.is_none() +pub fn policy_is_string_variant(policy: Rc) -> bool { + (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + && (policy.rename_style.clone() == None)) } pub fn wire_variant_rename_attr_for_policy( @@ -7717,9 +8348,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.as_str() == "StripAffixAndSnakeCase" { + 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 { @@ -7738,7 +8369,7 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { @@ -7801,7 +8432,7 @@ pub fn variant_rename_validations_for_policy( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (text.clone() != "".to_string()) { __result.push(text); } } @@ -7843,6 +8474,7 @@ pub fn enum_variant_field_type_node( pub fn render_variant_payload_type( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if ((n.connective.clone() == Connective::NoConnective) @@ -7856,6 +8488,7 @@ pub fn render_variant_payload_type( __result.push(render_rust_type( child_type_node(c.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), )); } @@ -7874,7 +8507,12 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } @@ -7886,9 +8524,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).as_str() == "0".to_string().as_str()) - } + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, } } @@ -7923,8 +8559,7 @@ pub fn emit_variant_from_child( env.source_indices.clone(), ); let tuple_style = (positional_payload.clone() - || (serde_policy.enum_attr.clone().as_str() - == "#[serde(untagged)]".to_string().as_str())); + || (serde_policy.enum_attr.clone() == "#[serde(untagged)]".to_string())); if tuple_style { match child.children.clone().first().cloned() { Some(f) => { @@ -7945,12 +8580,14 @@ pub fn emit_variant_from_child( render_variant_payload_type( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { render_rust_type( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) }; @@ -7963,6 +8600,7 @@ pub fn emit_variant_from_child( render_rust_type_with_applied_binding( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -8013,6 +8651,7 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8066,6 +8705,7 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8122,71 +8762,78 @@ pub fn emit_fn_def( shared_types: Rc>, emit_info: Rc, ) -> String { - if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { - if rust_emit_faithful_text_carrier(scope.type_env.source_indices.clone()) { - return seam_fn; - } else { - return "".to_string(); - } - } { let si = scope.type_env.clone().source_indices.clone(); - let type_params = function_type_params(params.clone()); - let value_params = function_value_params(params.clone()); - if function_type_params_have_collision(type_params.clone()) { - return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); - } - let type_params_str = emit_type_params(type_params.clone(), si.clone()); - let generic_param_names = Rc::new({ - let mut __result = Vec::new(); - for p in type_params.clone().iter().cloned() { - __result.push(generic_param_name_at(p.clone(), si.clone())); + 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() + } else { + "".to_string() + } } - __result - }); - let params_str = emit_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - emit_info.read_only_params.clone(), - scope.type_env.clone(), - ); - let ret_str = emit_inferred( - inferred, - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - scope.type_env.clone(), - ); - let body_scope = build_params_scope(scope.clone(), value_params.clone()); - let depth = 0; - let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); - let needs_stacker = - (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) - && (use_tco.clone() == false)); - if use_tco.clone() { - { - let tco_params_str = emit_tco_params( + None => { + let type_params = function_type_params(params.clone()); + let value_params = function_value_params(params.clone()); + if function_type_params_have_collision(type_params.clone()) { + return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); + } + let type_params_str = emit_type_params(type_params.clone(), si.clone()); + let generic_param_names = Rc::new({ + let mut __result = Vec::new(); + for p in type_params.clone().iter().cloned() { + __result.push(generic_param_name_at(p.clone(), si.clone())); + } + __result + }); + let params_str = emit_params( value_params.clone(), generic_param_names.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), si.clone(), + emit_info.read_only_params.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); - let body_str = emit_typed_tco_body( - body.clone(), - name.clone(), - value_params.clone(), - registry.clone(), - body_scope, - (depth.clone() + 1), + let ret_str = emit_inferred( + inferred, + generic_param_names.clone(), shared_types.clone(), - emit_info.clone(), + emit_info.corpus_repr.clone(), + si.clone(), + emit_info.variant_to_enum.clone(), + scope.type_env.clone(), ); - let kw = rust_items().func_keyword.clone(); - v1_rt::concat( - v1_rt::concat( + let body_scope = build_params_scope(scope.clone(), value_params.clone()); + let depth = 0; + let use_tco = + is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); + let needs_stacker = + (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) + && (use_tco.clone() == false)); + if use_tco.clone() { + { + let tco_params_str = emit_tco_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + emit_info.corpus_repr.clone(), + 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.clone(), + registry.clone(), + body_scope, + (depth.clone() + 1), + shared_types.clone(), + emit_info.clone(), + ); + let kw = rust_items().func_keyword.clone(); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -8197,49 +8844,53 @@ pub fn emit_fn_def( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - kw, + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + kw, + ), + " ".to_string(), + ), + emit_ident( + name.clone(), + RenderTarget::Rust, + ), ), - " ".to_string(), - ), - emit_ident( - name.clone(), - RenderTarget::Rust, + type_params_str, ), + "(".to_string(), ), - type_params_str, + tco_params_str, ), - "(".to_string(), + ")".to_string(), ), - tco_params_str, + ret_str, ), - ")".to_string(), + " {\n".to_string(), ), - ret_str, + make_indent((depth.clone() + 1)), ), - " {\n".to_string(), + body_str, ), - make_indent((depth.clone() + 1)), - ), - body_str, - ), - "\n}".to_string(), - ) + "\n}".to_string(), + ) + } + } else { + emit_fn_def_non_tco( + name.clone(), + type_params_str, + params_str, + ret_str, + body.clone(), + registry.clone(), + body_scope, + depth.clone(), + shared_types.clone(), + emit_info.clone(), + needs_stacker, + ) + } } - } else { - emit_fn_def_non_tco( - name.clone(), - type_params_str, - params_str, - ret_str, - body.clone(), - registry.clone(), - body_scope, - depth.clone(), - shared_types.clone(), - emit_info.clone(), - needs_stacker, - ) } } } @@ -8399,13 +9050,16 @@ pub fn emit_func_def( uses.clone(), service_names, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), + emit_info.variant_to_enum.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(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -8619,7 +9273,9 @@ pub fn emit_tco_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8630,7 +9286,9 @@ pub fn emit_tco_params( p.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8644,7 +9302,9 @@ pub fn emit_tco_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8654,15 +9314,19 @@ pub fn emit_tco_param( authored.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8687,8 +9351,10 @@ pub fn emit_func_params( uses: Rc>>, service_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8699,8 +9365,10 @@ pub fn emit_func_params( p.clone(), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8720,6 +9388,7 @@ pub fn emit_func_params( render_rust_type( resource_use_resource(u.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ), )); @@ -8744,12 +9413,13 @@ pub fn emit_func_params( pub fn emit_func_inferred( inferred: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { v1_rt::concat( v1_rt::concat( " -> Result<".to_string(), - render_rust_type(inferred, shared_types, source_indices), + render_rust_type(inferred, shared_types, corpus_repr, source_indices), ), ", Box>".to_string(), ) @@ -8759,8 +9429,10 @@ pub fn emit_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8771,8 +9443,10 @@ pub fn emit_params( p.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8786,16 +9460,20 @@ pub fn render_rust_param_sig_type( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param.clone()); + let type_node = resolved_type(param); render_rust_fn_sig_type( type_node, generic_param_names, shared_types, + corpus_repr, source_indices, + variant_to_enum, env, ) } @@ -8805,7 +9483,9 @@ pub fn emit_rust_param_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -8817,7 +9497,9 @@ pub fn emit_rust_param_type( param_node_type_expr(p.clone()), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8829,7 +9511,9 @@ pub fn emit_rust_param_type( rt.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8850,8 +9534,10 @@ pub fn emit_rust_param_type( n.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), - env, + variant_to_enum.clone(), + env.clone(), ) } } @@ -8860,8 +9546,10 @@ pub fn emit_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8871,15 +9559,19 @@ pub fn emit_param( authored.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8898,7 +9590,9 @@ pub fn emit_inferred( inferred: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -8907,7 +9601,9 @@ pub fn emit_inferred( inferred, generic_param_names, shared_types, + corpus_repr, source_indices, + variant_to_enum, env, ), ) @@ -8990,12 +9686,11 @@ pub fn collect_field_binding_string_guards( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) - } else { - v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) - }; + let field_path = if (fb_name.clone() == "0".to_string()) { + v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) + } else { + v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) + }; let bind_name = pattern_string_binding_name(field_path.clone()); match positional_payload_string_guard( fb_pat.clone(), @@ -9014,7 +9709,7 @@ pub fn collect_field_binding_string_guards( nested_path.clone(), source_indices.clone(), ); - if (nested.clone().as_str() == "".to_string().as_str()) { + if (nested.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![nested.clone()]) @@ -9045,7 +9740,7 @@ pub fn collect_pattern_string_guards( field_bindings: fbs, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) + if (((n.clone() == "Present".to_string()) && (parent.clone().as_deref() == Some("Optional".to_string()).as_deref())) && ((fbs.clone().len() as i64) == 1)) { @@ -9088,8 +9783,7 @@ pub fn collect_pattern_string_guards( match fbs.clone().first().cloned() { Some(fb) => { if (field_binding_name_at(fb.clone(), source_indices.clone()) - .as_str() - == "0".to_string().as_str()) + == "0".to_string()) { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( @@ -9230,7 +9924,7 @@ pub fn pattern_parent_enum( type_summaries: Rc>>, ) -> Option { { - let scrut_is_known_enum = ((scrut_type.clone().as_str() != "".to_string().as_str()) + 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() @@ -9273,13 +9967,12 @@ pub fn unique_variant_parent( } pub fn is_optional_variant_name(name: String) -> bool { - ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str())) + ((name.clone() == "Present".to_string()) || (name.clone() == "Absent".to_string())) } pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent.clone().as_str() == "Optional".to_string().as_str()), + Some(parent) => (parent.clone() == "Optional".to_string()), None => false, } } @@ -9337,7 +10030,7 @@ pub fn emit_variant_pattern( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -9350,7 +10043,7 @@ pub fn emit_variant_pattern( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (parent.clone() == "Witness".to_string()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9362,7 +10055,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -9393,8 +10086,8 @@ pub fn emit_variant_pattern( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (field_binding_name_at(fb.clone(), source_indices.clone()) + == "0".to_string()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -9597,25 +10290,24 @@ pub fn emit_variant_pattern( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone() == "0".to_string()) { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -9626,15 +10318,13 @@ pub fn emit_variant_pattern( } } else { { - let is_shorthand = match (*fb_pat.clone()) - .clone() - { - MatchPattern::Bind { name: n, .. } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } - _ => false, - }; + let is_shorthand = + match (*fb_pat.clone()).clone() { + MatchPattern::Bind { + name: n, .. + } => (n.clone() == fb_name.clone()), + _ => false, + }; if is_shorthand.clone() { emit_ident( fb_name.clone(), @@ -9642,26 +10332,25 @@ pub fn emit_variant_pattern( ) } else { { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { + let field_path = if (fb_name.clone() + == "0".to_string()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let pat_str = emit_pattern( fb_pat.clone(), field_path.clone(), @@ -9732,7 +10421,7 @@ pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc { let mut __found = false; for name in rc_analysis.ref_bound_fields.clone().iter().cloned() { - if (name.clone().as_str() == field_name.clone().as_str()) { + if (name.clone() == field_name.clone()) { __found = true; break; } @@ -9768,8 +10457,7 @@ pub fn analyze_rc_pattern( ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone().as_str() - == "Present".to_string().as_str()) + 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![]), @@ -9799,18 +10487,17 @@ pub fn analyze_rc_pattern( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let inner_scrut = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - positional_payload_scrut_type( - resolved_parent.clone(), - n.clone(), - fb.clone(), - emit_info.clone(), - source_indices.clone(), - ) - } else { - "".to_string() - }; + let inner_scrut = if (fb_name.clone() == "0".to_string()) { + positional_payload_scrut_type( + resolved_parent.clone(), + n.clone(), + fb.clone(), + emit_info.clone(), + source_indices.clone(), + ) + } else { + "".to_string() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -9970,7 +10657,7 @@ pub fn emit_variant_pattern_rc_aware( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -9983,7 +10670,7 @@ pub fn emit_variant_pattern_rc_aware( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (parent.clone() == "Witness".to_string()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9995,7 +10682,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10034,8 +10721,8 @@ pub fn emit_variant_pattern_rc_aware( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (field_binding_name_at(fb.clone(), source_indices.clone()) + == "0".to_string()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10270,25 +10957,24 @@ pub fn emit_variant_pattern_rc_aware( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone() == "0".to_string()) { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -10316,10 +11002,7 @@ pub fn emit_variant_pattern_rc_aware( { MatchPattern::Bind { name: n, .. - } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } + } => (n.clone() == fb_name.clone()), _ => false, }; if is_shorthand.clone() { @@ -10329,26 +11012,26 @@ pub fn emit_variant_pattern_rc_aware( ) } else { { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { + let field_path = if (fb_name + .clone() + == "0".to_string()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let inner_analysis = analyze_rc_pattern( fb_pat.clone(), @@ -10456,7 +11139,7 @@ pub fn rc_pattern_preludes( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - if (fb_name.clone().as_str() == "0".to_string().as_str()) { + if (fb_name.clone() == "0".to_string()) { { let payload_scrut = positional_payload_scrut_type( resolved_parent.clone(), @@ -10479,9 +11162,7 @@ pub fn rc_pattern_preludes( source_indices.clone(), emit_info.clone(), ); - if (inner_preludes.clone().as_str() - == "".to_string().as_str()) - { + if (inner_preludes.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![inner_preludes.clone()]) @@ -10566,7 +11247,7 @@ pub fn explicit_record_struct_name( false }; let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone().as_str() == "__EmitTypeCacheMiss".to_string().as_str()) { + if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { type_name.clone() } else { if n_is_error { @@ -10615,141 +11296,30 @@ pub fn variant_parent_from_binding_kind( } } -pub fn apply_clone(expr: String) -> String { - apply_type_template1( - sharing_for_target(RenderTarget::Rust).clone_value.clone(), - expr, - ) -} - -pub fn apply_deref_clone(expr: String) -> String { - apply_type_template1( - sharing_for_target(RenderTarget::Rust).deref_clone.clone(), - expr, - ) -} - -pub fn apply_field_clone(expr: String, field: String) -> String { - apply_type_template2( - sharing_for_target(RenderTarget::Rust).field_clone.clone(), - expr, - field, - ) -} - -pub fn clone_iterator_suffix() -> String { - sharing_for_target(RenderTarget::Rust).clone_suffix.clone() -} - -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - match v1_rt::map_get(&variant_to_enum, name.clone()) { - Some(parent) => { - if parent.as_str() != "" { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier - } else { - rust_qualify_type_leaf_name(name, variant_to_enum) - } -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - } - } - __result - }) - .join("\n") -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut names: Vec = Vec::new(); - for item in items.iter().cloned() { - if is_type_def_item(item.clone()) - && item - .children - .clone() - .iter() - .all(|c| c.children.clone().len() as i64 == 0) - { - for child in item.children.clone().iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !names.iter().any(|n| n == &vname) - { - names.push(vname); - } - } - } - } - } - names - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env.clone()) - .iter() - .cloned() - { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - __result - }) - .join("\n") +pub fn apply_clone(expr: String) -> String { + apply_type_template1( + sharing_for_target(RenderTarget::Rust).clone_value.clone(), + expr, + ) +} + +pub fn apply_deref_clone(expr: String) -> String { + apply_type_template1( + sharing_for_target(RenderTarget::Rust).deref_clone.clone(), + expr, + ) +} + +pub fn apply_field_clone(expr: String, field: String) -> String { + apply_type_template2( + sharing_for_target(RenderTarget::Rust).field_clone.clone(), + expr, + field, + ) +} + +pub fn clone_iterator_suffix() -> String { + sharing_for_target(RenderTarget::Rust).clone_suffix.clone() } pub fn effective_variant_parent( @@ -10762,7 +11332,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().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { Some(p.clone()) } else { None @@ -10775,8 +11345,7 @@ pub fn effective_variant_parent( None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); - if (((rt.ident_span.clone() != None) - && (rt_name.clone().as_str() != name.clone().as_str())) + if (((rt.ident_span.clone() != None) && (rt_name.clone() != name.clone())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), name.clone(), @@ -10803,14 +11372,10 @@ pub fn emit_var_ref( emit_info: Rc, source_indices: Rc>>, ) -> String { - if ((name.clone().as_str() == "none".to_string().as_str()) - || (name.clone().as_str() == "None".to_string().as_str())) - { + if ((name.clone() == "none".to_string()) || (name.clone() == "None".to_string())) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((name.clone().as_str() == "true".to_string().as_str()) - || (name.clone().as_str() == "false".to_string().as_str())) - { + if ((name.clone() == "true".to_string()) || (name.clone() == "false".to_string())) { emit_keyword(name.clone(), RenderTarget::Rust) } else { { @@ -10826,9 +11391,9 @@ pub fn emit_var_ref( let ref_str = match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(name.clone()) - && (enum_name.clone().as_str() == "Optional".to_string().as_str())) + && (enum_name.clone() == "Optional".to_string())) { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -10918,14 +11483,10 @@ pub fn emit_typed_expr_base( .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) - { + if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((n.clone().as_str() == "true".to_string().as_str()) - || (n.clone().as_str() == "false".to_string().as_str())) - { + if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { emit_keyword(n.clone(), RenderTarget::Rust) } else { { @@ -10939,10 +11500,9 @@ pub fn emit_typed_expr_base( match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(n.clone()) - && (enum_name.clone().as_str() - == "Optional".to_string().as_str())) + && (enum_name.clone() == "Optional".to_string())) { - if (n.clone().as_str() == "Present".to_string().as_str()) { + if (n.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -10991,6 +11551,35 @@ pub fn emit_typed_expr_base( } } +pub fn field_access_field_is_boxed( + base: Rc, + field: String, + scope: Rc, + shared_types: Rc>, + emit_info: Rc, +) -> bool { + { + let base_struct = expand_type_for_field_access( + resolved_type(base), + scope.type_env.clone(), + scope.module_name.clone(), + ); + match find_child_named( + base_struct, + field, + scope.type_env.clone().source_indices.clone(), + ) { + Some(field_child) => needs_box_wrapping( + resolved_type(field_child.clone()), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ), + None => false, + } + } +} + pub fn emit_typed_field_access( base: Rc, field: String, @@ -11053,9 +11642,7 @@ pub fn emit_typed_field_access( if (authored_name_at( scope.type_env.clone().source_indices.clone(), pair.1.clone(), - ) - .as_str() - == field.clone().as_str()) + ) == field.clone()) { __result.push(pair); } @@ -11125,19 +11712,39 @@ pub fn emit_typed_field_access( } _ => false, }; - if base_is_owned { + let field_is_boxed = field_access_field_is_boxed( + base.clone(), + field.clone(), + scope.clone(), + shared_types.clone(), + emit_info.clone(), + ); + if field_is_boxed { v1_rt::concat( - v1_rt::concat(base_str, ".".to_string()), - emit_ident(field.clone(), RenderTarget::Rust), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(*".to_string(), base_str), + ".".to_string(), + ), + emit_ident(field.clone(), RenderTarget::Rust), + ), + ").clone()".to_string(), ) } else { - apply_type_template1( - sharing.clone_value.clone(), + if base_is_owned { v1_rt::concat( v1_rt::concat(base_str, ".".to_string()), emit_ident(field.clone(), RenderTarget::Rust), - ), - ) + ) + } else { + apply_type_template1( + sharing.clone_value.clone(), + v1_rt::concat( + v1_rt::concat(base_str, ".".to_string()), + emit_ident(field.clone(), RenderTarget::Rust), + ), + ) + } } } }, @@ -11192,7 +11799,7 @@ pub fn type_needs_rc_seen( } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); if (normed.inferred.clone() != None) { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11205,12 +11812,12 @@ pub fn type_needs_rc_seen( continue; } } else { - if ((canonical.clone().as_str() != "".to_string().as_str()) + if ((canonical.clone() != "".to_string()) && emit_map_has(seen.clone(), canonical.clone())) { break false; } else { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11248,6 +11855,7 @@ pub fn rust_runtime_bridge_name(function_name: String) -> String { pub fn rust_empty_map_value_type_str( map_type: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match map_type.children.clone().get(1 as usize).cloned() { @@ -11255,9 +11863,10 @@ pub fn rust_empty_map_value_type_str( let rendered = render_rust_type( child_type_node(value_child.clone()), shared_types, + corpus_repr, source_indices, ); - if (rendered.clone().as_str() == "".to_string().as_str()) { + if (rendered.clone() == "".to_string()) { "".to_string() } else { rendered.clone() @@ -11270,6 +11879,7 @@ pub fn rust_empty_map_value_type_str( pub fn rust_empty_map_kv_type_str( map_type: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -11277,6 +11887,7 @@ pub fn rust_empty_map_kv_type_str( Some(key_child) => render_rust_type( child_type_node(key_child.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ), None => "".to_string(), @@ -11284,11 +11895,10 @@ pub fn rust_empty_map_kv_type_str( let val_str = rust_empty_map_value_type_str( map_type.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ); - if ((key_str.clone().as_str() != "".to_string().as_str()) - && (val_str.clone().as_str() != "".to_string().as_str())) - { + 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(), @@ -11316,12 +11926,12 @@ pub fn rust_btree_set_element_ord_eligible( ) -> bool { { let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); - (((((((elem_name.clone().as_str() == "String".to_string().as_str()) - || (elem_name.clone().as_str() == "Int".to_string().as_str())) - || (elem_name.clone().as_str() == "Bool".to_string().as_str())) - || (elem_name.clone().as_str() == "Unit".to_string().as_str())) - || (elem_name.clone().as_str() == "Secret".to_string().as_str())) - || (elem_name.clone().as_str() == "Bytes".to_string().as_str())) + (((((((elem_name.clone() == "String".to_string()) + || (elem_name.clone() == "Int".to_string())) + || (elem_name.clone() == "Bool".to_string())) + || (elem_name.clone() == "Unit".to_string())) + || (elem_name.clone() == "Secret".to_string())) + || (elem_name.clone() == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -11394,7 +12004,7 @@ pub fn emit_rust_empty_set_expr( shared_types, source_indices.clone(), ); - if (elem_str.clone().as_str() != "".to_string().as_str()) { + if (elem_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_set::<".to_string(), @@ -11697,36 +12307,70 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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.module_name.clone(), + ); + let variant_name = match tn.clone() { + Some(n) => n.clone(), + None => "".to_string(), + }; + let peeled_type_name = if (((parent_enum.clone() == None) + && (expanded_rt.connective.clone() == Connective::Conj)) + && (expanded_rt.ident_span.clone() != None)) + { + { + let concrete = authored_name_at(si.clone(), expanded_rt.clone()); + if ((concrete.clone() != "".to_string()) + && (concrete.clone() != variant_name.clone())) + { + Some(concrete.clone()) + } else { + tn.clone() + } + } + } else { + tn.clone() + }; let raw = emit_typed_record_lit( - tn.clone(), + peeled_type_name, fs, parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), registry, scope.clone(), depth, shared_types.clone(), emit_info.clone(), ); - let si = scope.type_env.clone().source_indices.clone(); - let variant_name = match tn.clone() { - Some(n) => n.clone(), - None => "".to_string(), - }; let rc_name = match parent_enum.clone() { Some(en) => en.clone(), None => match contextual_variant_parent( variant_name.clone(), parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), emit_info.clone(), si.clone(), ) { - Some(p) => p, - None => variant_name.clone(), + Some(p) => p.clone(), + None => { + 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.clone() + } else { + variant_name.clone() + } + } }, }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + 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()) @@ -12161,7 +12805,7 @@ pub fn contextual_variant_parent( None => { let rt_name = authored_name_at(source_indices, resolved_type.clone()); if (((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != variant_name.clone().as_str())) + && (rt_name.clone() != variant_name.clone())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), variant_name.clone(), @@ -12204,7 +12848,7 @@ pub fn emit_discriminant_call_lowering( scope.clone(), depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ); let ty_name = @@ -12266,7 +12910,7 @@ pub fn emit_discriminant_call_lowering( ), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), ), ",".to_string(), @@ -12303,7 +12947,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } } @@ -12312,7 +12956,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), } } @@ -12329,15 +12973,16 @@ pub fn emit_typed_call_expr( emit_info: Rc, ) -> String { { - let call_str = if (func.clone().as_str() == "empty_map".to_string().as_str()) { + let call_str = if (func.clone() == "empty_map".to_string()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( ret_type.clone(), shared_types, + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -12354,7 +12999,7 @@ pub fn emit_typed_call_expr( .to_string(), } } else { - if (func.clone().as_str() == "empty_set".to_string().as_str()) { + if (func.clone() == "empty_set".to_string()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( @@ -12398,7 +13043,7 @@ pub fn emit_typed_call( emit_info: Rc, ) -> String { { - if (func.clone().as_str() == "get".to_string().as_str()) { + if (func.clone() == "get".to_string()) { { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); @@ -12442,7 +13087,7 @@ pub fn emit_typed_call( return get_result; } } - if (func.clone().as_str() == "with".to_string().as_str()) { + if (func.clone() == "with".to_string()) { { let with_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); if ((with_args.clone().len() as i64) == 0) { @@ -12540,7 +13185,7 @@ pub fn emit_typed_call( } } } - if (func.clone().as_str() == "to_string".to_string().as_str()) { + if (func.clone() == "to_string".to_string()) { { let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12561,45 +13206,24 @@ pub fn emit_typed_call( ), ").to_string()".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), None => "compile_error!(\"to_string call missing value argument\")".to_string(), }; return ts_result; } } - if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { + if (func.clone() == "utf8_decode_bytes".to_string()) { { let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let decode_result = match decode_args.first().cloned() { - Some(value_arg) => v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "String::from_utf8(".to_string(), - emit_typed_expr( - arg_value(value_arg.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ), - ), - ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" - .to_string(), - ), - "".to_string(), - ), - None => { - "compile_error!(\"utf8_decode_bytes call missing value argument\")" - .to_string() - } - }; + Some(value_arg) => v1_rt::concat(v1_rt::concat("String::from_utf8(".to_string(), emit_typed_expr(arg_value(value_arg.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)), ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?".to_string()), + None => "compile_error!(\"utf8_decode_bytes call missing value argument\")".to_string(), +}; return decode_result; } } - if (func.clone().as_str() == "discriminant".to_string().as_str()) { + if (func.clone() == "discriminant".to_string()) { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { @@ -12618,10 +13242,10 @@ pub fn emit_typed_call( return disc_result; } } - let collection_scope = if ((((func.clone().as_str() == "map".to_string().as_str()) - || (func.clone().as_str() == "filter".to_string().as_str())) - || (func.clone().as_str() == "flat_map".to_string().as_str())) - || (func.clone().as_str() == "fold".to_string().as_str())) + let collection_scope = if ((((func.clone() == "map".to_string()) + || (func.clone() == "filter".to_string())) + || (func.clone() == "flat_map".to_string())) + || (func.clone() == "fold".to_string())) { { let call_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12796,8 +13420,7 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt.clone() - && (func.clone().as_str() == "concat".to_string().as_str())) + 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.clone(), "".to_string(), shared_types.clone()) @@ -12853,12 +13476,11 @@ pub fn fill_default_args( let is_provided = { let mut __found = false; for n in provided_names.clone().iter().cloned() { - if (n.clone().as_str() + if (n.clone() == param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str()) + )) { __found = true; break; @@ -12971,7 +13593,7 @@ pub fn emit_nested_rt_concat( break acc.clone(); } Some(arg) => { - let next_acc = if (acc.clone().as_str() == "".to_string().as_str()) { + let next_acc = if (acc.clone() == "".to_string()) { arg.clone() } else { v1_rt::concat( @@ -13171,6 +13793,7 @@ pub fn emit_typed_slice( pub fn collection_element_type( receiver_type: Option>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match receiver_type.as_deref().cloned() { @@ -13196,6 +13819,7 @@ pub fn collection_element_type( render_rust_type( elem_node.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -13252,6 +13876,7 @@ pub fn lambda_param_type_strs( param_nodes: Rc>>, fallback_types: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> Rc> { Rc::new({ @@ -13291,6 +13916,7 @@ pub fn lambda_param_type_strs( Some(render_rust_type( param_type.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), )) } @@ -13354,6 +13980,7 @@ pub fn emit_typed_collection_lambda( pn.clone(), Rc::new(vec![elem_type_str]), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13364,7 +13991,7 @@ pub fn emit_typed_collection_lambda( lambda_scope, depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ); v1_rt::concat( @@ -13378,7 +14005,7 @@ pub fn emit_typed_collection_lambda( scope.clone(), depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ), } @@ -13410,10 +14037,9 @@ pub fn emit_typed_fold_lambda( .skip(1 as usize) .collect::>(), ); - let safe_acc_type = if (((acc_type_str.clone().as_str() - == "Rc>".to_string().as_str()) - || (acc_type_str.clone().as_str() == "Vec<()>".to_string().as_str())) - || (acc_type_str.clone().as_str() == "Option<()>".to_string().as_str())) + let safe_acc_type = if (((acc_type_str.clone() == "Rc>".to_string()) + || (acc_type_str.clone() == "Vec<()>".to_string())) + || (acc_type_str.clone() == "Option<()>".to_string())) { "_".to_string() } else { @@ -13445,6 +14071,7 @@ pub fn emit_typed_fold_lambda( Rc::new(vec![]), fallback_types, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13462,7 +14089,7 @@ pub fn emit_typed_fold_lambda( Some(n) => n.clone(), None => "".to_string(), }; - let needs_unwrap = ((acc_name.clone().as_str() != "".to_string().as_str()) + let needs_unwrap = ((acc_name.clone() != "".to_string()) && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); if needs_unwrap { { @@ -13534,6 +14161,7 @@ pub fn emit_rust_fold_method_call( let elem_type_str = collection_element_type( receiver.inferred.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { @@ -13685,6 +14313,7 @@ pub fn emit_rust_fold_method_call( ), 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(), }), None => emit_info.clone(), } @@ -13717,6 +14346,7 @@ pub fn emit_rust_fold_method_call( owned_bindings: emit_info.owned_bindings.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(), }), None => emit_info.clone(), } @@ -13730,6 +14360,7 @@ pub fn emit_rust_fold_method_call( let acc_type_str = render_rust_type( acc_type_node.clone(), shared_types.clone(), + 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) { @@ -13790,18 +14421,19 @@ pub fn emit_rust_fold_method_call( arg_value(init_arg.clone()), scope.type_env.clone().source_indices.clone(), ); - if ((((init_func.clone().as_str() == "empty_map".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + if ((((init_func.clone() == "empty_map".to_string()) + && (acc_type_str.clone() != "_".to_string())) + && (acc_type_str.clone() != "".to_string())) && !acc_has_unit_child.clone()) { { let kv_type_str = rust_empty_map_kv_type_str( acc_type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -13814,13 +14446,12 @@ pub fn emit_rust_fold_method_call( } } } else { - if (init_func.clone().as_str() == "empty_map".to_string().as_str()) { + if (init_func.clone() == "empty_map".to_string()) { "Rc::new(HashMap::new()) /* BRIDGE: fold empty_map accumulator type unresolved */".to_string() } else { - if ((((init_func.clone().as_str() - == "empty_set".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + 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()) { emit_rust_empty_set_expr( @@ -13829,8 +14460,7 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func.clone().as_str() == "empty_set".to_string().as_str()) - { + if (init_func.clone() == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -13927,6 +14557,7 @@ pub fn emit_rust_sort_by_method_call( render_rust_type( elem.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ) } else { @@ -13951,7 +14582,7 @@ pub fn emit_rust_sort_by_method_call( let iter_str = apply_type_template1(sharing.iter_owned.clone(), recv_str); let a_clone = apply_type_template1(sharing.clone_value.clone(), "a".to_string()); let b_clone = apply_type_template1(sharing.clone_value.clone(), "b".to_string()); - if (elem_type_str.clone().as_str() == "_".to_string().as_str()) { + 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()) @@ -14438,9 +15069,7 @@ pub fn emit_rust_first_method_call( if (expr_method_name_at( receiver.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "skip".to_string().as_str()) + ) == "skip".to_string()) { { let skip_recv = method_receiver(receiver.clone()); @@ -14678,9 +15307,7 @@ pub fn emit_typed_method_call( if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), - ) - .as_str() - == "serde_json::Value".to_string().as_str()) + ) == "serde_json::Value".to_string()) { __result.push(p); } @@ -14777,7 +15404,7 @@ pub fn emit_typed_method_call( scope.type_env.clone().source_indices.clone(), method_def.clone(), ); - if (method_name.clone().as_str() == "fold".to_string().as_str()) { + if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( method_call_node, fold_accumulator_type.clone(), @@ -14791,7 +15418,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "sort_by".to_string().as_str()) { + if (method_name.clone() == "sort_by".to_string()) { emit_rust_sort_by_method_call( receiver.clone(), args.clone(), @@ -14802,7 +15429,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "map".to_string().as_str()) { + if (method_name.clone() == "map".to_string()) { emit_rust_map_method_call( receiver.clone(), args.clone(), @@ -14816,9 +15443,7 @@ pub fn emit_typed_method_call( match Rc::new({ let mut __result = Vec::new(); for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone().as_str() - == method_name.clone().as_str()) - { + if (s.method_name.clone() == method_name.clone()) { __result.push(s); } } @@ -14838,8 +15463,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ), None => { - if (method_name.clone().as_str() == "get".to_string().as_str()) - { + if (method_name.clone() == "get".to_string()) { emit_rust_get_method_call( receiver.clone(), args.clone(), @@ -14850,9 +15474,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "with".to_string().as_str()) - { + if (method_name.clone() == "with".to_string()) { emit_rust_with_method_call( receiver.clone(), args.clone(), @@ -14863,8 +15485,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "string_contains".to_string().as_str()) + if (method_name.clone() + == "string_contains".to_string()) { emit_rust_generic_method_call( "string_contains".to_string(), @@ -14878,9 +15500,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "concat".to_string().as_str()) - { + if (method_name.clone() == "concat".to_string()) { { let recv_str = emit_typed_expr( receiver.clone(), @@ -14917,8 +15537,7 @@ pub fn emit_typed_method_call( ) } } else { - if (method_name.clone().as_str() - == "first".to_string().as_str()) + if (method_name.clone() == "first".to_string()) { emit_rust_first_method_call( receiver.clone(), @@ -15309,8 +15928,8 @@ pub fn emit_typed_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) + let guard_str = if ((field_guards.clone() != "".to_string()) + && (arm_guard_str.clone() != "".to_string())) { v1_rt::concat( v1_rt::concat( @@ -15320,10 +15939,10 @@ pub fn emit_typed_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { + if (field_guards.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { + if (arm_guard_str.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -15585,14 +16204,13 @@ pub fn wrap_rust_record_field_value( field_name: String, ) -> String { { - let is_bounded_lattice_field = - (struct_name.clone().as_str() == "BoundedLattice".to_string().as_str()); + let is_bounded_lattice_field = (struct_name.clone() == "BoundedLattice".to_string()); if rust_record_field_needs_fn_rc(scope.clone(), struct_name.clone(), field_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "meet".to_string().as_str()) - || (field_name.clone().as_str() == "join".to_string().as_str()))) + && ((field_name.clone() == "meet".to_string()) + || (field_name.clone() == "join".to_string()))) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -15606,8 +16224,8 @@ pub fn wrap_rust_record_field_value( v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "top".to_string().as_str()) - || (field_name.clone().as_str() == "bottom".to_string().as_str()))) + && ((field_name.clone() == "top".to_string()) + || (field_name.clone() == "bottom".to_string()))) { v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { @@ -15638,16 +16256,13 @@ pub fn is_already_optional( binding_kind: binding_kind, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) - || (n.clone().as_str() == "Absent".to_string().as_str())) + if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true } else { - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) - { + if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { match texpr.inferred.clone().as_deref().cloned() { @@ -15671,8 +16286,8 @@ pub fn is_already_optional( } => match tn { Some(name) => { ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) - && ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str()))) + && ((name.clone() == "Present".to_string()) + || (name.clone() == "Absent".to_string()))) } None => false, }, @@ -15894,7 +16509,7 @@ pub fn emit_field_value_with_context( Some(en) => en.clone(), None => variant_name.clone(), }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + 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()) @@ -16146,10 +16761,15 @@ pub fn emit_typed_record_lit( false }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); - if ((((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != tn.clone().as_str())) + if (((((resolved_type.ident_span.clone() != None) + && (rt_name.clone() != tn.clone())) && !rt_is_type_var) - && (rt_name.clone().as_str() != "Error".to_string().as_str())) + && (rt_name.clone() != "Error".to_string())) + && variant_belongs_to_enum( + emit_info.type_summaries.clone(), + tn.clone(), + rt_name.clone(), + )) { Some(rt_name.clone()) } else { @@ -16161,7 +16781,7 @@ pub fn emit_typed_record_lit( && (is_optional_parent(parent_enum.clone()) || is_optional_parent(effective_parent.clone()))); let rust_tn = if optional_variant.clone() { - if (tn.clone().as_str() == "Present".to_string().as_str()) { + if (tn.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -16180,8 +16800,7 @@ pub fn emit_typed_record_lit( None => rust_tn, } }; - if ((optional_variant.clone() - && (tn.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -16221,8 +16840,8 @@ pub fn emit_typed_record_lit( let is_positional_ctor = (((fields.clone().len() as i64) == 1) && match fields.clone().first().cloned() { Some(f) => { - (field_init_node_name_at(f.clone(), si.clone()).as_str() - == "0".to_string().as_str()) + (field_init_node_name_at(f.clone(), si.clone()) + == "0".to_string()) } None => false, }); @@ -16384,18 +17003,13 @@ pub fn emit_typed_record_lit( &ftm, fname.clone(), ) { - Some(ft) => { - match rust_zero_value( - ft.clone(), - scope - .type_env - .source_indices - .clone(), - ) { - Some(_) => true, - None => false, - } - } + Some(ft) => match rust_zero_value( + ft.clone(), + emit_info.corpus_repr.clone(), + ) { + Some(_) => true, + None => false, + }, None => false, }; (has_zv.clone() @@ -16419,10 +17033,7 @@ pub fn emit_typed_record_lit( Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { match v1_rt::map_get(&ftm, fname.clone()) { - Some(ft) => match rust_zero_value( - ft.clone(), - scope.type_env.source_indices.clone(), - ) { + Some(ft) => match rust_zero_value(ft.clone(), emit_info.corpus_repr.clone()) { Some(zv) => Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": ".to_string()), zv.clone()), ",".to_string())]), None => Rc::new(vec![]), }, @@ -16438,7 +17049,48 @@ pub fn emit_typed_record_lit( } None => Rc::new(vec![]), }; - let all_field_strs = v1_rt::concat(field_strs, default_strs); + let phantom_strs = match lookup_type_by_name( + scope.type_env.clone(), + tn.clone(), + ) { + Some(struct_decl) => { + let is_struct = (struct_decl.connective.clone() + == Connective::Conj); + let pnames = Rc::new({ + let mut __result = Vec::new(); + for p in struct_decl.params.clone().iter().cloned() + { + __result.push(generic_param_name_at( + p.clone(), + si.clone(), + )); + } + __result + }); + let unused = struct_unused_param_names( + pnames, + struct_decl.children.clone(), + si.clone(), + ); + let has_unused = ((unused.len() as i64) > 0); + if (is_struct && has_unused) { + Rc::new(vec![v1_rt::concat( + v1_rt::concat( + " ".to_string(), + rust_phantom_field_name(), + ), + ": std::marker::PhantomData,".to_string(), + )]) + } else { + Rc::new(vec![]) + } + } + None => Rc::new(vec![]), + }; + let all_field_strs = v1_rt::concat( + v1_rt::concat(field_strs, default_strs), + phantom_strs, + ); let fields_str = all_field_strs.join(&"\n".to_string()); let raw = v1_rt::concat( v1_rt::concat( @@ -16458,18 +17110,15 @@ pub fn emit_typed_record_lit( } } -pub fn rust_zero_value( - type_name: String, - source_indices: Rc>>, -) -> Option { - if (type_name.clone().as_str() == "Int".to_string().as_str()) { +pub fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> Option { + if (type_name.clone() == "Int".to_string()) { Some("0".to_string()) } else { - if (type_name.clone().as_str() == "Bool".to_string().as_str()) { + if (type_name.clone() == "Bool".to_string()) { Some("false".to_string()) } else { - if (type_name.clone().as_str() == "String".to_string().as_str()) { - if rust_emit_faithful_text_carrier(source_indices) { + if (type_name.clone() == "String".to_string()) { + if corpus_repr_is_faithful(corpus_repr) { Some( "crate::v2_std_algebra::freemonoid_empty::()" .to_string(), @@ -16537,8 +17186,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - scope.type_env.clone().source_indices.clone(), + l_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16551,8 +17200,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), - scope.type_env.clone().source_indices.clone(), + r_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16584,12 +17233,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + l_str, + emit_info.corpus_repr.clone(), ), ), " ".to_string(), @@ -16599,8 +17244,8 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), - scope.type_env.clone().source_indices.clone(), + r_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16733,7 +17378,7 @@ pub fn emit_typed_string_interp( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (a.clone() != "".to_string()) { __result.push(a); } } @@ -16742,7 +17387,7 @@ pub fn emit_typed_string_interp( if ((args.clone().len() as i64) == 0) { emit_rust_host_to_dag_string_via_seam( v1_rt::concat(v1_rt::concat("\"".to_string(), fmt_str), "\"".to_string()), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } else { { @@ -16758,7 +17403,7 @@ pub fn emit_typed_string_interp( ), ")".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } } @@ -16919,9 +17564,7 @@ pub fn emit_tco_init_stmt( if (param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + ) == n.clone()) { __found = true; break; @@ -17275,9 +17918,7 @@ pub fn emit_rust_tco_let( if (param_node_name_at( p.clone(), frame.scope.clone().type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + ) == n.clone()) { __found = true; break; @@ -17564,8 +18205,8 @@ pub fn emit_typed_tco_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) + let guard_str = if ((field_guards.clone() != "".to_string()) + && (arm_guard_str.clone() != "".to_string())) { v1_rt::concat( v1_rt::concat( @@ -17575,10 +18216,10 @@ pub fn emit_typed_tco_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { + if (field_guards.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { + if (arm_guard_str.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -17648,10 +18289,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()).as_str() - == var_name.clone().as_str()) - } + } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -17838,6 +18476,7 @@ pub fn emit_service_def( item: Rc, registry: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -17857,6 +18496,7 @@ pub fn emit_service_def( op_children.clone(), registry, shared_types, + corpus_repr, env.clone(), item.clone(), ); @@ -17936,6 +18576,7 @@ pub fn emit_service_impl( op_children: Rc>>, registry: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -17958,6 +18599,7 @@ pub fn emit_service_impl( registry.clone(), (depth.clone() + 1), shared_types.clone(), + corpus_repr.clone(), env.clone(), service_item.clone(), )); @@ -18023,7 +18665,7 @@ pub fn emit_service_new_method( }, None => "".to_string(), }; - let base_url_default = if (from_config.clone().as_str() != "".to_string().as_str()) { + let base_url_default = if (from_config.clone() != "".to_string()) { from_config.clone() } else { if fs.has_rest.clone() { @@ -18048,7 +18690,7 @@ pub fn emit_service_new_method( } else { "".to_string() }; - if (from_fallback.clone().as_str() != "".to_string().as_str()) { + if (from_fallback.clone() != "".to_string()) { from_fallback.clone() } else { "http://localhost".to_string() @@ -18116,7 +18758,7 @@ pub fn emit_auth_source_ctor( ) -> String { match (*source_expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { - Some(variant) => if (variant.clone().as_str() == "EnvVar".to_string().as_str()) { + 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()) }, @@ -18160,6 +18802,7 @@ pub fn emit_operation_method( registry: Rc>>, depth: i64, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18180,15 +18823,17 @@ pub fn emit_operation_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -18196,6 +18841,7 @@ pub fn emit_operation_method( let ret_type = render_rust_type( resolved_type(op_node.clone()), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), ); let eff_transport = effective_operation_transport(op_node.clone(), transport); @@ -18210,6 +18856,7 @@ pub fn emit_operation_method( op_node.clone(), env.source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), ); let mock_props = Rc::new({ @@ -18233,6 +18880,7 @@ pub fn emit_operation_method( op_node.clone(), env.clone(), shared_types.clone(), + corpus_repr.clone(), ); let body = v1_rt::concat( v1_rt::concat( @@ -18314,6 +18962,7 @@ pub fn emit_dry_run_branch_from_props( op_node: Rc, env: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, ) -> String { { let log_line = v1_rt::concat( @@ -18351,7 +19000,7 @@ let prelude = match wire_opt.clone() { 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, source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) +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()) } }, None => v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()), @@ -18370,7 +19019,7 @@ let raw = match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed dry-run: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for mock field: ".to_string()), ch_name.clone()), "\");".to_string()), }; @@ -18393,13 +19042,6 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } } } else { - // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single - // authority): compile_error! -> panic! in the dry-run missing-fixture branch. - // Applied by hand because regen-fixpoint is temporarily broken (§7 hole). - // DISSOLUTION lane: bright-stag's adhoc-1bdd0259-2e3 (re-repair the hole + add a - // regen-equals-committed CI drift-gate). When it lands, a clean regen reproduces - // this line from the .dag — delete this hand-patch; the dissolution check is - // regen-output == this mirror modulo HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -18424,6 +19066,7 @@ pub fn emit_transport_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { if is_rest_transport(transport.clone(), source_indices.clone()) { @@ -18436,6 +19079,7 @@ pub fn emit_transport_call( op_node, source_indices.clone(), shared_types, + corpus_repr, env, ) } else { @@ -18447,6 +19091,7 @@ pub fn emit_transport_call( depth, inferred, op_node, + corpus_repr, source_indices.clone(), ) } else { @@ -18468,6 +19113,7 @@ pub fn emit_rest_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -18482,7 +19128,11 @@ pub fn emit_rest_call( http_method, source_indices.clone(), ); - let query_line = emit_rest_query_line(transport.clone(), source_indices.clone()); + let query_line = emit_rest_query_line( + transport.clone(), + corpus_repr.clone(), + source_indices.clone(), + ); let body_line = emit_rest_body_line(transport.clone(), source_indices.clone()); let headers = transport_headers(transport.clone(), source_indices.clone()); let header_lines = Rc::new({ @@ -18515,6 +19165,7 @@ pub fn emit_rest_call( transport.clone(), source_indices.clone(), shared_types, + corpus_repr.clone(), env, ); let all_lines = Rc::new({ @@ -18529,7 +19180,7 @@ pub fn emit_rest_call( .iter() .cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -18774,6 +19425,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_rest_query_line( transport: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match transport_query(transport, source_indices.clone()) { @@ -18796,7 +19448,7 @@ pub fn emit_rest_query_line( RenderTarget::Rust, source_indices.clone(), ), - source_indices.clone(), + corpus_repr.clone(), ), ), ")".to_string(), @@ -18859,7 +19511,7 @@ pub fn has_response_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 9) { false } else { - (v1_rt::substring(&name, 0, 9).as_str() == "response_".to_string().as_str()) + (v1_rt::substring(&name, 0, 9) == "response_".to_string()) } } @@ -18870,8 +19522,8 @@ pub fn child_from_key( match Rc::new({ let mut __result = Vec::new(); for p in ch.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "from_key".to_string()) { __result.push(p); } @@ -18925,8 +19577,8 @@ pub fn has_response_200_property( { let mut __found = false; for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "response_200".to_string()) { __found = true; break; @@ -18944,8 +19596,8 @@ pub fn operation_response_200_resolved_type( match Rc::new({ let mut __result = Vec::new(); for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "response_200".to_string()) { __result.push(p); } @@ -18964,7 +19616,7 @@ pub fn operation_response_200_resolved_type( source_indices.clone(), normalize_access_type_node(v.clone()), ); - if (type_name.clone().as_str() == "".to_string().as_str()) { + if (type_name.clone() == "".to_string()) { None } else { lookup_type_by_name(env, type_name.clone()) @@ -18982,7 +19634,7 @@ pub fn is_json_wire_declaration_type( ) -> bool { { let n = authored_name_at(source_indices, normalize_access_type_node(t)); - if (n.clone().as_str() == "Json".to_string().as_str()) { + if (n.clone() == "Json".to_string()) { true } else { { @@ -18993,7 +19645,7 @@ pub fn is_json_wire_declaration_type( .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone().as_str() == "Json".to_string().as_str()), + Some(last) => (last.clone() == "Json".to_string()), None => false, } } @@ -19044,7 +19696,7 @@ pub fn wire_child_for_segment( Some(k) => k.clone(), None => authored.clone(), }; - (wire_key.clone().as_str() == seg.clone().as_str()) + (wire_key.clone() == seg.clone()) } { __result.push(ch); } @@ -19160,7 +19812,7 @@ pub fn emit_wire_struct_path_chain( .iter() .cloned() { - if (s.clone().as_str() != "".to_string().as_str()) { + if (s.clone() != "".to_string()) { __result.push(s); } } @@ -19226,6 +19878,7 @@ pub fn emit_json_value_extract( var_name: String, from_path: String, dag_type_name: String, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19247,9 +19900,8 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); - let is_dag_string = dag_type_name.as_str() == "String"; - let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); - let accessor = if is_dag_string { + let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name.clone()); + let accessor = if (dag_type_name.clone() == "String".to_string()) { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19257,7 +19909,7 @@ pub fn emit_json_value_extract( ".and_then(|v| v.as_str()).map(|s| ".to_string(), emit_rust_host_to_dag_string_via_seam( "s.to_string()".to_string(), - source_indices.clone(), + corpus_repr, ), ), ").ok_or(\"missing field: ".to_string(), @@ -19267,7 +19919,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "i64".to_string().as_str()) { + if (rust_type.clone() == "i64".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_i64()).ok_or(\"missing field: ".to_string(), @@ -19276,7 +19928,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "f64".to_string().as_str()) { + if (rust_type.clone() == "f64".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_f64()).ok_or(\"missing field: ".to_string(), @@ -19285,7 +19937,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "bool".to_string().as_str()) { + 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(), @@ -19322,6 +19974,7 @@ pub fn emit_from_key_extraction( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19359,6 +20012,7 @@ pub fn emit_from_key_extraction( render_rust_type( wire_ty, shared_types, + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19388,7 +20042,7 @@ match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed response: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for output field: ".to_string()), ch_name.clone()), "\");".to_string()), } @@ -19443,8 +20097,7 @@ pub fn emit_plain_response_body( { let is_text = match transport_response_format(transport, source_indices.clone()) { Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()).as_str() - == "Text".to_string().as_str()) + (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) } None => false, }; @@ -19461,6 +20114,7 @@ pub fn emit_response_code_handling( transport: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19480,6 +20134,7 @@ pub fn emit_response_code_handling( op_node.clone(), source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), ) } else { @@ -19497,6 +20152,7 @@ pub fn emit_response_code_handling( transport.clone(), source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), )); } @@ -19528,21 +20184,22 @@ pub fn emit_response_arm( transport: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 9, v1_rt::string_length(&name)); let is_success = if (v1_rt::string_length(&code_str) >= 1) { - (v1_rt::substring(&code_str, 0, 1).as_str() == "2".to_string().as_str()) + (v1_rt::substring(&code_str, 0, 1) == "2".to_string()) } else { false }; - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (code_str.clone() == "nonzero".to_string()) { "_".to_string() } else { if ((v1_rt::string_length(&code_str) == 3) - && (v1_rt::substring(&code_str, 1, 3).as_str() == "xx".to_string().as_str())) + && (v1_rt::substring(&code_str, 1, 3) == "xx".to_string())) { { let prefix = v1_rt::substring(&code_str, 0, 1); @@ -19570,6 +20227,7 @@ pub fn emit_response_arm( op_node, source_indices.clone(), shared_types, + corpus_repr, env, ), ), @@ -19597,13 +20255,14 @@ pub fn has_exit_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5).as_str() == "exit_".to_string().as_str()) + (v1_rt::substring(&name, 0, 5) == "exit_".to_string()) } } pub fn emit_exit_code_handling( op_node: Rc, inferred: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19623,8 +20282,8 @@ pub fn emit_exit_code_handling( let has_nonzero = { let mut __found = false; for p in exit_props.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "exit_nonzero".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "exit_nonzero".to_string()) { __found = true; break; @@ -19638,6 +20297,7 @@ pub fn emit_exit_code_handling( __result.push(emit_exit_arm( p.clone(), inferred.clone(), + corpus_repr.clone(), source_indices.clone(), )); } @@ -19646,16 +20306,7 @@ pub fn emit_exit_code_handling( let default_arm = if has_nonzero { "".to_string() } else { - v1_rt::concat( - v1_rt::concat( - "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), - emit_rust_host_to_dag_string_via_seam( - "stderr".to_string(), - source_indices.clone(), - ), - ), - ") },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr.clone())), ") },".to_string()) }; v1_rt::concat( v1_rt::concat( @@ -19678,17 +20329,18 @@ pub fn emit_exit_code_handling( pub fn emit_exit_arm( prop: Rc, inferred: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 5, v1_rt::string_length(&name)); - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (code_str.clone() == "nonzero".to_string()) { "_".to_string() } else { code_str.clone() }; - let is_success = (code_str.clone().as_str() == "0".to_string().as_str()); + let is_success = (code_str.clone() == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -19701,22 +20353,7 @@ pub fn emit_exit_arm( " },".to_string(), ) } else { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(" ".to_string(), pattern), - " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), - ), - emit_rust_host_to_dag_string_via_seam( - "stderr".to_string(), - source_indices.clone(), - ), - ), - ") },".to_string(), - ), - "".to_string(), - ) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string()), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr)), ") },".to_string()) } } } @@ -19728,6 +20365,7 @@ pub fn emit_shell_call( depth: i64, inferred: Rc, op_node: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19772,6 +20410,7 @@ pub fn emit_shell_call( emit_shell_argv_element( first_arg.clone(), optional_params.clone(), + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19813,6 +20452,7 @@ pub fn emit_shell_call( emit_shell_argv_element( arg.clone(), optional_params.clone(), + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19873,8 +20513,12 @@ pub fn emit_shell_call( let wait_line = "let output = output.wait_with_output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = - emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); + let return_line = emit_exit_code_handling( + op_node.clone(), + inferred, + corpus_repr.clone(), + source_indices.clone(), + ); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![ @@ -19894,8 +20538,12 @@ pub fn emit_shell_call( let output_line = " .output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = - emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); + let return_line = emit_exit_code_handling( + op_node.clone(), + inferred, + corpus_repr.clone(), + source_indices.clone(), + ); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![wd_line, output_line, check_line, return_line]), @@ -19909,6 +20557,7 @@ pub fn emit_shell_call( pub fn emit_shell_argv_element( arg: Rc, optional_params: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match (*arg.expr_data.clone()).clone() { @@ -20007,10 +20656,10 @@ pub fn emit_shell_argv_element( if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), - source_indices.clone(), + corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), source_indices.clone()) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) } } _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), @@ -20077,7 +20726,7 @@ pub fn emit_shell_return( } __result }); - let lines = if (stderr_line.clone().as_str() != "".to_string().as_str()) { + let lines = if (stderr_line.clone() != "".to_string()) { v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() @@ -20104,13 +20753,13 @@ pub fn emit_shell_return( pub fn emit_shell_channel_expr(channel: String, is_optional: bool) -> String { { - let base = if (channel.clone().as_str() == "exit_success".to_string().as_str()) { + let base = if (channel.clone() == "exit_success".to_string()) { "output.status.success()".to_string() } else { - if (channel.clone().as_str() == "stderr".to_string().as_str()) { + if (channel.clone() == "stderr".to_string()) { "stderr.clone()".to_string() } else { - if (channel.clone().as_str() == "stdout_lines".to_string().as_str()) { + if (channel.clone() == "stdout_lines".to_string()) { "Rc::new(stdout.lines().filter(|l| !l.is_empty()).map(|l| l.trim().to_string()).collect())".to_string() } else { "stdout.clone()".to_string() @@ -20182,6 +20831,7 @@ pub fn emit_local_call(op_name: String) -> String { pub fn emit_resource_def( item: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20204,6 +20854,7 @@ pub fn emit_resource_def( __result.push(emit_capability_method( c.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), )); } @@ -20234,6 +20885,7 @@ pub fn emit_resource_def( pub fn emit_capability_method( cap_node: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20252,15 +20904,17 @@ pub fn emit_capability_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -20268,6 +20922,7 @@ pub fn emit_capability_method( let ret = render_rust_type( resolved_type(cap_node.clone()), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), ); let items = rust_items(); @@ -20356,10 +21011,11 @@ pub fn emit_data_def( let raw_ty_str = render_rust_type_with_applied_binding( render_type_node, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - let ty_str = if ((raw_ty_str.clone().as_str() == "BoundedLattice".to_string().as_str()) - || (raw_ty_str.clone().as_str() == "Rc".to_string().as_str())) + let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) + || (raw_ty_str.clone() == "Rc".to_string())) { match field_value_by_name( value.clone(), @@ -20371,12 +21027,10 @@ pub fn emit_data_def( scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); - if (top_type_name.clone().as_str() == "".to_string().as_str()) { + if (top_type_name.clone() == "".to_string()) { raw_ty_str.clone() } else { - if (raw_ty_str.clone().as_str() - == "Rc".to_string().as_str()) - { + if (raw_ty_str.clone() == "Rc".to_string()) { v1_rt::concat( v1_rt::concat( "Rc { let lattice_value = field_value_by_name( @@ -20678,38 +21333,31 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( + v1_rt::concat( + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + v1_rt::concat( + "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), ), + "\"".to_string(), ), - "\"".to_string(), + emit_info.corpus_repr.clone(), ), - scope - .type_env - .clone() - .source_indices - .clone(), - ), - ), - v1_rt::concat( - v1_rt::concat( - ", ".to_string(), - val_str.clone(), ), - ");".to_string(), + ", ".to_string(), ), + val_str.clone(), ), - "".to_string(), + ");".to_string(), ) }); } @@ -20785,13 +21433,18 @@ pub fn emit_data_def_body( pub fn emit_test_file( module_name: String, projections: Rc>>, + corpus_repr: RustCorpusRepr, ) -> Rc { { let depth = 0; let test_fns = Rc::new({ let mut __result = Vec::new(); for p in projections.iter().cloned() { - __result.push(emit_operation_test(p.clone(), (depth.clone() + 1))); + __result.push(emit_operation_test( + p.clone(), + (depth.clone() + 1), + corpus_repr.clone(), + )); } __result }); @@ -20842,13 +21495,16 @@ pub fn emit_test_file( } } -pub fn rust_test_signature_comment(projection: Rc) -> String { +pub fn rust_test_signature_comment( + projection: Rc, + corpus_repr: RustCorpusRepr, +) -> String { { let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), + bindings: v1_rt::rc_empty_map::>(), recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::>>>(), source_indices: projection.source_indices.clone(), intern_table: empty_intern_table(), }); @@ -20864,7 +21520,9 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { param_node_type_expr(p.clone()), Rc::new(vec![]), v1_rt::rc_empty_set::(), + corpus_repr.clone(), projection.source_indices.clone(), + v1_rt::rc_empty_map::(), stub_env.clone(), ), )); @@ -20901,7 +21559,11 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { } } -pub fn emit_operation_test(projection: Rc, depth: i64) -> String { +pub fn emit_operation_test( + projection: Rc, + depth: i64, + corpus_repr: RustCorpusRepr, +) -> String { { let test_name = rust_test_name(projection.clone()); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -20918,12 +21580,12 @@ pub fn emit_operation_test(projection: Rc, depth: i64) -> String __result }); let args_str = param_args.join(&", ".to_string()); - let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { + let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { 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())), "\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.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()) } } @@ -21020,8 +21682,8 @@ pub fn emit_cargo_dep(name: String, version: String, features: Rc>) pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { { let header = v1_rt::concat( - v1_rt::concat("[package]\nname = \"".to_string(), crate_name), - "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n".to_string(), + format!("[package]\nname = \"{}\"\nversion = \"0.1.0\"", crate_name), + "\nedition = \"2021\"\n".to_string(), ); let workspace = "\n[workspace]\n".to_string(); let base_deps = Rc::new(vec![ @@ -21121,8 +21783,8 @@ pub fn resolve_param_default( ItemKind::DataItem => match Rc::new({ let mut __result = Vec::new(); for i in module_items.iter().cloned() { - if (authored_name_at(source_indices.clone(), i.clone()).as_str() - == authored_name_at(source_indices.clone(), dv.clone()).as_str()) + if (authored_name_at(source_indices.clone(), i.clone()) + == authored_name_at(source_indices.clone(), dv.clone())) { __result.push(i); } @@ -21332,9 +21994,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc String { { - let about_attr = if (about.clone().as_str() != "".to_string().as_str()) { + let about_attr = if (about.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat(", about = \"".to_string(), about.clone()), "\"".to_string(), @@ -21907,11 +22566,18 @@ pub fn emit_cli_param_type_node( if ((n.children.clone().len() as i64) == 0) { { let nname = authored_name_at(source_indices, n.clone()); - let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone().as_str() != nname.clone().as_str()) { - mapped.clone() - } else { + if (nname.clone() == "String".to_string()) { "String".to_string() + } else { + { + let mapped = + coerce_primitive_type(RenderTarget::Rust, nname.clone()); + if (mapped.clone() != nname.clone()) { + mapped.clone() + } else { + "String".to_string() + } + } } } } else { @@ -21982,7 +22648,7 @@ pub fn emit_main_fn( ";".to_string(), ) }; - let body_lines = if (dry_run_line.clone().as_str() == "".to_string().as_str()) { + let body_lines = if (dry_run_line.clone() == "".to_string()) { v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) } else { v1_rt::concat( @@ -22017,15 +22683,7 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat( - v1_rt::concat( - "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" - .to_string(), - " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" - .to_string(), - ), - " },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index a0c3dd4540f..e716da211b3 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -35,13 +35,14 @@ pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_access::AccessCheckResultNode; pub use crate::v1_compiler_infer_access::{check_index_access_node, check_slice_access_node}; pub use crate::v1_compiler_infer_cycle::detect_type_cycles_kahn; +use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ add_emit_item_summary, build_enum_field_summaries, build_struct_field_summaries, derive_variant_to_enum, empty_emit_graph_info, lookup_emit_type_summary, }; pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, EmitInfoBuildState, TypeRepr, TypeSummary, + EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ inductive_fields_for, inductive_fields_list_to_map, is_recursive_type, @@ -163,8 +164,7 @@ use std::collections::HashMap; use std::rc::Rc; pub fn is_witness_type_name(name: String) -> bool { - ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) + ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -547,7 +547,7 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { + if (field_type_name.clone() == parent_name.clone()) { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -575,17 +575,15 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = ((value_type.clone().as_str() - == parent_name.clone().as_str()) + let is_recursive_element = ((value_type.clone() == parent_name.clone()) || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = - if (value_type.clone().as_str() == parent_name.clone().as_str()) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = if (value_type.clone() == parent_name.clone()) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -753,8 +751,8 @@ pub fn namespace_root_from_properties( match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "namespace_root".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "namespace_root".to_string()) { __result.push(p); } @@ -884,8 +882,7 @@ pub fn rejects_string_for_optional_coproduct_field( let expected_is_optional_coproduct = ((expected.return_cardinality.clone() == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); - let got_is_string = - (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); + let got_is_string = (authored_name_at(source_indices, got) == "String".to_string()); (expected_is_optional_coproduct && got_is_string) } } @@ -906,9 +903,7 @@ pub fn record_lit_expected_fields( if (authored_name_at( scope.type_env.clone().source_indices.clone(), v.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { __result.push(v); } @@ -942,9 +937,7 @@ pub fn record_lit_expanded_from_expected( if (((authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -955,9 +948,7 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), expanded.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { Some(expanded.clone()) } else { @@ -969,9 +960,7 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), rt.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { Some(rt.clone()) } else { @@ -1015,8 +1004,7 @@ pub fn record_lit_instantiated_fields( Some(tn) => match expected { Some(exp) => { if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - .as_str() - != tn.clone().as_str()) + != tn.clone()) { None } else { @@ -1186,10 +1174,9 @@ pub fn type_node_is_callable(n: Rc) -> bool { pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); + && (v1_rt::substring(&module_name, 0, 3) == "v2.".to_string())); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (v1_rt::substring(&module_name, 0, 13).as_str() - == "v1.compiler.".to_string().as_str())); + && (v1_rt::substring(&module_name, 0, 13) == "v1.compiler.".to_string())); (is_v4 || is_compiler_substrate) } } @@ -1204,13 +1191,11 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (formal_name.clone().as_str() != "".to_string().as_str())) - && (actual_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() != actual_name.clone().as_str())) + && (formal_name.clone() != "".to_string())) + && (actual_name.clone() != "".to_string())) + && (formal_name.clone() != actual_name.clone())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) - .as_str() - == structural_carrier_template_name(actual.clone(), source_indices.clone()) - .as_str())) + == 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())) } @@ -1225,8 +1210,8 @@ pub fn container_element_nominal_brand_mismatch( ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), formal.clone()).as_str() - == authored_name_at(source_indices.clone(), actual.clone()).as_str())) + && (authored_name_at(source_indices.clone(), formal.clone()) + == authored_name_at(source_indices.clone(), actual.clone()))) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1357,8 +1342,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( scope: Rc, span: Rc, ) -> Rc { - if ((func_name.clone().as_str() == "lookup".to_string().as_str()) - || (func_name.clone().as_str() == "map_get".to_string().as_str())) + if ((func_name.clone() == "lookup".to_string()) || (func_name.clone() == "map_get".to_string())) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1374,7 +1358,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (func_name.clone().as_str() == "lookup".to_string().as_str()) { + if (func_name.clone() == "lookup".to_string()) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1390,7 +1374,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { + if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1427,7 +1411,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (func_name.clone().as_str() == "map_values".to_string().as_str()) { + if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1465,14 +1449,13 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_union".to_string().as_str())) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + if (((func_name.clone() == "set_insert".to_string()) + || (func_name.clone() == "set_union".to_string())) + || (func_name.clone() == "set_contains".to_string())) { { - let operand_elem = if ((func_name.clone().as_str() - == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + let operand_elem = if ((func_name.clone() == "set_insert".to_string()) + || (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()) @@ -1516,18 +1499,17 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - let union_other_bad = - if (func_name.clone().as_str() == "set_union".to_string().as_str()) { - match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg.clone(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + 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(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1590,9 +1572,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let result_bt = if (func_name.clone() == "set_contains".to_string()) { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1635,9 +1615,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let build_diags = if (func_name.clone() == "set_contains".to_string()) { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1689,7 +1667,7 @@ pub fn method_pipe_map_keys_values_fallback( scope: Rc, span: Rc, ) -> Rc { - if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { + 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.clone()); @@ -1704,7 +1682,7 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (method_name.clone().as_str() == "map_values".to_string().as_str()) { + 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.clone()); @@ -1752,7 +1730,7 @@ pub fn validate_cast( match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (source_name.clone().as_str() == target_name.clone().as_str()) { + if (source_name.clone() == target_name.clone()) { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1880,23 +1858,18 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (scrutinee_name.clone().as_str() - != "Optional".to_string().as_str())); - let optional_coproduct_subject = ((scrutinee_name.clone().as_str() - == "Optional".to_string().as_str()) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))); + && (scrutinee_name.clone() != "Optional".to_string())); + let optional_coproduct_subject = ((scrutinee_name.clone() + == "Optional".to_string()) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((variant_name.clone().as_str() - == "Holds".to_string().as_str()) - || (variant_name.clone().as_str() - == "Violates".to_string().as_str()))); + && ((variant_name.clone() == "Holds".to_string()) + || (variant_name.clone() == "Violates".to_string()))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))) { Some("Optional".to_string()) } else { @@ -2141,7 +2114,7 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { + if (scrut_type_name.clone() == "".to_string()) { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2150,8 +2123,8 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) - && (f.field_name.clone().as_str() == field_name.clone().as_str())) + if ((f.variant_name.clone() == variant_name.clone()) + && (f.field_name.clone() == field_name.clone())) { __result.push(f); } @@ -2279,7 +2252,7 @@ pub fn method_name_is(opt: Option, expected: String) -> bool { if (opt.clone() == None) { false } else { - (opt.clone().unwrap().as_str() == expected.as_str()) + (opt.clone().unwrap() == expected) } } @@ -2293,7 +2266,7 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (n.clone().unwrap().as_str() == name.as_str()) + (n.clone().unwrap() == name) } } } @@ -2367,9 +2340,7 @@ pub fn derive_element_provenance( if (authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - ) - .as_str() - == "".to_string().as_str()) + ) == "".to_string()) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2777,11 +2748,18 @@ pub fn infer_expr( ); match field_type_lookup { Some(field_type) => { - let field_summary = field_summary_for_type( + let field_summary = match field_summary_for_type( base_rt.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(), + field_name.clone(), + ), + }; let fa_texpr = make_named_expr_node( field_name.clone(), Rc::new(ExprData::ExprFieldAccess { @@ -3425,7 +3403,7 @@ pub fn infer_expr( }) } } else { - if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { + if (func_name.clone() == "empty_map".to_string()) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3489,8 +3467,7 @@ match bare_m { } } } else { - if (func_name.clone().as_str() == "empty_set".to_string().as_str()) - { + if (func_name.clone() == "empty_set".to_string()) { { let bare_s = bare_set_node(); match expected.clone() { @@ -3563,13 +3540,12 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = if (func_name.clone().as_str() - == "lookup".to_string().as_str()) - { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = + if (func_name.clone() == "lookup".to_string()) { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4300,9 +4276,7 @@ match bare_s { (authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - ) - .as_str() - == let_name.clone().as_str()) + ) == let_name.clone()) } _ => false, }, @@ -5306,7 +5280,7 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (pn.clone().as_str() == fname.clone().as_str()) { + if (pn.clone() == fname.clone()) { __found = true; break; } @@ -5380,7 +5354,7 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) + let stop = ((is_optional || (next_name.clone() == "".to_string())) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5508,8 +5482,8 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((type_name.clone().unwrap().as_str() - == "Present".to_string().as_str()) + let is_present_ctor = ((type_name.clone().unwrap() == "Present".to_string()) && (local_variant_parent.clone().as_deref() == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { @@ -5848,9 +5818,7 @@ pub fn infer_record_lit( if (field_init_node_name_at( fir.typed_field.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "value".to_string().as_str()) + ) == "value".to_string()) { __result.push(fir); } @@ -5942,7 +5910,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()); - if (mname.as_str() == "count".to_string().as_str()) { + if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6039,7 +6007,7 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone().as_str() == param_name.clone().as_str()) { + 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 { @@ -6095,9 +6063,7 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "take".to_string().as_str()) - || (mname.clone().as_str() == "skip".to_string().as_str())) - { + if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { let receiver = method_receiver(arg_expr.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6108,7 +6074,7 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (rname.as_str() == param_name.clone().as_str()) { + if (rname == param_name.clone()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { @@ -6122,8 +6088,7 @@ pub fn classify_collection_shrink( unreachable!() }; if ((k.clone() > 0) - && (mname.clone().as_str() - == "skip".to_string().as_str())) + && (mname.clone() == "skip".to_string())) { match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { @@ -6166,9 +6131,7 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p.clone().as_str() - == param_name.clone().as_str()) - { + 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 { @@ -6199,8 +6162,7 @@ Rc::new(SubValueRelation::StrictSubValue { ExprData::ExprBinOp { op, .. } => { match op.clone() { BinOp::Add => { - if (mname.clone().as_str() - == "skip".to_string().as_str()) + if (mname.clone() == "skip".to_string()) { { let left = @@ -6321,16 +6283,15 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (lookup_type.clone().as_str() != "".to_string().as_str()) { + if (lookup_type.clone() != "".to_string()) { { 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() { - if ((f.field_name.clone().as_str() == field_label.clone().as_str()) - && ((f.variant_name.clone().as_str() == vname.clone().as_str()) - || (f.variant_name.clone().as_str() - == "".to_string().as_str()))) + if ((f.field_name.clone() == field_label.clone()) + && ((f.variant_name.clone() == vname.clone()) + || (f.variant_name.clone() == "".to_string()))) { __result.push(f); } @@ -6522,7 +6483,7 @@ pub fn resolve_collection_field( } } }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6534,8 +6495,7 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (f.field_name.clone().as_str() == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -6606,12 +6566,12 @@ pub fn resolve_collection_field( } => { let inner_mname = expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); - let is_collection_preserving = (((((inner_mname.clone().as_str() - == "enumerate".to_string().as_str()) - || (inner_mname.clone().as_str() == "skip".to_string().as_str())) - || (inner_mname.clone().as_str() == "take".to_string().as_str())) - || (inner_mname.clone().as_str() == "filter".to_string().as_str())) - || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); + 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 { { let __tco_0 = method_receiver(expr); @@ -6665,7 +6625,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (type_name.clone().as_str() != "".to_string().as_str()) { + if (type_name.clone() != "".to_string()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6745,9 +6705,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option "".to_string(), }, }; - if (inner_type.clone().as_str() - != "".to_string().as_str()) - { + if (inner_type.clone() != "".to_string()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6892,7 +6848,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if ((elem.clone().as_str() != "".to_string().as_str()) + if ((elem.clone() != "".to_string()) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -7037,7 +6993,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if (left_name.clone().as_str() != "".to_string().as_str()) { + if (left_name.clone() != "".to_string()) { match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -7079,12 +7035,12 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - if (mname.clone().as_str() == "skip".to_string().as_str()) { + if (mname.clone() == "skip".to_string()) { { let skip_args = method_arg_nodes(val.clone()); let skip_amount = match skip_args.first().cloned() { @@ -7297,7 +7253,7 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7343,7 +7299,7 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -7487,9 +7443,7 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7533,9 +7487,7 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7553,9 +7505,7 @@ pub fn classify_argument( ((expr_var_name_at( inner_left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7697,8 +7647,7 @@ pub fn read_arg_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) - { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -7838,7 +7787,7 @@ pub fn build_call_evidence( } pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { - if (found.clone().as_str() != "".to_string().as_str()) { + if (found.clone() != "".to_string()) { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -7885,7 +7834,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let arg_val = arg_value(child.clone()); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLambda => { - if (source_type.clone().as_str() != "".to_string().as_str()) { + if (source_type.clone() != "".to_string()) { { let lparams = lambda_param_names_at( arg_val.clone(), @@ -7902,9 +7851,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }; let lambda_ctx = Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (p2.clone().as_str() - != "".to_string().as_str()) - { + param_names: if (p2.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.param_names.clone(), @@ -7915,9 +7862,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { source_type.clone(), ) } else { - if (p1.clone().as_str() - != "".to_string().as_str()) - { + if (p1.clone() != "".to_string()) { v1_rt::rc_map_insert( ctx.param_names.clone(), p1.clone(), @@ -7929,9 +7874,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: if (p1.clone().as_str() - != "".to_string().as_str()) - { + sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( ctx.type_env.clone(), @@ -7959,9 +7902,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }), None => Rc::new(SubValueRelation::PreservedValue), }; - if (p2.clone().as_str() - != "".to_string().as_str()) - { + if (p2.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), @@ -8100,7 +8041,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Some(t) => t.clone(), None => "".to_string(), }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), @@ -8109,9 +8050,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -8135,8 +8074,8 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "first".to_string().as_str()) - || (mname.clone().as_str() == "last".to_string().as_str())) + if ((mname.clone() == "first".to_string()) + || (mname.clone() == "last".to_string())) { { let receiver = method_receiver(scrut.clone()); @@ -8148,8 +8087,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } _ => None, }; - let scrut_has_inductive = (((scrut_type.clone().as_str() - != "".to_string().as_str()) + let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) @@ -8190,7 +8128,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { + Some(ind_field) => if (vname.clone() == "Present".to_string()) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8214,9 +8152,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == inner_vname.clone()) && (f.field_name.clone() == inner_field_name.clone())) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { + Some(inner_ind_field) => if (inner_bind_name.clone() != "".to_string()) { Rc::new(DescentContext { 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()), @@ -8251,9 +8189,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == vname.clone()) && (f.field_name.clone() == field_name.clone())) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { + Some(ind_field) => if (bind_name.clone() != "".to_string()) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8276,7 +8214,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { + MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone() != "".to_string()) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8369,7 +8307,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { + param_names: if (sub_type.clone() != "".to_string()) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8486,9 +8424,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (sub_type.clone().as_str() - != "".to_string().as_str()) - { + param_names: if (sub_type.clone() != "".to_string()) { v1_rt::rc_map_insert( acc.ctx.clone().param_names.clone(), bname.clone(), @@ -8592,7 +8528,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (inner_mname.as_str() == "enumerate".to_string().as_str()) { + if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8638,7 +8574,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota None => "".to_string(), }, }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( @@ -8648,9 +8584,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .iter() .cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -8954,9 +8888,7 @@ pub fn infer_output_provenance( |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) - { + if ((pname.clone() != "".to_string()) && (ptype.clone() != "".to_string())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { acc.clone() @@ -9022,7 +8954,7 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (pn.clone().as_str() == vname.clone().as_str()) { + if (pn.clone() == vname.clone()) { __found = true; break; } @@ -9071,7 +9003,7 @@ pub fn classify_body_provenance( } _ => "".to_string(), }; - if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { + if (type_for_lookup.clone() != "".to_string()) { { let fields = inductive_fields_for( type_env.clone(), @@ -9080,9 +9012,7 @@ pub fn classify_body_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == field.clone().as_str()) - { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -9238,7 +9168,7 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { +if ((bind_name.clone() != "".to_string()) && (field_label.clone() != "".to_string())) { { let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) @@ -9426,7 +9356,7 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (first_pname.clone().as_str() != "".to_string().as_str()) { + if (first_pname.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), first_pname.clone(), @@ -9838,8 +9768,8 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((bind_name.clone().as_str() == "".to_string().as_str()) - || (field_label.clone().as_str() == "".to_string().as_str())) + if ((bind_name.clone() == "".to_string()) + || (field_label.clone() == "".to_string())) { c.clone() } else { @@ -9997,8 +9927,8 @@ pub fn compute_variant_provenance( param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) + if ((pname.clone() != "".to_string()) + && (ptype.clone() != "".to_string())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -10049,7 +9979,7 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { + if (enum_name.clone() == parent_enum.clone()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10073,7 +10003,7 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (fname.clone().as_str() != "".to_string().as_str()) { + if (fname.clone() != "".to_string()) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -10110,9 +10040,7 @@ pub fn collect_variant_constructors( if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) - .as_str() - == parent_enum.clone().as_str()) + ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10396,8 +10324,8 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((ptype.clone().as_str() != "".to_string().as_str()) - && (pname.clone().as_str() != "".to_string().as_str())) + if ((ptype.clone() != "".to_string()) + && (pname.clone() != "".to_string())) { { let fields = inductive_fields_for( @@ -10689,9 +10617,7 @@ pub fn infer_auth_source_properties( if (field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "svc_auth_source".to_string().as_str()) + ) == "svc_auth_source".to_string()) { { let val = field_init_node_value(p.clone()); @@ -11115,11 +11041,10 @@ pub fn infer_items( } pub fn is_type_variable_name(name: String) -> bool { - (((((name.clone().as_str() == "T".to_string().as_str()) - || (name.clone().as_str() == "K".to_string().as_str())) - || (name.clone().as_str() == "V".to_string().as_str())) - || (name.clone().as_str() == "MappedElement".to_string().as_str())) - || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) + (((((name.clone() == "T".to_string()) || (name.clone() == "K".to_string())) + || (name.clone() == "V".to_string())) + || (name.clone() == "MappedElement".to_string())) + || (name.clone() == "FoldAccumulator".to_string())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -11134,7 +11059,7 @@ pub fn type_node_label( ) -> String { { let authored = authored_name_at(source_indices, n.clone()); - if (authored.clone().as_str() != "".to_string().as_str()) { + if (authored.clone() != "".to_string()) { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11159,9 +11084,9 @@ pub fn param_is_generic_decl( }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) - && (pname.clone().as_str() != "".to_string().as_str())) - && ((pname.clone().as_str() == tname.as_str()) - || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) + && (pname.clone() != "".to_string())) + && ((pname.clone() == tname) + || (type_expr_is_var && (pname.clone() == pt.name.clone())))) } } @@ -11184,7 +11109,7 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == bind_name.clone().as_str()) { + if (g.clone() == bind_name.clone()) { __found = true; break; } @@ -11243,9 +11168,9 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); - (((formal_name.clone().as_str() != "".to_string().as_str()) - && (record_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() == record_name.clone().as_str())) + (((formal_name.clone() != "".to_string()) + && (record_name.clone() != "".to_string())) + && (formal_name.clone() == record_name.clone())) } } } @@ -11270,9 +11195,7 @@ pub fn unify_record_lit_field_walk( if (field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == field_name.clone().as_str()) + ) == field_name.clone()) { __result.push(fi); } @@ -11327,7 +11250,7 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == formal_name.clone().as_str()) { + if (g.clone() == formal_name.clone()) { __found = true; break; } @@ -11349,8 +11272,8 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((record_type_name.clone().as_str() != "".to_string().as_str()) - && (formal_name.clone().as_str() == record_type_name.clone().as_str())) + if ((record_type_name.clone() != "".to_string()) + && (formal_name.clone() == record_type_name.clone())) { unify_record_lit_field_walk( record_lit_expected_fields( @@ -11823,9 +11746,6 @@ pub fn build_type_env( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - // §3 single-authority: no implicit std.types base-injection. Resolution - // flows through each module's explicit import graph only (mirrors - // v1.compiler.infer build_type_env in src/v1/04_infer.dag). let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); @@ -11848,7 +11768,7 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12420,8 +12340,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - // §3 single-authority: no implicit std.types base-injection (mirrors - // build_type_env_unresolved in src/v1/04_infer.dag). + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12443,7 +12362,7 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -13357,8 +13276,8 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (dep.clone().as_str() == "None".to_string().as_str())) - || (dep.clone().as_str() == "".to_string().as_str())) + || (dep.clone() == "None".to_string())) + || (dep.clone() == "".to_string())) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13571,9 +13490,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).as_str() == "0".to_string().as_str()) - } + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, }) } @@ -13700,6 +13617,40 @@ pub fn build_positional_payload_variants( ) } +pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { + { + let has_seed = { + let mut __found = false; + 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() + { + if (v1_rt::contains(k.clone(), "/v1/".to_string()) + || v1_rt::contains(k.clone(), "src/v1".to_string())) + { + __found = true; + break; + } + } + __found + } { + __found = true; + break; + } + } + __found + }; + if has_seed { + RustCorpusRepr::HostNative + } else { + RustCorpusRepr::FaithfulFreeMonoid + } + } +} + pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { @@ -13756,6 +13707,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), + corpus_repr: rust_corpus_repr(modules.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 98745ada53b..5aa8cda70bb 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -1,6 +1,7 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.infer_emit_info +use self::RustCorpusRepr::*; use self::TypeRepr::*; pub use crate::v1_compiler_infer_types::{ child_type_node, emit_map_has, node_type_equals, normalize_access_type_node, @@ -62,6 +63,15 @@ pub struct TypeSummary { pub has_fn_fields: bool, } +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum RustCorpusRepr { + HostNative, + FaithfulFreeMonoid, +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EmitGraphInfo { pub type_summaries: Rc>>, @@ -75,6 +85,7 @@ pub struct EmitGraphInfo { pub owned_bindings: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, + pub corpus_repr: RustCorpusRepr, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -96,6 +107,7 @@ pub fn empty_emit_graph_info() -> Rc { read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), + corpus_repr: RustCorpusRepr::FaithfulFreeMonoid, }) } @@ -453,9 +465,8 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((resolved_name.clone().as_str() != "".to_string().as_str()) - && !ft_is_type_var.clone()) - && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) + if (((resolved_name.clone() != "".to_string()) && !ft_is_type_var.clone()) + && (resolved_name.clone() != "Dynamic".to_string())) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -621,3 +632,6 @@ pub fn add_emit_item_summary( None => state, } } + +pub struct HostNative; +pub struct FaithfulFreeMonoid; From 9757de200bea6b3dbb174d6c05c70c7e371e4932 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 05:13:06 +0000 Subject: [PATCH 38/61] Restore known-good stage0 seed (auto-committed local regen reverted again) Local class-3 verification re-ran the regen in the working tree, which the harness auto-committed and re-broke the seed build. Seed reverted to the committed fixpoint; class-3 logic remains entirely in the .dag source. Seed regen is the regen-lockstep lane's deliverable. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 3724 +++++++---------- src/v1/stage0/src/v1_compiler_infer.rs | 500 ++- .../stage0/src/v1_compiler_infer_emit_info.rs | 20 +- 3 files changed, 1810 insertions(+), 2434 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index bdb428d0e1f..2f8f22d77f7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -8,8 +8,8 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_templates, rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_struct_derives, rust_struct_derives_copy, }; +pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::SubValueUnknown; -pub use crate::std_induction::{InductiveField, SubValueRelation}; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{is_container_type, is_kernel_type}; @@ -45,25 +45,19 @@ pub use crate::v1_compiler_emit_core_support::{ pub use crate::v1_compiler_emit_core_support::{EmitResult, TestProjection}; pub use crate::v1_compiler_infer::InferScope; pub use crate::v1_compiler_infer::{ - build_emit_graph_info, build_params_scope, expand_type_for_field_access, expr_span, - extend_scope, resolved_type_name, + build_emit_graph_info, build_params_scope, expr_span, extend_scope, resolved_type_name, }; -use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ find_variant_parent, is_enum_in_summaries, is_known_variant, lookup_emit_type_summary, variant_belongs_to_enum, variant_summary_key, }; -pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, RustCorpusRepr, TypeRepr, TypeSummary, -}; +pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; pub use crate::v1_compiler_infer_env::{authored_name, lookup_type_by_name, lookup_type_for}; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; use crate::v1_compiler_infer_items::ItemKind::{DataItem, OtherItem, TypeItem}; pub use crate::v1_compiler_infer_items::{ItemInfo, ItemKind, ResolvedGraph, TypedModule}; -pub use crate::v1_compiler_infer_resolve::{ - is_width_nat_type_literal, lookup_unit_variant_phantom_type, -}; +pub use crate::v1_compiler_infer_resolve::lookup_unit_variant_phantom_type; pub use crate::v1_compiler_infer_service::{ extract_typed_service_name, is_typed_service_call_receiver, }; @@ -89,6 +83,7 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; +use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -117,16 +112,16 @@ use crate::v1_std_core::VarBindingKind::{ }; pub use crate::v1_std_core::{ arg_name_at, arg_value, arm_body, arm_guard, arm_pattern, authored_name_at, binop_left, - binop_right, cast_expr, cast_target, empty_intern_table, expr_call_func_at, - expr_has_non_tail_self_call, expr_has_self_call, expr_method_name_at, expr_var_name_at, - field_access_base, 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, find_property, foreach_body, foreach_collection, foreach_variable_at, - generic_param_name_at, if_condition, if_else_branch, if_then_branch, import_is_all, - import_specific_names_at, index_base, index_expr, is_compiler_error, is_file_transport, - is_rest_transport, is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, - let_body, let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, - make_span, match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + binop_right, cast_expr, cast_target, expr_call_func_at, expr_has_non_tail_self_call, + expr_has_self_call, expr_method_name_at, expr_var_name_at, field_access_base, + 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, + find_property, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, + if_condition, if_else_branch, if_then_branch, import_is_all, import_specific_names_at, + index_base, index_expr, is_compiler_error, is_file_transport, is_rest_transport, + is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, let_body, + let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, make_span, + match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, module_items, param_node_default_value, param_node_name_at, param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, return_value, service_config_auth, service_config_auth_input, service_config_auth_source, @@ -149,7 +144,6 @@ use std::rc::Rc; pub fn render_rust_type( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match n.inferred.clone().as_deref().cloned() { @@ -165,26 +159,12 @@ pub fn render_rust_type( applied.clone(), Rc::new(vec![]), shared_types, - corpus_repr, source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::< - String, - Rc>>, - >(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } else { render_rust_type_without_applied_binding( n.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } @@ -192,7 +172,6 @@ pub fn render_rust_type( None => render_rust_type_without_applied_binding( n.clone(), shared_types, - corpus_repr, source_indices.clone(), ), }, @@ -202,7 +181,6 @@ pub fn render_rust_type( pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if (((n.connective.clone() == Connective::NoConnective) @@ -213,17 +191,7 @@ pub fn render_rust_type_without_applied_binding( n.clone(), Rc::new(vec![]), shared_types, - corpus_repr, source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -263,20 +231,19 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { + let tn = authored_name_at(source_indices.clone(), n.clone()); + if (tn.clone().as_str() == "String".to_string().as_str() + && ((n.children.clone().len() as i64) == 0) + && rust_emit_faithful_text_carrier(source_indices.clone())) { - let tn = authored_name_at(source_indices.clone(), n.clone()); - if (((tn == "String".to_string()) && ((n.children.clone().len() as i64) == 0)) - && corpus_repr_is_faithful(corpus_repr)) - { - render_rust_text_carrier(shared_types) - } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) - } + render_rust_text_carrier(shared_types.clone()) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) } } } @@ -288,21 +255,22 @@ pub fn empty_string_bool_map() -> Rc> { pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { ((v1_rt::string_length(&type_name) >= 3) - && (v1_rt::substring(&type_name, 0, 3) == "Rc<".to_string())) + && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) } -pub fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> bool { - match corpus_repr { - RustCorpusRepr::FaithfulFreeMonoid => true, - RustCorpusRepr::HostNative => false, - } +pub fn rust_corpus_includes_v1_compiler( + source_indices: Rc>>, +) -> bool { + v1_rt::map_keys(&source_indices) + .iter() + .cloned() + .any(|k| k.contains("/v1/") || k.contains("src/v1")) } -pub fn corpus_repr_is_host(corpus_repr: RustCorpusRepr) -> bool { - match corpus_repr { - RustCorpusRepr::HostNative => true, - RustCorpusRepr::FaithfulFreeMonoid => false, - } +pub fn rust_emit_faithful_text_carrier( + source_indices: Rc>>, +) -> bool { + !rust_corpus_includes_v1_compiler(source_indices) } pub fn render_rust_text_carrier(shared_types: Rc>) -> String { @@ -315,9 +283,9 @@ pub fn render_rust_text_carrier(shared_types: Rc>>, ) -> String { - if corpus_repr_is_faithful(corpus_repr) { + if rust_emit_faithful_text_carrier(source_indices) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), @@ -332,9 +300,9 @@ pub fn emit_rust_host_to_dag_string_via_seam( pub fn emit_rust_dag_string_to_host_via_seam( dag_expr: String, - corpus_repr: RustCorpusRepr, + source_indices: Rc>>, ) -> String { - if corpus_repr_is_faithful(corpus_repr) { + if rust_emit_faithful_text_carrier(source_indices) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), @@ -348,52 +316,57 @@ pub fn emit_rust_dag_string_to_host_via_seam( } pub fn rust_host_string_seam_fn_emit(name: String) -> Option { - if (name.clone() == "host_string_text_from_rust_host".to_string()) { - Some(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string()), "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string()), "}\n".to_string())) + if name.as_str() == "host_string_text_from_rust_host" { + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), + " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), + ), + "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), + ), + "}\n".to_string(), + )) + } else if name.as_str() == "host_string_text_to_rust_host" { + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), + " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), + ), + "}\n".to_string(), + ), + "".to_string(), + )) } else { - if (name.clone() == "host_string_text_to_rust_host".to_string()) { - Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) - } else { - None - } + None } } pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if ((name.clone() == "Json".to_string()) || (name.clone() == "Bytes".to_string())) { + if (name.clone().as_str() == "Json".to_string().as_str()) + || (name.clone().as_str() == "Bytes".to_string().as_str()) + { Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { None } } -pub fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> Option { - if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) - && corpus_repr_is_host(corpus_repr)) +pub fn rust_named_type_base( + name: String, + source_indices: Rc>>, +) -> String { + if ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) { - Some("i64".to_string()) - } else { - None - } -} - -pub fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> Option { - if ((name == "List".to_string()) && corpus_repr_is_host(corpus_repr)) { - Some("Vec".to_string()) - } else { - None - } -} - -pub fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { - if ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) { "Witness".to_string() + } else if name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices) + { + "FreeMonoid".to_string() } else { - if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr)) { - "FreeMonoid".to_string() - } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) - } + coerce_primitive_type(RenderTarget::Rust, name.clone()) } } @@ -421,112 +394,15 @@ 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()), - None => false, - } -} - -pub fn is_parametric_opaque_type_base( - type_name: String, - def_mod_filename: String, - typed_modules: Rc>>, - source_indices: Rc>>, - module_index: Rc, -) -> bool { - match type_item_by_name_in_module_filename( - type_name, - def_mod_filename, - typed_modules, - source_indices.clone(), - module_index, - ) { - Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), - None => false, - } -} - -pub fn render_rust_phantom_opaque_applied_type_arg( - n: Rc, - generic_param_names: Rc>, - shared_types: Rc>, - corpus_repr: RustCorpusRepr, - source_indices: Rc>>, - scope: Rc, - imports: Rc>>, - registry: Rc>>, - module_name: String, - export_sets: Rc>>>, - typed_modules: Rc>>, - module_index: Rc, - variant_to_enum: Rc>, -) -> String { - if is_width_nat_type_literal(n.clone()) { - "()".to_string() - } else { - render_rust_alias_rhs_type( - n.clone(), - generic_param_names, - shared_types, - corpus_repr, - source_indices, - scope, - imports, - registry, - module_name, - export_sets, - typed_modules, - module_index, - variant_to_enum, - ) - } -} - -pub fn render_rust_phantom_opaque_applied_decl_arg( - n: Rc, - generic_param_names: Rc>, - shared_types: Rc>, - corpus_repr: RustCorpusRepr, - source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_width_nat_type_literal(n.clone()) { - "()".to_string() - } else { - render_rust_decl_type( - n.clone(), - generic_param_names, - shared_types, - corpus_repr, - source_indices, - variant_to_enum, - env, - ) - } -} - pub fn render_rust_applied_type_arg( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type( - n.clone(), - generic_param_names, - shared_types, - corpus_repr, - source_indices, - variant_to_enum, - env, - ), + _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), } } @@ -534,46 +410,26 @@ pub fn render_rust_applied_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { - let base_name = authored_name_at(source_indices.clone(), n.clone()); - let base = 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()), - }; + let base = rust_named_type_base( + authored_name_at(source_indices.clone(), n.clone()), + source_indices.clone(), + ); if ((n.children.clone().len() as i64) == 0) { base } else { { - 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() { - __result.push(if peel.clone() { - render_rust_phantom_opaque_applied_decl_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - } else { - render_rust_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - }); + __result.push(render_rust_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + )); } __result }) @@ -604,20 +460,14 @@ pub fn render_rust_applied_type_shared( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { let rendered = render_rust_applied_type( n.clone(), generic_param_names, shared_types.clone(), - corpus_repr, source_indices.clone(), - variant_to_enum, - env, ); let type_name = authored_name_at(source_indices.clone(), n.clone()); render_rust_shared_type_if_needed(type_name, rendered, shared_types.clone()) @@ -628,10 +478,7 @@ pub fn render_rust_decl_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -639,7 +486,8 @@ pub fn render_rust_decl_type( "__applied_type_args".to_string(), source_indices.clone(), ); - let applied_overlay = match applied_prop.clone() { + let has_applied_prop = applied_prop.is_some(); + let applied_overlay = match applied_prop { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) @@ -654,10 +502,7 @@ pub fn render_rust_decl_type( applied.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -666,7 +511,7 @@ pub fn render_rust_decl_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone() == name.clone()) { + if (g.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -675,103 +520,67 @@ pub fn render_rust_decl_type( }) { name.clone() + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && !has_applied_prop + && name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices.clone())) + { + render_rust_text_carrier(shared_types.clone()) + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && !has_applied_prop + && v1_rt::set_contains(&shared_types, name.clone())) + { + let stub_env = Rc::new(TypeEnv { + bindings: Rc::new(HashMap::new()), + recursive_types: Rc::new(vec![]), + recursive_type_set: Rc::new(HashMap::new()), + inductive_fields: Rc::new(HashMap::new()), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }); + let rendered = rust_render_type_leaf_name( + name.clone(), + v1_rt::rc_empty_map::(), + stub_env, + ); + render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) } else { - if (((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && (name.clone() == "String".to_string())) - && corpus_repr_is_faithful(corpus_repr.clone())) + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) { - render_rust_text_carrier(shared_types.clone()) - } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && v1_rt::set_contains(&shared_types, name.clone())) { - { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - env.clone(), - ); - render_rust_shared_type_if_needed( - name.clone(), - rendered, - shared_types.clone(), - ) - } - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - if (!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(), + let base = rust_named_type_base(name.clone(), source_indices.clone()); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), shared_types.clone(), - ) - } else { - { - let base = - rust_named_type_base(name.clone(), corpus_repr.clone()); - let peel = is_parametric_opaque_type_by_name( - env.clone(), - name.clone(), - ); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(if peel.clone() { - render_rust_phantom_opaque_applied_decl_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - } else { - render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - ) - }); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat( - v1_rt::concat(base, "<".to_string()), - args, - ), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) - } + source_indices.clone(), + )); } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - ) - } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) } + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + source_indices.clone(), + ) } } } @@ -780,78 +589,53 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - if (name.clone() == "String".to_string()) { - return false; - } - let binding = match lookup_type_for(env.clone(), n.clone()) { - 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()) { - Some(b) => b.clone(), - None => return false, - } - } - }; - ((binding.params.clone().len() as i64) == 0) + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if name.clone().as_str() == "String".to_string().as_str() { + return false; } + let binding = match lookup_type_for(env.clone(), n.clone()) { + Some(b) => b, + None => { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + match lookup_type_by_name(env.clone(), name) { + Some(b) => b, + None => return false, + } + } + }; + (binding.params.clone().len() as i64) == 0 } pub fn render_rust_fn_sig_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices.clone())) { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (name.clone() == "String".to_string())) - && corpus_repr_is_faithful(corpus_repr.clone())) - { - render_rust_text_carrier(shared_types) - } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !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) - } else { - if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type( - n.clone(), - generic_param_names.clone(), - shared_types, - corpus_repr.clone(), - source_indices.clone(), - variant_to_enum, - env.clone(), - ) - } else { - render_rust_fn_sig_type_applied_binding( - n.clone(), - shared_types, - corpus_repr.clone(), - source_indices.clone(), - env.clone(), - ) - } - } - } + render_rust_text_carrier(shared_types.clone()) + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0) + && !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()) + } else if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) + } else { + render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) } } pub fn render_rust_fn_sig_type_applied_binding( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, env: Rc, ) -> String { @@ -862,42 +646,25 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if outer_name.as_str() != "" + && n.connective.clone() == Connective::NoConnective + && (n.children.clone().len() as i64) == 0 + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if ((((outer_name.clone() != "".to_string()) - && (n.connective.clone() == Connective::NoConnective)) - && ((n.children.clone().len() as i64) == 0)) - && rust_fn_sig_peel_closed_alias(env, n.clone())) - { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name.clone(), - shared_types, - ) - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ) - } + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name, + shared_types.clone(), + ) + } else { + render_rust_type_with_applied_binding(n, shared_types, source_indices) } } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ) + render_rust_type_with_applied_binding(n, shared_types, source_indices) } } - None => render_rust_type_with_applied_binding( - n.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ), + None => render_rust_type_with_applied_binding(n, shared_types, source_indices), } } @@ -905,7 +672,6 @@ pub fn render_rust_alias_rhs_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, scope: Rc, imports: Rc>>, @@ -923,7 +689,7 @@ pub fn render_rust_alias_rhs_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone() == name.clone()) { + if (g.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -932,140 +698,85 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + { + if name.clone().as_str() == "String".to_string().as_str() + && rust_emit_faithful_text_carrier(source_indices.clone()) { - match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { - Some(host) => host.clone(), - None => { - if ((name.clone() == "String".to_string()) - && corpus_repr_is_faithful(corpus_repr.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else { - 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(), - scope.type_env.clone(), - ); - render_rust_shared_type_if_needed( - name.clone(), - rendered, - shared_types.clone(), - ) - } - } - } - } - } + render_rust_text_carrier(shared_types.clone()) + } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { + carrier } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + scope.type_env.clone(), + ); + render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) + } + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let base = if (def_mod.clone().as_str() != local_mod.as_str()) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + }; + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), scope.clone(), + imports.clone(), registry.clone(), + module_name.clone(), export_sets.clone(), typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = match rust_seed_host_container_base( - name.clone(), - corpus_repr.clone(), - ) { - Some(host) => host.clone(), - None => { - if (def_mod.clone() != local_mod) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - } - } - }; - let peel = is_parametric_opaque_type_base( - name.clone(), - def_mod.clone(), - typed_modules.clone(), - source_indices.clone(), module_index.clone(), - ); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(if peel.clone() { - render_rust_phantom_opaque_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - variant_to_enum.clone(), - ) - } else { - render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - variant_to_enum.clone(), - ) - }); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) - } else { - applied_ty.clone() - } + variant_to_enum.clone(), + )); } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr.clone(), - source_indices.clone(), - ) + applied_ty.clone() } } + } else { + render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -1192,14 +903,14 @@ pub fn rust_nominal_identity_carrier_def(name: String) -> String { } pub fn rust_nominal_identity_carrier_type_eligible(type_name: String) -> bool { - (type_name == "Symbol".to_string()) + (type_name.as_str() == "Symbol".to_string().as_str()) } pub fn rust_nominal_identity_carrier_shape_eligible( n: Rc, source_indices: Rc>>, ) -> bool { - ((((authored_name_at(source_indices, n.clone()) == "Symbol".to_string()) + ((((authored_name_at(source_indices, n.clone()).as_str() == "Symbol".to_string().as_str()) && ((n.children.clone().len() as i64) == 0)) && ((n.params.clone().len() as i64) == 0)) && (n.connective.clone() == Connective::NoConnective)) @@ -1210,7 +921,8 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( children: Rc>>, source_indices: Rc>>, ) -> bool { - if ((name != "DiffId".to_string()) || ((children.clone().len() as i64) != 1)) { + if ((name.as_str() != "DiffId".to_string().as_str()) || ((children.clone().len() as i64) != 1)) + { false } else { match children.clone().first().cloned() { @@ -1244,8 +956,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.clone() == "DiffId".to_string()))) + && ((type_name.clone().as_str() == "Symbol".to_string().as_str()) + || (type_name.clone().as_str() == "DiffId".to_string().as_str()))) } } @@ -1346,7 +1058,9 @@ pub fn field_value_by_name( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at(fi.clone(), source_indices.clone()) == field_name.clone()) { + if (field_init_node_name_at(fi.clone(), source_indices.clone()).as_str() + == field_name.clone().as_str()) + { __result.push(fi); } } @@ -1416,16 +1130,18 @@ pub fn rust_string_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone() == "AsAuthored".to_string()) { + if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { rust_string_as_authored_policy() } else { - if (naming_name.clone() == "SnakeCase".to_string()) { + if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { rust_snake_string_policy() } else { - if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { + if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { rust_screaming_snake_string_policy() } else { - if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripPrefixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1442,7 +1158,9 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripSuffixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1459,15 +1177,35 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) + if (naming_name.clone().as_str() + == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - 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())), - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), -}, - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), -} + 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()), + ), + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal suffix" + .to_string(), + ), + }, + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal prefix" + .to_string(), + ), + } } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1489,7 +1227,7 @@ pub fn rust_internal_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone() == "AsAuthored".to_string()) { + if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1500,7 +1238,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone() == "SnakeCase".to_string()) { + if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1511,7 +1249,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { + if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1522,7 +1260,9 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripPrefixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1542,7 +1282,9 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { + if (naming_name.clone().as_str() + == "StripSuffixAndSnakeCase".to_string().as_str()) + { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1562,15 +1304,41 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) + if (naming_name.clone().as_str() + == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - 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())), - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), -}, - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), -} + 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()), + ), + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal suffix" + .to_string(), + ), + }, + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal prefix" + .to_string(), + ), + } } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1616,10 +1384,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ) -> Rc { { let encoding_name = authored_name_at(source_indices.clone(), ve.clone()); - if (encoding_name.clone() == "InternallyTaggedObject".to_string()) { + if (encoding_name.clone().as_str() == "InternallyTaggedObject".to_string().as_str()) { rust_internal_policy_for_encoding(ve.clone(), source_indices.clone()) } else { - if (encoding_name.clone() == "StringVariant".to_string()) { + if (encoding_name.clone().as_str() == "StringVariant".to_string().as_str()) { match naming_policy_node(ve.clone(), source_indices.clone()) { Some(nv) => rust_string_policy_for_naming(nv.clone(), source_indices.clone()), None => rust_serde_error_policy( @@ -1627,10 +1395,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ), } } else { - if (encoding_name.clone() == "UntaggedVariant".to_string()) { + if (encoding_name.clone().as_str() == "UntaggedVariant".to_string().as_str()) { rust_untagged_policy() } else { - if (encoding_name.clone() == "TaggedVariant".to_string()) { + if (encoding_name.clone().as_str() == "TaggedVariant".to_string().as_str()) { rust_tagged_object_policy() } else { rust_serde_error_policy(v1_rt::concat( @@ -1660,7 +1428,8 @@ pub fn resolve_wire_serde_policy( } pub fn item_binding_is_named(env: Rc, node: Rc, name: String) -> bool { - ((authored_name(env, node.clone()) == name.clone()) || (node.name.clone() == name.clone())) + ((authored_name(env, node.clone()).as_str() == name.clone().as_str()) + || (node.name.clone().as_str() == name.clone().as_str())) } pub fn resolve_wire_serde_policy_for_coproduct( @@ -1853,7 +1622,7 @@ pub fn variant_encoding_is_string_variant( encoding: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, encoding) == "StringVariant".to_string()) + (authored_name_at(source_indices, encoding).as_str() == "StringVariant".to_string().as_str()) } pub fn coproduct_wire_contract_targets( @@ -1864,7 +1633,7 @@ pub fn coproduct_wire_contract_targets( match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { - Some(target_name) => (target_name.clone() == coproduct_name), + Some(target_name) => (target_name.clone().as_str() == coproduct_name.as_str()), None => false, } } @@ -1893,15 +1662,15 @@ pub fn module_imports_std_serialization_coproduct_wire_contract( { let mut __found = false; for imp in imports.iter().cloned() { - if ((authored_name_at(source_indices.clone(), imp.clone()) - == "std.serialization".to_string()) + if ((authored_name_at(source_indices.clone(), imp.clone()).as_str() + == "std.serialization".to_string().as_str()) && (import_is_all(imp.clone()) || { let mut __found = false; for name in import_specific_names_at(imp.clone(), source_indices.clone()) .iter() .cloned() { - if (name.clone() == "CoproductWireContract".to_string()) { + if (name.clone().as_str() == "CoproductWireContract".to_string().as_str()) { __found = true; break; } @@ -1924,8 +1693,8 @@ 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.clone()) - == "CoproductWireContract".to_string()) + ((authored_name_at(source_indices.clone(), type_node.clone()).as_str() + == "CoproductWireContract".to_string().as_str()) && module_imports_std_serialization_coproduct_wire_contract( imports, source_indices.clone(), @@ -1945,8 +1714,8 @@ pub fn module_defines_local_coproduct_wire_contract_type( if (((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), item.clone()) - == "CoproductWireContract".to_string())) + && (authored_name_at(source_indices.clone(), item.clone()).as_str() + == "CoproductWireContract".to_string().as_str())) { __found = true; break; @@ -2007,7 +1776,7 @@ pub fn emit_coproduct_wire_contract_target_validation( if { let mut __found = false; for name in local_coproduct_names.iter().cloned() { - if (name.clone() == target_name.clone()) { + if (name.clone().as_str() == target_name.clone().as_str()) { __found = true; break; } @@ -2072,7 +1841,7 @@ pub fn emit_coproduct_wire_contract_validations( .iter() .cloned() { - if (text.clone() != "".to_string()) { + if (text.clone().as_str() != "".to_string().as_str()) { __result.push(text); } } @@ -2397,198 +2166,51 @@ pub fn emit_rust_init_block_stmts( remaining .clone() .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ); - match rest.clone().first().cloned() { - None => { - break Rc::new(BlockEmitState { - text: text, - scope: scope.clone(), - }); - } - Some(_) => { - let raw_line = emit_typed_expr( - stmt.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let is_let = match (*stmt.expr_data.clone()).clone() { - ExprData::ExprLet => true, - _ => false, - }; - let line = if is_let { - raw_line - } else { - 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); - let __tco_2 = next_scope; - remaining = __tco_0; - text = __tco_1; - scope = __tco_2; - continue; - } - } - } - } - } - } -} - -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - 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(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name.clone() - } else { - match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier.clone(), - None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum), - } - } -} - -pub fn rust_phantom_zst_marker_def(vname: String) -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]\n".to_string(), rust_visibility_prefix()), rust_items().struct_keyword.clone()), " ".to_string()), vname), ";".to_string()) -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - { - let markers = Rc::new({ - let mut __result = Vec::new(); - for child in Rc::new({ - let mut __result = Vec::new(); - for child in Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if ((child.children.clone().len() as i64) == 0) { - __result.push(child); - } - } - __result - }) - .iter() - .cloned() - { - if is_phantom_unit_variant_type_arg( - env.clone(), - authored_name(env.clone(), child.clone()), - ) { - __result.push(child); - } - } - __result - }) - .iter() - .cloned() - { - __result.push({ - let vname = authored_name(env.clone(), child.clone()); - rust_phantom_zst_marker_def(vname.clone()) - }); - } - __result - }) - .join(&"\n".to_string()); - markers - } -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for item in items.iter().cloned() { - if (is_type_def_item(item.clone()) && { - let mut __all = true; - for c in item.children.clone().iter().cloned() { - if !((c.children.clone().len() as i64) == 0) { - __all = false; - break; - } - } - __all - }) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { - item.children.clone().iter().cloned().fold( - acc, - |inner: Rc>, child: Rc| { - if ((child.children.clone().len() as i64) == 0) { - { - let vname = authored_name(env.clone(), child.clone()); - if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !{ - let mut __found = false; - for n in inner.clone().iter().cloned() { - if (n.clone() == vname.clone()) { - __found = true; - break; - } - } - __found - }) - { - v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + .cloned() + .skip(1 as usize) + .collect::>(), + ); + match rest.clone().first().cloned() { + None => { + break Rc::new(BlockEmitState { + text: text, + scope: scope.clone(), + }); + } + Some(_) => { + let raw_line = emit_typed_expr( + stmt.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ); + let is_let = match (*stmt.expr_data.clone()).clone() { + ExprData::ExprLet => true, + _ => false, + }; + let line = if is_let { + raw_line } else { - inner.clone() + 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); + let __tco_2 = next_scope; + remaining = __tco_0; + text = __tco_1; + scope = __tco_2; + continue; } } - } else { - inner.clone() } - }, - ) - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { - __result.push(rust_phantom_zst_marker_def(vname.clone())); + } } - __result - }) - .join(&"\n".to_string()) + } } pub fn has_complex_variants(item: Rc) -> bool { @@ -2730,8 +2352,9 @@ pub fn build_shared_types( .iter() .cloned() { - if ((sharing.needs_sharing.clone() && (k.clone() != "optional".to_string())) - && (k.clone() != "boolean_algebra".to_string())) + if ((sharing.needs_sharing.clone() + && (k.clone().as_str() != "optional".to_string().as_str())) + && (k.clone().as_str() != "boolean_algebra".to_string().as_str())) { __result.push(k); } @@ -2909,7 +2532,6 @@ pub fn emit_rust(typed: Rc) -> Rc { owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let registry = typed.item_registry.clone(); @@ -2990,18 +2612,18 @@ pub fn emit_rust(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone() + if (p.module_name.clone().as_str() == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - )) + ) + .as_str()) { __result.push(p); } } __result }), - emit_info.corpus_repr.clone(), )); } __result @@ -3009,7 +2631,7 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone() != "".to_string()) { + if (f.path.clone().as_str() != "".to_string().as_str()) { __result.push(f); } } @@ -3020,7 +2642,8 @@ pub fn emit_rust(typed: Rc) -> Rc { 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()) + .as_str() + == "v1.compiler.compile".to_string().as_str()) { __found = true; break; @@ -3129,7 +2752,7 @@ pub fn emit_lib_rs_from_files( __result }); let hand_maintained_mods = if has_compiler_tests.clone() { - "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod languages_consumer_census;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() + "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() } else { "".to_string() }; @@ -3139,6 +2762,9 @@ pub fn emit_lib_rs_from_files( "".to_string() }; let shared_types = emit_non_empty_wrappers(); + // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (single authority): + // crate-root #![recursion_limit = "256"] added (serde_json::json! recursion fix). + // DISSOLUTION lane adhoc-1bdd0259-2e3; a clean regen reproduces this from the .dag. let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); Rc::new(TextFile { path: v1_rt::concat( @@ -3173,7 +2799,6 @@ pub fn emit_module( owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let export_sets = build_module_export_sets(Rc::new(vec![typed_module.clone()])); @@ -3270,7 +2895,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), module_index.clone(), ); - let imports_section = if (imports_str.clone() == "".to_string()) { + let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { v1_rt::concat("\n".to_string(), imports_str.clone()) @@ -3300,7 +2925,7 @@ pub fn emit_module_full( __result.extend( (*match v1_rt::map_get(&svc_module_map, sn.clone()) { Some(mod_file) => { - if (mod_file.clone() == this_mod_filename.clone()) { + if (mod_file.clone().as_str() == this_mod_filename.clone().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![v1_rt::concat( @@ -3387,7 +3012,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = - if (coproduct_wire_contract_validations.clone() == "".to_string()) { + if (coproduct_wire_contract_validations.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { v1_rt::concat( @@ -3448,19 +3073,19 @@ 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()); - let phantom_section = if (phantom_zst_markers.clone() == "".to_string()) { + let phantom_section = if phantom_zst_markers.as_str() == "" { "".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 filename = if (raw_filename.clone() == "main".to_string()) { + let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()) - == "std.error_primitives".to_string()) + let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()).as_str() + == "std.error_primitives".to_string().as_str()) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { @@ -3662,10 +3287,10 @@ pub fn has_physical_type_def_in_module_filename( if { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) - == rhs_name.clone()) - && ((is_type_def_item(item.clone()) - || is_type_alias_item(item.clone(), source_indices.clone())) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == rhs_name.clone().as_str()) + && (is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone()) || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; @@ -3717,8 +3342,8 @@ pub fn find_variant_parent_in_module( 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()) + if (authored_name_at(source_indices.clone(), child.clone()).as_str() + == variant_name.clone().as_str()) { __found = true; break; @@ -3760,7 +3385,8 @@ pub fn type_name_is_export_source_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == name.clone().as_str()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3793,7 +3419,8 @@ pub fn type_name_is_rust_importable_in_module( Some(tm) => match Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == name.clone().as_str()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3875,7 +3502,7 @@ pub fn name_in_transitive_export_surface( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone() == module_name.clone()) { + if (v.clone().as_str() == module_name.clone().as_str()) { __found = true; break; } @@ -3970,7 +3597,7 @@ pub fn reexport_source_module_name_with_visited( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone() == import_module.clone()) { + if (v.clone().as_str() == import_module.clone().as_str()) { __found = true; break; } @@ -4024,7 +3651,8 @@ pub fn reexport_source_module_name_with_visited( .iter() .cloned() { - if (n.clone() == name.clone()) { + if (n.clone().as_str() == name.clone().as_str()) + { __found = true; break; } @@ -4198,7 +3826,7 @@ pub fn import_module_enum_scope( .iter() .cloned() { - if (p.clone() != "".to_string()) { + if (p.clone().as_str() != "".to_string().as_str()) { __result.push(p); } } @@ -4273,7 +3901,8 @@ pub fn enum_physically_defined_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if (((authored_name_at(source_indices.clone(), item.clone()) == enum_name.clone()) + if (((authored_name_at(source_indices.clone(), item.clone()).as_str() + == enum_name.clone().as_str()) && is_type_def_item(item.clone())) && is_coproduct_type(item.clone())) { @@ -4298,7 +3927,7 @@ pub fn wildcard_import_pool_surface_names( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone() == module_name.clone()) { + if (v.clone().as_str() == module_name.clone().as_str()) { __found = true; break; } @@ -4395,7 +4024,7 @@ pub fn wildcard_reexport_surface_names( source_indices.clone(), module_index.clone(), ) { - Some(src) => (src.clone() != import_module.clone()), + Some(src) => (src.clone().as_str() != import_module.clone().as_str()), None => false, } { __result.push(n); @@ -4468,7 +4097,7 @@ pub fn variant_defining_module_filename_for_import( module_index.clone(), ) { Some(hop) => { - if (hop.clone() != import_module.clone()) { + if (hop.clone().as_str() != import_module.clone().as_str()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4506,7 +4135,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone() == parent_enum.clone()) { + if (local_parent.clone().as_str() == parent_enum.clone().as_str()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -4558,7 +4187,7 @@ pub fn explicit_import_source_module_for_name( .iter() .cloned() { - if (n.clone() == name.clone()) { + if (n.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -4671,7 +4300,7 @@ pub fn reexport_variant_parent_in_import_module( module_index.clone(), ) { Some(hop) => { - if (hop.clone() != src_mod.clone()) { + if (hop.clone().as_str() != src_mod.clone().as_str()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4762,7 +4391,7 @@ pub fn alias_rhs_base_module_filename( let local_mod = module_to_filename(alias_module.clone()); match lookup_item(scope.item_registry.clone(), name.clone()) { Some(info) => { - if ((info.module_name.clone() == alias_module.clone()) + if ((info.module_name.clone().as_str() == alias_module.clone().as_str()) && ((info.kind.clone() == ItemKind::TypeItem) || (info.kind.clone() == ItemKind::OtherItem))) { @@ -4815,7 +4444,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .iter() .cloned() { - if (n.clone() == name.clone()) { + if (n.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -4922,8 +4551,8 @@ pub fn type_item_by_name_in_module_filename( Some(tm) => Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()) - == rhs_name.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()).as_str() + == rhs_name.clone().as_str()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -4970,12 +4599,28 @@ pub fn type_item_has_rust_nominal_shell_authority( { true } else { + let rhs = resolved_type(item.clone()); + if is_type_alias_return_node(rhs.clone(), source_indices.clone()) + && ((rhs.children.clone().len() as i64) > 0) { - let rhs = resolved_type(item.clone()); - if (is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && ((rhs.children.clone().len() as i64) > 0)) - { - alias_rhs_nominal_shell_has_rust_authority( + alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + ) + } else if is_type_alias_return_node(rhs.clone(), source_indices.clone()) + { + let rhs_name = + authored_name_at(source_indices.clone(), rhs.clone()); + (rhs_name.as_str() != item_text.as_str()) + && rhs_name.as_str() != "" + && alias_rhs_nominal_shell_has_rust_authority( rhs.clone(), module_name, imports, @@ -4986,34 +4631,8 @@ pub fn type_item_has_rust_nominal_shell_authority( source_indices.clone(), module_index, ) - } else { - if is_type_alias_return_node( - rhs.clone(), - source_indices.clone(), - ) { - { - let rhs_name = authored_name_at( - source_indices.clone(), - rhs.clone(), - ); - (((rhs_name.clone() != item_text.clone()) - && (rhs_name.clone() != "".to_string())) - && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - )) - } - } else { - false - } - } + } else { + false } } } else { @@ -5211,7 +4830,9 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( } else { { let name = authored_name_at(source_indices.clone(), n.clone()); - if ((name.clone() == "".to_string()) || is_kernel_type(name.clone())) { + if ((name.clone().as_str() == "".to_string().as_str()) + || is_kernel_type(name.clone())) + { true } else { if is_phantom_unit_variant_type_arg( @@ -5260,100 +4881,91 @@ pub fn is_self_referential_opaque_type_resolved( item: Rc, source_indices: Rc>>, ) -> bool { - { - 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)) - } + 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 } pub fn is_zero_param_self_referential_opaque_decl( item: Rc, source_indices: Rc>>, ) -> bool { - (is_bare_leaf_item(item.clone()) - && is_self_referential_opaque_type_resolved(item.clone(), source_indices)) + is_bare_leaf_item(item.clone()) + && is_self_referential_opaque_type_resolved(item.clone(), source_indices) } 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.children.clone().len() as i64) == 0)) + ((item.params.clone().len() as i64) > 0) + && item.body.is_none() + && item.transport.is_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()))) + || is_self_referential_opaque_type_resolved(item.clone(), source_indices)) } pub fn emit_zero_param_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - { - let item_text = authored_name_at(source_indices, item); + let item_text = authored_name_at(source_indices.clone(), item.clone()); + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), - ), - rust_items().struct_keyword.clone(), + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), ), - " ".to_string(), + rust_items().struct_keyword.clone(), + ), + v1_rt::concat( + v1_rt::concat(" ".to_string(), item_text), + "(pub std::marker::PhantomData<()>);".to_string(), ), - item_text, ), - "(pub std::marker::PhantomData<()>);".to_string(), - ) - } + "".to_string(), + ), + "".to_string(), + ) } pub fn emit_parametric_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - let type_params = emit_type_params(item.params.clone(), source_indices.clone()); - 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(), g.clone()), - ">".to_string(), - ), - None => "std::marker::PhantomData<()>".to_string(), - }; + let item_text = authored_name_at(source_indices.clone(), item.clone()); + let type_params = emit_type_params(item.params.clone(), source_indices.clone()); + 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(), g), + ">".to_string(), + ), + None => "std::marker::PhantomData<()>".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( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n" - .to_string(), - rust_visibility_prefix(), - ), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - item_text, - ), - type_params, + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), ), - "(pub ".to_string(), + rust_items().struct_keyword.clone(), ), - marker_ty, + v1_rt::concat(v1_rt::concat(" ".to_string(), item_text), type_params), ), - ");".to_string(), - ) - } + v1_rt::concat( + v1_rt::concat("(pub ".to_string(), marker_ty), + ");".to_string(), + ), + ), + "".to_string(), + ) } pub fn is_emittable_parametric_type_alias_item( @@ -5383,21 +4995,37 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs_name = authored_name_at(source_indices.clone(), rhs.clone()); - ((rhs_name.clone() != item_text) - && (((rhs.children.clone().len() as i64) > 0) - || ((((rhs.children.clone().len() as i64) == 0) - && (rhs_name.clone() != "".to_string())) - && alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - )))) + if rhs_name.as_str() != item_text.as_str() { + if (rhs.children.clone().len() as i64) > 0 { + alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + ) + } else if rhs_name.as_str() != "" { + alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + ) + } else { + false + } + } else { + false + } } } } @@ -5425,7 +5053,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for ln in local_names.clone().iter().cloned() { - if !(ln.clone() != n.clone()) { + if !(ln.clone().as_str() != n.clone().as_str()) { __all = false; break; } @@ -5567,7 +5195,7 @@ pub fn emit_specific_import_block( .iter() .cloned() { - if (p.clone() != "".to_string()) { + if (p.clone().as_str() != "".to_string().as_str()) { __result.push(p); } } @@ -5601,7 +5229,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => false, } { __found = true; @@ -5623,7 +5251,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for n in direct_names.clone().iter().cloned() { - if !(n.clone() != p.clone()) { + if !(n.clone().as_str() != p.clone().as_str()) { __all = false; break; } @@ -5648,7 +5276,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => false, } { __found = true; @@ -5732,7 +5360,9 @@ pub fn emit_specific_import_block( export_sets.clone(), source_indices.clone(), module_index.clone(), - ) == def_mod.clone()) + ) + .as_str() + == def_mod.clone().as_str()) { __result.push(n); } @@ -5810,13 +5440,13 @@ pub fn emit_specific_import_block( Rc::new({ let mut __result = Vec::new(); for l in type_direct_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } __result }), - if (other_direct_line.clone() != "".to_string()) { + if (other_direct_line.clone().as_str() != "".to_string().as_str()) { Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) @@ -5836,7 +5466,9 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => { + (found.clone().as_str() == p.clone().as_str()) + } None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -5847,7 +5479,9 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == p.clone()), + Some(found) => { + (found.clone().as_str() == p.clone().as_str()) + } None => false, }, } { @@ -5886,15 +5520,15 @@ pub fn emit_specific_import_block( __result.push({ let group = Rc::new({ let mut __result = Vec::new(); for p in remote_parent_list.clone().iter().cloned() { if { let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone() == p.clone()), + Some(found) => (found.clone().as_str() == p.clone().as_str()), None => false, }, } { __result.push(n); } } __result }).first().cloned(); match rep_variant.clone() { - Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()) == def_mod.clone()), - None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()) == def_mod.clone()), + Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()).as_str() == def_mod.clone().as_str()), + None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()).as_str() == def_mod.clone().as_str()), } } { __result.push(p); } } __result }); if ((group.clone().len() as i64) > 0) { @@ -5915,7 +5549,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -5926,7 +5560,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -5962,7 +5596,10 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone() == parent.clone()), + Some(found) => { + (found.clone().as_str() + == parent.clone().as_str()) + } None => { match reexport_variant_parent_in_import_module( n.clone(), @@ -5975,7 +5612,8 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib module_index.clone(), ) { Some(found) => { - (found.clone() == parent.clone()) + (found.clone().as_str() + == parent.clone().as_str()) } None => match find_variant_parent( type_summaries.clone(), @@ -6054,7 +5692,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib if ({ let mut __found = false; for p in parent_list.clone().iter().cloned() { - if (p.clone() == en.clone()) { + if (p.clone().as_str() == en.clone().as_str()) { __found = true; break; } @@ -6088,7 +5726,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in main_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -6097,7 +5735,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in variant_lines.iter().cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -6221,7 +5859,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { } pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: String) -> bool { - (((rust_pub_use_module_name(line.clone()) == mod_name) + (((rust_pub_use_module_name(line.clone()).as_str() == mod_name.as_str()) && v1_rt::contains(line.clone(), "::{".to_string())) && (((v1_rt::contains( line.clone(), @@ -6254,7 +5892,9 @@ pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> b { let mod_name = rust_pub_use_module_name(line.clone()); let name = rust_pub_use_singleton_name(line.clone()); - if ((mod_name.clone() == "".to_string()) || (name.clone() == "".to_string())) { + if ((mod_name.clone().as_str() == "".to_string().as_str()) + || (name.clone().as_str() == "".to_string().as_str())) + { false } else { { @@ -6279,14 +5919,17 @@ pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone() == "".to_string()) || ((names.clone().len() as i64) == 0)) { + if ((mod_name.clone().as_str() == "".to_string().as_str()) + || ((names.clone().len() as i64) == 0)) + { false } else { { let mut __found = false; for other in lines.iter().cloned() { - if (((((other.clone() != line.clone()) - && (rust_pub_use_module_name(other.clone()) == mod_name.clone())) + if (((((other.clone().as_str() != line.clone().as_str()) + && (rust_pub_use_module_name(other.clone()).as_str() + == mod_name.clone().as_str())) && v1_rt::contains(other.clone(), "::{".to_string())) && ((rust_pub_use_braced_names(other.clone()).len() as i64) > (names.clone().len() as i64))) @@ -6325,7 +5968,9 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> Rc> { let exact = unique_strings(Rc::new({ let mut __result = Vec::new(); for line in lines.iter().cloned() { - if (line.clone() != "".to_string()) { + if (line.clone().as_str() != "".to_string().as_str()) { __result.push(line); } } @@ -6438,7 +6083,8 @@ pub fn emit_imports( let mut __result = Vec::new(); for imp in imports.clone().iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - == import_module.clone()) + .as_str() + == import_module.clone().as_str()) { __result.push(imp); } @@ -6508,7 +6154,8 @@ pub fn emit_imports( source_indices.clone(), module_index.clone(), ); - if (specific_block.clone() != "".to_string()) { + if (specific_block.clone().as_str() != "".to_string().as_str()) + { v1_rt::concat( v1_rt::concat(wildcard_line.clone(), "\n".to_string()), specific_block.clone(), @@ -6638,74 +6285,44 @@ pub fn emit_typed_item( && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { rust_nominal_identity_carrier_def(item_text.clone()) + } else if is_zero_param_self_referential_opaque_decl( + item.clone(), + env.source_indices.clone(), + ) { + emit_zero_param_phantom_opaque_struct(item.clone(), env.source_indices.clone()) } else { - if is_zero_param_self_referential_opaque_decl( - item.clone(), - env.source_indices.clone(), - ) { - emit_zero_param_phantom_opaque_struct( - item.clone(), - env.source_indices.clone(), - ) - } else { - match rust_seed_host_numeric_alias( - item_text.clone(), - emit_info.corpus_repr.clone(), - ) { - Some(host) => v1_rt::concat( + 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(), - rust_items().type_alias_keyword.clone(), - ), - " ".to_string(), - ), - item_text.clone(), + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), ), - " = ".to_string(), + " ".to_string(), ), - host.clone(), + item_text.clone(), ), - ";".to_string(), + " = ".to_string(), ), - None => v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), - ), - " ".to_string(), - ), - item_text.clone(), - ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - Rc::new(vec![]), - shared_types, - emit_info.corpus_repr.clone(), - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), - ), - ), - ";".to_string(), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + Rc::new(vec![]), + shared_types, + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), ), - } - } + ), + ";".to_string(), + ) } } else { if is_type_decl_item(item.clone(), env.source_indices.clone()) { @@ -6714,11 +6331,19 @@ pub fn emit_typed_item( { rust_nominal_identity_carrier_def(item_text.clone()) } else { - match rust_seed_host_container_base( + if is_emittable_parametric_type_alias_item( + item.clone(), item_text.clone(), - emit_info.corpus_repr.clone(), + env.source_indices.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), ) { - Some(host) => { + { let type_params = emit_type_params( item.params.clone(), env.source_indices.clone(), @@ -6726,113 +6351,53 @@ pub fn emit_typed_item( let generic_names = item_generic_param_names( item.clone(), env.source_indices.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( - rust_visibility_prefix(), - rust_items() - .type_alias_keyword - .clone(), - ), - " ".to_string(), - ), - item_text.clone(), - ), - type_params, - ), - " = ".to_string(), - ), - host.clone(), - ), - "<".to_string(), - ), - generic_names.join(&", ".to_string()), - ), - ">;".to_string(), - ) - } - None => { - if is_emittable_parametric_type_alias_item( - item.clone(), - item_text.clone(), - env.source_indices.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - ) { - { - let type_params = emit_type_params( - item.params.clone(), - env.source_indices.clone(), - ); - let generic_names = item_generic_param_names( - item.clone(), - env.source_indices.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( - rust_visibility_prefix(), - rust_items() - .type_alias_keyword - .clone(), - ), - " ".to_string(), - ), - item_text.clone(), + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), ), - type_params, + " ".to_string(), ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - generic_names, - shared_types, - emit_info.corpus_repr.clone(), - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + item_text.clone(), ), + type_params, ), - ";".to_string(), - ) - } - } else { - if is_parametric_opaque_type_decl_item( - item.clone(), - env.source_indices.clone(), - ) { - emit_parametric_phantom_opaque_struct( - item.clone(), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + generic_names, + shared_types, env.source_indices.clone(), - ) - } else { - "".to_string() - } - } + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), + ) } + } else if is_parametric_opaque_type_decl_item( + item.clone(), + env.source_indices.clone(), + ) { + emit_parametric_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + "".to_string() } } } else { @@ -6876,7 +6441,6 @@ pub fn emit_typed_item( owned_bindings: v1_rt::rc_empty_set::(), 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(), @@ -6931,17 +6495,11 @@ pub fn emit_typed_item( item.clone(), registry.clone(), shared_types, - emit_info.corpus_repr.clone(), env.clone(), ) } else { if is_resource_def_item(item.clone()) { - emit_resource_def( - item.clone(), - shared_types, - emit_info.corpus_repr.clone(), - env.clone(), - ) + emit_resource_def(item.clone(), shared_types, env.clone()) } else { v1_rt::concat( v1_rt::concat( @@ -6972,7 +6530,9 @@ pub fn needs_box_wrapping( if v1_rt::set_contains(&shared_types, name.clone()) { break false; } else { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()).as_str() + != name.clone().as_str()) + { break false; } else { break v1_rt::set_contains(&recursive_types, name.clone()); @@ -7023,11 +6583,12 @@ pub fn is_function_type_param(param: Rc) -> bool { Some(inf) => is_type_variable(inf.clone()), None => false, }; - let same_source_span = (((param.span.clone().file.clone() - == type_expr.span.clone().file.clone()) + let same_source_span = (((param.span.clone().file.clone().as_str() + == type_expr.span.clone().file.clone().as_str()) && (param.span.clone().start.clone() == type_expr.span.clone().start.clone())) && (param.span.clone().end.clone() == type_expr.span.clone().end.clone())); - (((param.name.clone() != "".to_string()) && (param.name.clone() == type_expr.name.clone())) + (((param.name.clone().as_str() != "".to_string().as_str()) + && (param.name.clone().as_str() == type_expr.name.clone().as_str())) && (type_expr_is_var || same_source_span)) } } @@ -7148,10 +6709,11 @@ pub fn emit_type_def_from_connective( Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; - let validations = if (policy_validation.clone() == "".to_string()) { + let validations = if (policy_validation.clone().as_str() == "".to_string().as_str()) + { rename_validations.clone() } else { - if (rename_validations.clone() == "".to_string()) { + if (rename_validations.clone().as_str() == "".to_string().as_str()) { policy_validation.clone() } else { v1_rt::concat( @@ -7178,7 +6740,7 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), emit_info, ); - if (validations.clone() == "".to_string()) { + if (validations.clone().as_str() == "".to_string().as_str()) { enum_text } else { v1_rt::concat( @@ -7191,73 +6753,6 @@ pub fn emit_type_def_from_connective( } } -pub fn type_node_mentions_name( - n: Rc, - target: String, - source_indices: Rc>>, -) -> bool { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - if (authored_name_at(source_indices.clone(), n.clone()) == target.clone()) { - true - } else { - { - let mut __found = false; - for c in n.children.clone().iter().cloned() { - if type_node_mentions_name(c.clone(), target.clone(), source_indices.clone()) { - __found = true; - break; - } - } - __found - } - } - }) -} - -pub fn struct_unused_param_names( - generic_param_names: Rc>, - children: Rc>>, - source_indices: Rc>>, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for p in generic_param_names.iter().cloned() { - if !{ - let mut __found = false; - for child in children.clone().iter().cloned() { - if type_node_mentions_name( - field_node_type_expr(child.clone()), - p.clone(), - source_indices.clone(), - ) { - __found = true; - break; - } - } - __found - } { - __result.push(p); - } - } - __result - }) -} - -pub fn rust_phantom_marker_inner(unused: Rc>) -> String { - if ((unused.clone().len() as i64) == 1) { - unused.clone().join(&", ".to_string()) - } else { - v1_rt::concat( - v1_rt::concat("(".to_string(), unused.clone().join(&", ".to_string())), - ")".to_string(), - ) - } -} - -pub fn rust_phantom_field_name() -> String { - "_phantom".to_string() -} - pub fn emit_struct_from_children( name: String, type_params: String, @@ -7280,7 +6775,9 @@ pub fn emit_struct_from_children( name.clone(), children.clone(), env.source_indices.clone(), - ) != "".to_string()) + ) + .as_str() + != "".to_string().as_str()) { rust_nominal_ord_derives_for_shape( name.clone(), @@ -7332,32 +6829,7 @@ pub fn emit_struct_from_children( } __result }); - let unused_params = struct_unused_param_names( - generic_param_names.clone(), - children.clone(), - env.source_indices.clone(), - ); - let all_field_lines = if ((unused_params.clone().len() as i64) > 0) { - v1_rt::concat( - field_lines, - Rc::new(vec![v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(" ".to_string(), rust_visibility_prefix()), - rust_phantom_field_name(), - ), - ": std::marker::PhantomData<".to_string(), - ), - rust_phantom_marker_inner(unused_params.clone()), - ), - ">,".to_string(), - )]), - ) - } else { - field_lines - }; - let fields_str = all_field_lines.join(&"\n".to_string()); + let fields_str = field_lines.join(&"\n".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7391,7 +6863,6 @@ pub fn emit_struct_from_children( pub fn render_rust_type_with_applied_binding( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match find_property( @@ -7401,93 +6872,51 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if outer_name.as_str() != "" + && n.connective.clone() == Connective::NoConnective + && (n.children.clone().len() as i64) == 0 { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if (((outer_name.clone() != "".to_string()) - && (n.connective.clone() == Connective::NoConnective)) - && ((n.children.clone().len() as i64) == 0)) - { - if (outer_name.clone() != applied_name) { - render_rust_shared_type_if_needed( - outer_name.clone(), - 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.clone(), - shared_types.clone(), - ) - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types.clone(), - corpus_repr, - source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::< - String, - Rc>>, - >( - ), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), - ) - } - } + if outer_name != applied_name { + render_rust_shared_type_if_needed( + 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, + shared_types.clone(), + ) } else { render_rust_applied_type_shared( applied.clone(), Rc::new(vec![]), - shared_types.clone(), - corpus_repr, + shared_types, source_indices.clone(), - v1_rt::rc_empty_map::(), - Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), - recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::< - String, - Rc>>, - >(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types, + source_indices.clone(), + ) } } else { - render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr, - source_indices.clone(), - ) + render_rust_type(n.clone(), shared_types, source_indices.clone()) } } - None => render_rust_type( - n.clone(), - shared_types.clone(), - corpus_repr, - source_indices.clone(), - ), + None => render_rust_type(n.clone(), shared_types, source_indices.clone()), } } pub fn render_rust_field_type_with_applied_binding( field: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -7501,7 +6930,6 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( field.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } else { @@ -7514,24 +6942,17 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( authored_type.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } else { if ((authored_type.connective.clone() == Connective::NoConnective) && ((authored_type.children.clone().len() as i64) > 0)) { - render_rust_type( - authored_type.clone(), - shared_types, - corpus_repr, - source_indices.clone(), - ) + render_rust_type(authored_type.clone(), shared_types, source_indices.clone()) } else { render_rust_type_with_applied_binding( resolved_type(field.clone()), shared_types, - corpus_repr, source_indices.clone(), ) } @@ -7569,7 +6990,6 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7582,7 +7002,6 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( authored_child_type.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7595,7 +7014,6 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7642,7 +7060,6 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7650,7 +7067,6 @@ pub fn emit_struct_field_from_child( None => render_rust_type( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ), } @@ -7659,7 +7075,6 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7667,7 +7082,7 @@ pub fn emit_struct_field_from_child( } } }; - let generic_ty = if (struct_name == "PartialFunction".to_string()) { + let generic_ty = if (struct_name.as_str() == "PartialFunction".to_string().as_str()) { rust_normalize_partial_function_field_type_text(rust_normalize_witness_type_text(ty)) } else { ty @@ -7698,8 +7113,8 @@ pub fn emit_struct_field_from_child( let rename_attr = match Rc::new({ let mut __result = Vec::new(); for p in child.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), env.source_indices.clone()) - == "from_key".to_string()) + if (field_init_node_name_at(p.clone(), env.source_indices.clone()).as_str() + == "from_key".to_string().as_str()) { __result.push(p); } @@ -7744,18 +7159,19 @@ pub fn emit_rust_field_definition( { let snake = to_snake(authored.clone()); let emitted = emit_ident(authored.clone(), RenderTarget::Rust); - let keyword_rename = - if ((emitted.clone() != snake.clone()) && (rename_attr.clone() == "".to_string())) { + let keyword_rename = if ((emitted.clone().as_str() != snake.clone().as_str()) + && (rename_attr.clone().as_str() == "".to_string().as_str())) + { + v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), + snake.clone(), + ), + "\")]\n".to_string(), + ) + } else { + "".to_string() + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7825,7 +7241,7 @@ pub fn emit_enum_from_children( __result }); let variants_str = variant_lines.join(&"\n".to_string()); - let tag_line = if (serde_policy.enum_attr.clone() == "".to_string()) { + let tag_line = if (serde_policy.enum_attr.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) @@ -7867,7 +7283,7 @@ pub fn emit_enum_from_children( env.clone(), emit_info.clone(), ); - if (accessor_impl.clone() == "".to_string()) { + if (accessor_impl.clone().as_str() == "".to_string().as_str()) { enum_def } else { v1_rt::concat( @@ -7916,7 +7332,9 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> if !({ let mut __found = false; for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()) == fname.clone()) { + if (authored_name(env.clone(), f.clone()).as_str() + == fname.clone().as_str()) + { __found = true; break; } @@ -7980,7 +7398,8 @@ pub fn emit_enum_shared_accessors( match Rc::new({ let mut __result = Vec::new(); for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()) == fname.clone()) + if (authored_name(env.clone(), f.clone()).as_str() + == fname.clone().as_str()) { __result.push(f); } @@ -7993,7 +7412,6 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "".to_string(), @@ -8009,7 +7427,7 @@ pub fn emit_enum_shared_accessors( { let mut __all = true; for t in types.clone().iter().cloned() { - if !(t.clone() == first_type.clone()) { + if !(t.clone().as_str() == first_type.clone().as_str()) { __all = false; break; } @@ -8032,7 +7450,9 @@ pub fn emit_enum_shared_accessors( let ty = match Rc::new({ let mut __result = Vec::new(); for f in first_fielded.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()) == fname.clone()) { + if (authored_name(env.clone(), f.clone()).as_str() + == fname.clone().as_str()) + { __result.push(f); } } @@ -8044,7 +7464,6 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "compile_error!(\"enum shared accessor missing field metadata\")" @@ -8190,7 +7609,8 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) - && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)) == prefix.clone())) + && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)).as_str() + == prefix.clone().as_str())) { Some(v1_rt::substring( &value, @@ -8212,7 +7632,9 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { &value, (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), v1_rt::string_length(&value), - ) == suffix.clone())) + ) + .as_str() + == suffix.clone().as_str())) { Some(v1_rt::substring( &value, @@ -8225,120 +7647,67 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } -pub fn string_index_of_from(mut haystack: String, mut needle: String, mut pos: i64) -> Option { - loop { - if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { - break None; - } else { - if (v1_rt::substring( - &haystack, - pos.clone(), - (pos.clone() + v1_rt::string_length(&needle)), - ) == needle.clone()) - { - break Some(pos.clone()); - } else { - { - let __tco_0 = (pos + 1); - pos = __tco_0; - continue; - } - } - } - } -} - -pub fn string_index_of(haystack: String, needle: String) -> Option { - string_index_of_from(haystack, needle, 0) -} - pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, ) -> Option { - if (policy.error_message.clone() != None) { - None - } else { - match policy.rename_style.clone() { - Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { - { - let without_prefix = match policy.rename_prefix.clone() { - 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.clone()) { - Some(stripped) => stripped.clone(), - None => return None, - } - } - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } - } else { - None - } + if policy.error_message.is_some() { + return None; + } + match policy.rename_style.clone() { + Some(style) => { + if style.as_str() == "StripAffixAndSnakeCase" { + let without_prefix = match policy.rename_prefix.clone() { + Some(prefix) => match string_without_prefix(authored, prefix) { + Some(stripped) => stripped, + 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, + }, + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } else { + None } - None => { - if v1_rt::contains( - policy.enum_attr.clone(), - "rename_all = \"snake_case\"".to_string(), - ) { - Some(to_snake(authored)) - } else { - if (((policy.enum_attr.clone() == "".to_string()) - && (policy.rename_prefix.clone() == None)) - && (policy.rename_suffix.clone() == None)) - { - Some(authored) - } else { - None - } - } + } + None => { + if policy.enum_attr.contains("rename_all = \"snake_case\"") { + Some(to_snake(authored)) + } else if policy.enum_attr.is_empty() + && policy.rename_prefix.is_none() + && policy.rename_suffix.is_none() + { + Some(authored) + } else { + None } } } } -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)); - 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(), - )), - None => None, - } - } - None => None, - } - } +pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { + let needle = "tag = \""; + let start = policy.enum_attr.find(needle)? + needle.len(); + let rest = &policy.enum_attr[start..]; + let end = rest.find('"')?; + Some(rest[..end].to_string()) } -pub fn policy_is_untagged(policy: Rc) -> bool { - v1_rt::contains(policy.enum_attr.clone(), "untagged".to_string()) +pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { + policy.enum_attr.contains("untagged") } -pub fn policy_is_string_variant(policy: Rc) -> bool { - (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) - && (policy.rename_prefix.clone() == None)) - && (policy.rename_suffix.clone() == None)) - && (policy.rename_style.clone() == None)) +pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { + !policy.enum_attr.contains("tag =") + && policy.rename_prefix.is_none() + && policy.rename_suffix.is_none() + && policy.rename_style.is_none() } pub fn wire_variant_rename_attr_for_policy( @@ -8348,9 +7717,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.as_str() == "StripAffixAndSnakeCase" { v1_rt::concat( - v1_rt::concat(" #[serde(rename = \"".to_string(), tag.clone()), + v1_rt::concat(" #[serde(rename = \"".to_string(), tag), "\")]\n".to_string(), ) } else { @@ -8369,7 +7738,7 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { @@ -8432,7 +7801,7 @@ pub fn variant_rename_validations_for_policy( .iter() .cloned() { - if (text.clone() != "".to_string()) { + if (text.clone().as_str() != "".to_string().as_str()) { __result.push(text); } } @@ -8474,7 +7843,6 @@ pub fn enum_variant_field_type_node( pub fn render_variant_payload_type( n: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if ((n.connective.clone() == Connective::NoConnective) @@ -8488,7 +7856,6 @@ pub fn render_variant_payload_type( __result.push(render_rust_type( child_type_node(c.clone()), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), )); } @@ -8507,12 +7874,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.clone(), source_indices.clone()) } } @@ -8524,7 +7886,9 @@ 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.clone(), source_indices).as_str() == "0".to_string().as_str()) + } None => false, } } @@ -8559,7 +7923,8 @@ pub fn emit_variant_from_child( env.source_indices.clone(), ); let tuple_style = (positional_payload.clone() - || (serde_policy.enum_attr.clone() == "#[serde(untagged)]".to_string())); + || (serde_policy.enum_attr.clone().as_str() + == "#[serde(untagged)]".to_string().as_str())); if tuple_style { match child.children.clone().first().cloned() { Some(f) => { @@ -8580,14 +7945,12 @@ pub fn emit_variant_from_child( render_variant_payload_type( type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { render_rust_type( type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) }; @@ -8600,7 +7963,6 @@ pub fn emit_variant_from_child( render_rust_type_with_applied_binding( type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -8651,7 +8013,6 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8705,7 +8066,6 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8762,78 +8122,71 @@ pub fn emit_fn_def( shared_types: Rc>, emit_info: Rc, ) -> String { + if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { + if rust_emit_faithful_text_carrier(scope.type_env.source_indices.clone()) { + return seam_fn; + } else { + return "".to_string(); + } + } { - let si = scope.type_env.clone().source_indices.clone(); - 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() - } else { - "".to_string() - } - } - None => { - let type_params = function_type_params(params.clone()); - let value_params = function_value_params(params.clone()); - if function_type_params_have_collision(type_params.clone()) { - return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); - } - let type_params_str = emit_type_params(type_params.clone(), si.clone()); - let generic_param_names = Rc::new({ - let mut __result = Vec::new(); - for p in type_params.clone().iter().cloned() { - __result.push(generic_param_name_at(p.clone(), si.clone())); - } - __result - }); - let params_str = emit_params( + let si = scope.type_env.clone().source_indices.clone(); + let type_params = function_type_params(params.clone()); + let value_params = function_value_params(params.clone()); + if function_type_params_have_collision(type_params.clone()) { + return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); + } + let type_params_str = emit_type_params(type_params.clone(), si.clone()); + let generic_param_names = Rc::new({ + let mut __result = Vec::new(); + for p in type_params.clone().iter().cloned() { + __result.push(generic_param_name_at(p.clone(), si.clone())); + } + __result + }); + let params_str = emit_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + emit_info.read_only_params.clone(), + scope.type_env.clone(), + ); + let ret_str = emit_inferred( + inferred, + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + scope.type_env.clone(), + ); + let body_scope = build_params_scope(scope.clone(), value_params.clone()); + let depth = 0; + let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); + let needs_stacker = + (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) + && (use_tco.clone() == false)); + if use_tco.clone() { + { + let tco_params_str = emit_tco_params( value_params.clone(), generic_param_names.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), si.clone(), - emit_info.read_only_params.clone(), - emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); - let ret_str = emit_inferred( - inferred, - generic_param_names.clone(), + let body_str = emit_typed_tco_body( + body.clone(), + name.clone(), + value_params.clone(), + registry.clone(), + body_scope, + (depth.clone() + 1), shared_types.clone(), - emit_info.corpus_repr.clone(), - si.clone(), - emit_info.variant_to_enum.clone(), - scope.type_env.clone(), + emit_info.clone(), ); - let body_scope = build_params_scope(scope.clone(), value_params.clone()); - let depth = 0; - let use_tco = - is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); - let needs_stacker = - (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) - && (use_tco.clone() == false)); - if use_tco.clone() { - { - let tco_params_str = emit_tco_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - emit_info.corpus_repr.clone(), - 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.clone(), - registry.clone(), - body_scope, - (depth.clone() + 1), - shared_types.clone(), - emit_info.clone(), - ); - let kw = rust_items().func_keyword.clone(); + let kw = rust_items().func_keyword.clone(); + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -8844,53 +8197,49 @@ pub fn emit_fn_def( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - kw, - ), - " ".to_string(), - ), - emit_ident( - name.clone(), - RenderTarget::Rust, - ), + rust_visibility_prefix(), + kw, ), - type_params_str, + " ".to_string(), + ), + emit_ident( + name.clone(), + RenderTarget::Rust, ), - "(".to_string(), ), - tco_params_str, + type_params_str, ), - ")".to_string(), + "(".to_string(), ), - ret_str, + tco_params_str, ), - " {\n".to_string(), + ")".to_string(), ), - make_indent((depth.clone() + 1)), + ret_str, ), - body_str, + " {\n".to_string(), ), - "\n}".to_string(), - ) - } - } else { - emit_fn_def_non_tco( - name.clone(), - type_params_str, - params_str, - ret_str, - body.clone(), - registry.clone(), - body_scope, - depth.clone(), - shared_types.clone(), - emit_info.clone(), - needs_stacker, - ) - } + make_indent((depth.clone() + 1)), + ), + body_str, + ), + "\n}".to_string(), + ) } + } else { + emit_fn_def_non_tco( + name.clone(), + type_params_str, + params_str, + ret_str, + body.clone(), + registry.clone(), + body_scope, + depth.clone(), + shared_types.clone(), + emit_info.clone(), + needs_stacker, + ) } } } @@ -9050,16 +8399,13 @@ pub fn emit_func_def( uses.clone(), service_names, shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), - emit_info.variant_to_enum.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(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -9273,9 +8619,7 @@ pub fn emit_tco_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9286,9 +8630,7 @@ pub fn emit_tco_params( p.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9302,9 +8644,7 @@ pub fn emit_tco_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9314,19 +8654,15 @@ pub fn emit_tco_param( authored.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, env, ) }; @@ -9351,10 +8687,8 @@ pub fn emit_func_params( uses: Rc>>, service_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9365,10 +8699,8 @@ pub fn emit_func_params( p.clone(), Rc::new(vec![]), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9388,7 +8720,6 @@ pub fn emit_func_params( render_rust_type( resource_use_resource(u.clone()), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), ), )); @@ -9413,13 +8744,12 @@ pub fn emit_func_params( pub fn emit_func_inferred( inferred: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { v1_rt::concat( v1_rt::concat( " -> Result<".to_string(), - render_rust_type(inferred, shared_types, corpus_repr, source_indices), + render_rust_type(inferred, shared_types, source_indices), ), ", Box>".to_string(), ) @@ -9429,10 +8759,8 @@ pub fn emit_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9443,10 +8771,8 @@ pub fn emit_params( p.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9460,20 +8786,16 @@ pub fn render_rust_param_sig_type( param: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param); + let type_node = resolved_type(param.clone()); render_rust_fn_sig_type( type_node, generic_param_names, shared_types, - corpus_repr, source_indices, - variant_to_enum, env, ) } @@ -9483,9 +8805,7 @@ pub fn emit_rust_param_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -9497,9 +8817,7 @@ pub fn emit_rust_param_type( param_node_type_expr(p.clone()), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9511,9 +8829,7 @@ pub fn emit_rust_param_type( rt.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -9534,10 +8850,8 @@ pub fn emit_rust_param_type( n.clone(), generic_param_names.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), + env, ) } } @@ -9546,10 +8860,8 @@ pub fn emit_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9559,19 +8871,15 @@ pub fn emit_param( authored.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, - corpus_repr, source_indices.clone(), - variant_to_enum, env, ) }; @@ -9590,9 +8898,7 @@ pub fn emit_inferred( inferred: Rc, generic_param_names: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -9601,9 +8907,7 @@ pub fn emit_inferred( inferred, generic_param_names, shared_types, - corpus_repr, source_indices, - variant_to_enum, env, ), ) @@ -9686,11 +8990,12 @@ pub fn collect_field_binding_string_guards( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone() == "0".to_string()) { - v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) - } else { - v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) - }; + let field_path = + if (fb_name.clone().as_str() == "0".to_string().as_str()) { + v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) + } else { + v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) + }; let bind_name = pattern_string_binding_name(field_path.clone()); match positional_payload_string_guard( fb_pat.clone(), @@ -9709,7 +9014,7 @@ pub fn collect_field_binding_string_guards( nested_path.clone(), source_indices.clone(), ); - if (nested.clone() == "".to_string()) { + if (nested.clone().as_str() == "".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![nested.clone()]) @@ -9740,7 +9045,7 @@ pub fn collect_pattern_string_guards( field_bindings: fbs, .. } => { - if (((n.clone() == "Present".to_string()) + if (((n.clone().as_str() == "Present".to_string().as_str()) && (parent.clone().as_deref() == Some("Optional".to_string()).as_deref())) && ((fbs.clone().len() as i64) == 1)) { @@ -9783,7 +9088,8 @@ pub fn collect_pattern_string_guards( match fbs.clone().first().cloned() { Some(fb) => { if (field_binding_name_at(fb.clone(), source_indices.clone()) - == "0".to_string()) + .as_str() + == "0".to_string().as_str()) { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( @@ -9924,7 +9230,7 @@ pub fn pattern_parent_enum( type_summaries: Rc>>, ) -> Option { { - let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) + let scrut_is_known_enum = ((scrut_type.clone().as_str() != "".to_string().as_str()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { parent_enum.clone() @@ -9967,12 +9273,13 @@ pub fn unique_variant_parent( } pub fn is_optional_variant_name(name: String) -> bool { - ((name.clone() == "Present".to_string()) || (name.clone() == "Absent".to_string())) + ((name.clone().as_str() == "Present".to_string().as_str()) + || (name.clone().as_str() == "Absent".to_string().as_str())) } pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent.clone() == "Optional".to_string()), + Some(parent) => (parent.clone().as_str() == "Optional".to_string().as_str()), None => false, } } @@ -10030,7 +9337,7 @@ pub fn emit_variant_pattern( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone() == "Present".to_string()) { + if (name.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -10043,7 +9350,7 @@ pub fn emit_variant_pattern( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone() == "Witness".to_string()) { + if (parent.clone().as_str() == "Witness".to_string().as_str()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -10055,7 +9362,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10086,8 +9393,8 @@ pub fn emit_variant_pattern( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()) - == "0".to_string()) + if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() + == "0".to_string().as_str()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10290,24 +9597,25 @@ pub fn emit_variant_pattern( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone() == "0".to_string()) { + let field_path = if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -10318,13 +9626,15 @@ pub fn emit_variant_pattern( } } else { { - let is_shorthand = - match (*fb_pat.clone()).clone() { - MatchPattern::Bind { - name: n, .. - } => (n.clone() == fb_name.clone()), - _ => false, - }; + let is_shorthand = match (*fb_pat.clone()) + .clone() + { + MatchPattern::Bind { name: n, .. } => { + (n.clone().as_str() + == fb_name.clone().as_str()) + } + _ => false, + }; if is_shorthand.clone() { emit_ident( fb_name.clone(), @@ -10332,25 +9642,26 @@ pub fn emit_variant_pattern( ) } else { { - let field_path = if (fb_name.clone() - == "0".to_string()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let pat_str = emit_pattern( fb_pat.clone(), field_path.clone(), @@ -10421,7 +9732,7 @@ pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc { let mut __found = false; for name in rc_analysis.ref_bound_fields.clone().iter().cloned() { - if (name.clone() == field_name.clone()) { + if (name.clone().as_str() == field_name.clone().as_str()) { __found = true; break; } @@ -10457,7 +9768,8 @@ pub fn analyze_rc_pattern( ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone() == "Present".to_string()) + matches_option_rc_variant: ((n.clone().as_str() + == "Present".to_string().as_str()) && inner.matches_rc_variant.clone()), needs_rc_pattern: inner.needs_rc_pattern.clone(), ref_bound_fields: Rc::new(vec![]), @@ -10487,17 +9799,18 @@ pub fn analyze_rc_pattern( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let inner_scrut = if (fb_name.clone() == "0".to_string()) { - positional_payload_scrut_type( - resolved_parent.clone(), - n.clone(), - fb.clone(), - emit_info.clone(), - source_indices.clone(), - ) - } else { - "".to_string() - }; + let inner_scrut = + if (fb_name.clone().as_str() == "0".to_string().as_str()) { + positional_payload_scrut_type( + resolved_parent.clone(), + n.clone(), + fb.clone(), + emit_info.clone(), + source_indices.clone(), + ) + } else { + "".to_string() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -10657,7 +9970,7 @@ pub fn emit_variant_pattern_rc_aware( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone() == "Present".to_string()) { + if (name.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -10670,7 +9983,7 @@ pub fn emit_variant_pattern_rc_aware( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone() == "Witness".to_string()) { + if (parent.clone().as_str() == "Witness".to_string().as_str()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -10682,7 +9995,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone() == "Present".to_string())) + if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10721,8 +10034,8 @@ pub fn emit_variant_pattern_rc_aware( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()) - == "0".to_string()) + if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() + == "0".to_string().as_str()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10957,24 +10270,25 @@ pub fn emit_variant_pattern_rc_aware( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone() == "0".to_string()) { + let field_path = if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -11002,7 +10316,10 @@ pub fn emit_variant_pattern_rc_aware( { MatchPattern::Bind { name: n, .. - } => (n.clone() == fb_name.clone()), + } => { + (n.clone().as_str() + == fb_name.clone().as_str()) + } _ => false, }; if is_shorthand.clone() { @@ -11012,26 +10329,26 @@ pub fn emit_variant_pattern_rc_aware( ) } else { { - let field_path = if (fb_name - .clone() - == "0".to_string()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone().as_str() + == "0".to_string().as_str()) + { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let inner_analysis = analyze_rc_pattern( fb_pat.clone(), @@ -11139,7 +10456,7 @@ pub fn rc_pattern_preludes( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - if (fb_name.clone() == "0".to_string()) { + if (fb_name.clone().as_str() == "0".to_string().as_str()) { { let payload_scrut = positional_payload_scrut_type( resolved_parent.clone(), @@ -11162,7 +10479,9 @@ pub fn rc_pattern_preludes( source_indices.clone(), emit_info.clone(), ); - if (inner_preludes.clone() == "".to_string()) { + if (inner_preludes.clone().as_str() + == "".to_string().as_str()) + { Rc::new(vec![]) } else { Rc::new(vec![inner_preludes.clone()]) @@ -11247,7 +10566,7 @@ pub fn explicit_record_struct_name( false }; let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { + if (nname.clone().as_str() == "__EmitTypeCacheMiss".to_string().as_str()) { type_name.clone() } else { if n_is_error { @@ -11318,8 +10637,119 @@ pub fn apply_field_clone(expr: String, field: String) -> String { ) } -pub fn clone_iterator_suffix() -> String { - sharing_for_target(RenderTarget::Rust).clone_suffix.clone() +pub fn clone_iterator_suffix() -> String { + sharing_for_target(RenderTarget::Rust).clone_suffix.clone() +} + +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + match v1_rt::map_get(&variant_to_enum, name.clone()) { + Some(parent) => { + if parent.as_str() != "" { + v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name + } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { + carrier + } else { + rust_qualify_type_leaf_name(name, variant_to_enum) + } +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if (child.children.clone().len() as i64) == 0 { + let vname = authored_name(env.clone(), child.clone()); + if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + v1_rt::concat(vname, ";".to_string()), + )); + } + } + } + __result + }) + .join("\n") +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut names: Vec = Vec::new(); + for item in items.iter().cloned() { + if is_type_def_item(item.clone()) + && item + .children + .clone() + .iter() + .all(|c| c.children.clone().len() as i64 == 0) + { + for child in item.children.clone().iter().cloned() { + if (child.children.clone().len() as i64) == 0 { + let vname = authored_name(env.clone(), child.clone()); + if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !names.iter().any(|n| n == &vname) + { + names.push(vname); + } + } + } + } + } + names + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env.clone()) + .iter() + .cloned() + { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + v1_rt::concat(vname, ";".to_string()), + )); + } + __result + }) + .join("\n") } pub fn effective_variant_parent( @@ -11332,7 +10762,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()) { + if (p.clone().as_str() != "".to_string().as_str()) { Some(p.clone()) } else { None @@ -11345,7 +10775,8 @@ pub fn effective_variant_parent( None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); - if (((rt.ident_span.clone() != None) && (rt_name.clone() != name.clone())) + if (((rt.ident_span.clone() != None) + && (rt_name.clone().as_str() != name.clone().as_str())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), name.clone(), @@ -11372,10 +10803,14 @@ pub fn emit_var_ref( emit_info: Rc, source_indices: Rc>>, ) -> String { - if ((name.clone() == "none".to_string()) || (name.clone() == "None".to_string())) { + if ((name.clone().as_str() == "none".to_string().as_str()) + || (name.clone().as_str() == "None".to_string().as_str())) + { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((name.clone() == "true".to_string()) || (name.clone() == "false".to_string())) { + if ((name.clone().as_str() == "true".to_string().as_str()) + || (name.clone().as_str() == "false".to_string().as_str())) + { emit_keyword(name.clone(), RenderTarget::Rust) } else { { @@ -11391,9 +10826,9 @@ pub fn emit_var_ref( let ref_str = match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(name.clone()) - && (enum_name.clone() == "Optional".to_string())) + && (enum_name.clone().as_str() == "Optional".to_string().as_str())) { - if (name.clone() == "Present".to_string()) { + if (name.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -11483,10 +10918,14 @@ pub fn emit_typed_expr_base( .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { + if ((n.clone().as_str() == "none".to_string().as_str()) + || (n.clone().as_str() == "None".to_string().as_str())) + { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { + if ((n.clone().as_str() == "true".to_string().as_str()) + || (n.clone().as_str() == "false".to_string().as_str())) + { emit_keyword(n.clone(), RenderTarget::Rust) } else { { @@ -11500,9 +10939,10 @@ pub fn emit_typed_expr_base( match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(n.clone()) - && (enum_name.clone() == "Optional".to_string())) + && (enum_name.clone().as_str() + == "Optional".to_string().as_str())) { - if (n.clone() == "Present".to_string()) { + if (n.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -11551,35 +10991,6 @@ pub fn emit_typed_expr_base( } } -pub fn field_access_field_is_boxed( - base: Rc, - field: String, - scope: Rc, - shared_types: Rc>, - emit_info: Rc, -) -> bool { - { - let base_struct = expand_type_for_field_access( - resolved_type(base), - scope.type_env.clone(), - scope.module_name.clone(), - ); - match find_child_named( - base_struct, - field, - scope.type_env.clone().source_indices.clone(), - ) { - Some(field_child) => needs_box_wrapping( - resolved_type(field_child.clone()), - emit_info.recursive_type_set.clone(), - shared_types, - scope.type_env.clone().source_indices.clone(), - ), - None => false, - } - } -} - pub fn emit_typed_field_access( base: Rc, field: String, @@ -11642,7 +11053,9 @@ pub fn emit_typed_field_access( if (authored_name_at( scope.type_env.clone().source_indices.clone(), pair.1.clone(), - ) == field.clone()) + ) + .as_str() + == field.clone().as_str()) { __result.push(pair); } @@ -11712,39 +11125,19 @@ pub fn emit_typed_field_access( } _ => false, }; - let field_is_boxed = field_access_field_is_boxed( - base.clone(), - field.clone(), - scope.clone(), - shared_types.clone(), - emit_info.clone(), - ); - if field_is_boxed { + if base_is_owned { v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(*".to_string(), base_str), - ".".to_string(), - ), - emit_ident(field.clone(), RenderTarget::Rust), - ), - ").clone()".to_string(), + v1_rt::concat(base_str, ".".to_string()), + emit_ident(field.clone(), RenderTarget::Rust), ) } else { - if base_is_owned { + apply_type_template1( + sharing.clone_value.clone(), v1_rt::concat( v1_rt::concat(base_str, ".".to_string()), emit_ident(field.clone(), RenderTarget::Rust), - ) - } else { - apply_type_template1( - sharing.clone_value.clone(), - v1_rt::concat( - v1_rt::concat(base_str, ".".to_string()), - emit_ident(field.clone(), RenderTarget::Rust), - ), - ) - } + ), + ) } } }, @@ -11799,7 +11192,7 @@ pub fn type_needs_rc_seen( } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); if (normed.inferred.clone() != None) { - let next_seen = if (canonical.clone() == "".to_string()) { + let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11812,12 +11205,12 @@ pub fn type_needs_rc_seen( continue; } } else { - if ((canonical.clone() != "".to_string()) + if ((canonical.clone().as_str() != "".to_string().as_str()) && emit_map_has(seen.clone(), canonical.clone())) { break false; } else { - let next_seen = if (canonical.clone() == "".to_string()) { + let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11855,7 +11248,6 @@ pub fn rust_runtime_bridge_name(function_name: String) -> String { pub fn rust_empty_map_value_type_str( map_type: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match map_type.children.clone().get(1 as usize).cloned() { @@ -11863,10 +11255,9 @@ pub fn rust_empty_map_value_type_str( let rendered = render_rust_type( child_type_node(value_child.clone()), shared_types, - corpus_repr, source_indices, ); - if (rendered.clone() == "".to_string()) { + if (rendered.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { rendered.clone() @@ -11879,7 +11270,6 @@ pub fn rust_empty_map_value_type_str( pub fn rust_empty_map_kv_type_str( map_type: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -11887,7 +11277,6 @@ pub fn rust_empty_map_kv_type_str( Some(key_child) => render_rust_type( child_type_node(key_child.clone()), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), ), None => "".to_string(), @@ -11895,10 +11284,11 @@ pub fn rust_empty_map_kv_type_str( let val_str = rust_empty_map_value_type_str( map_type.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), ); - if ((key_str.clone() != "".to_string()) && (val_str.clone() != "".to_string())) { + if ((key_str.clone().as_str() != "".to_string().as_str()) + && (val_str.clone().as_str() != "".to_string().as_str())) + { v1_rt::concat( v1_rt::concat(key_str.clone(), ", ".to_string()), val_str.clone(), @@ -11926,12 +11316,12 @@ pub fn rust_btree_set_element_ord_eligible( ) -> bool { { let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); - (((((((elem_name.clone() == "String".to_string()) - || (elem_name.clone() == "Int".to_string())) - || (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.clone().as_str() == "String".to_string().as_str()) + || (elem_name.clone().as_str() == "Int".to_string().as_str())) + || (elem_name.clone().as_str() == "Bool".to_string().as_str())) + || (elem_name.clone().as_str() == "Unit".to_string().as_str())) + || (elem_name.clone().as_str() == "Secret".to_string().as_str())) + || (elem_name.clone().as_str() == "Bytes".to_string().as_str())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -12004,7 +11394,7 @@ pub fn emit_rust_empty_set_expr( shared_types, source_indices.clone(), ); - if (elem_str.clone() != "".to_string()) { + if (elem_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_set::<".to_string(), @@ -12307,70 +11697,36 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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.module_name.clone(), - ); - let variant_name = match tn.clone() { - Some(n) => n.clone(), - None => "".to_string(), - }; - let peeled_type_name = if (((parent_enum.clone() == None) - && (expanded_rt.connective.clone() == Connective::Conj)) - && (expanded_rt.ident_span.clone() != None)) - { - { - let concrete = authored_name_at(si.clone(), expanded_rt.clone()); - if ((concrete.clone() != "".to_string()) - && (concrete.clone() != variant_name.clone())) - { - Some(concrete.clone()) - } else { - tn.clone() - } - } - } else { - tn.clone() - }; let raw = emit_typed_record_lit( - peeled_type_name, + tn.clone(), fs, parent_enum.clone(), - expanded_rt.clone(), + resolved_type(expr.clone()), registry, scope.clone(), depth, shared_types.clone(), emit_info.clone(), ); + let si = scope.type_env.clone().source_indices.clone(); + let variant_name = match tn.clone() { + Some(n) => n.clone(), + None => "".to_string(), + }; let rc_name = match parent_enum.clone() { Some(en) => en.clone(), None => match contextual_variant_parent( variant_name.clone(), parent_enum.clone(), - expanded_rt.clone(), + resolved_type(expr.clone()), emit_info.clone(), si.clone(), ) { - Some(p) => p.clone(), - None => { - 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.clone() - } else { - variant_name.clone() - } - } + Some(p) => p, + None => variant_name.clone(), }, }; - if ((rc_name.clone() != "".to_string()) + if ((rc_name.clone().as_str() != "".to_string().as_str()) && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) @@ -12805,7 +12161,7 @@ pub fn contextual_variant_parent( None => { let rt_name = authored_name_at(source_indices, resolved_type.clone()); if (((resolved_type.ident_span.clone() != None) - && (rt_name.clone() != variant_name.clone())) + && (rt_name.clone().as_str() != variant_name.clone().as_str())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), variant_name.clone(), @@ -12848,7 +12204,7 @@ pub fn emit_discriminant_call_lowering( scope.clone(), depth, shared_types.clone(), - emit_info.clone(), + emit_info, 1024, ); let ty_name = @@ -12910,7 +12266,7 @@ pub fn emit_discriminant_call_lowering( ), "\"".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ",".to_string(), @@ -12947,7 +12303,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ) } } @@ -12956,7 +12312,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ), } } @@ -12973,16 +12329,15 @@ pub fn emit_typed_call_expr( emit_info: Rc, ) -> String { { - let call_str = if (func.clone() == "empty_map".to_string()) { + let call_str = if (func.clone().as_str() == "empty_map".to_string().as_str()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( ret_type.clone(), shared_types, - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone() != "".to_string()) { + if (kv_type_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -12999,7 +12354,7 @@ pub fn emit_typed_call_expr( .to_string(), } } else { - if (func.clone() == "empty_set".to_string()) { + if (func.clone().as_str() == "empty_set".to_string().as_str()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( @@ -13043,7 +12398,7 @@ pub fn emit_typed_call( emit_info: Rc, ) -> String { { - if (func.clone() == "get".to_string()) { + if (func.clone().as_str() == "get".to_string().as_str()) { { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); @@ -13087,7 +12442,7 @@ pub fn emit_typed_call( return get_result; } } - if (func.clone() == "with".to_string()) { + if (func.clone().as_str() == "with".to_string().as_str()) { { let with_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); if ((with_args.clone().len() as i64) == 0) { @@ -13185,7 +12540,7 @@ pub fn emit_typed_call( } } } - if (func.clone() == "to_string".to_string()) { + if (func.clone().as_str() == "to_string".to_string().as_str()) { { let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -13206,24 +12561,45 @@ pub fn emit_typed_call( ), ").to_string()".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ), None => "compile_error!(\"to_string call missing value argument\")".to_string(), }; return ts_result; } } - if (func.clone() == "utf8_decode_bytes".to_string()) { + if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { { let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let decode_result = match decode_args.first().cloned() { - Some(value_arg) => v1_rt::concat(v1_rt::concat("String::from_utf8(".to_string(), emit_typed_expr(arg_value(value_arg.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)), ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?".to_string()), - None => "compile_error!(\"utf8_decode_bytes call missing value argument\")".to_string(), -}; + Some(value_arg) => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "String::from_utf8(".to_string(), + emit_typed_expr( + arg_value(value_arg.clone()), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ), + ), + ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" + .to_string(), + ), + "".to_string(), + ), + None => { + "compile_error!(\"utf8_decode_bytes call missing value argument\")" + .to_string() + } + }; return decode_result; } } - if (func.clone() == "discriminant".to_string()) { + if (func.clone().as_str() == "discriminant".to_string().as_str()) { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { @@ -13242,10 +12618,10 @@ pub fn emit_typed_call( return disc_result; } } - let collection_scope = if ((((func.clone() == "map".to_string()) - || (func.clone() == "filter".to_string())) - || (func.clone() == "flat_map".to_string())) - || (func.clone() == "fold".to_string())) + let collection_scope = if ((((func.clone().as_str() == "map".to_string().as_str()) + || (func.clone().as_str() == "filter".to_string().as_str())) + || (func.clone().as_str() == "flat_map".to_string().as_str())) + || (func.clone().as_str() == "fold".to_string().as_str())) { { let call_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -13420,7 +12796,8 @@ 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.clone() + && (func.clone().as_str() == "concat".to_string().as_str())) && ((all_args.clone().len() as i64) > 2)) { emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) @@ -13476,11 +12853,12 @@ pub fn fill_default_args( let is_provided = { let mut __found = false; for n in provided_names.clone().iter().cloned() { - if (n.clone() + if (n.clone().as_str() == param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - )) + ) + .as_str()) { __found = true; break; @@ -13593,7 +12971,7 @@ pub fn emit_nested_rt_concat( break acc.clone(); } Some(arg) => { - let next_acc = if (acc.clone() == "".to_string()) { + let next_acc = if (acc.clone().as_str() == "".to_string().as_str()) { arg.clone() } else { v1_rt::concat( @@ -13793,7 +13171,6 @@ pub fn emit_typed_slice( pub fn collection_element_type( receiver_type: Option>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match receiver_type.as_deref().cloned() { @@ -13819,7 +13196,6 @@ pub fn collection_element_type( render_rust_type( elem_node.clone(), shared_types, - corpus_repr, source_indices.clone(), ) } @@ -13876,7 +13252,6 @@ pub fn lambda_param_type_strs( param_nodes: Rc>>, fallback_types: Rc>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> Rc> { Rc::new({ @@ -13916,7 +13291,6 @@ pub fn lambda_param_type_strs( Some(render_rust_type( param_type.clone(), shared_types.clone(), - corpus_repr.clone(), source_indices.clone(), )) } @@ -13980,7 +13354,6 @@ pub fn emit_typed_collection_lambda( pn.clone(), Rc::new(vec![elem_type_str]), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13991,7 +13364,7 @@ pub fn emit_typed_collection_lambda( lambda_scope, depth, shared_types.clone(), - emit_info.clone(), + emit_info, 1024, ); v1_rt::concat( @@ -14005,7 +13378,7 @@ pub fn emit_typed_collection_lambda( scope.clone(), depth, shared_types.clone(), - emit_info.clone(), + emit_info, 1024, ), } @@ -14037,9 +13410,10 @@ pub fn emit_typed_fold_lambda( .skip(1 as usize) .collect::>(), ); - let safe_acc_type = if (((acc_type_str.clone() == "Rc>".to_string()) - || (acc_type_str.clone() == "Vec<()>".to_string())) - || (acc_type_str.clone() == "Option<()>".to_string())) + let safe_acc_type = if (((acc_type_str.clone().as_str() + == "Rc>".to_string().as_str()) + || (acc_type_str.clone().as_str() == "Vec<()>".to_string().as_str())) + || (acc_type_str.clone().as_str() == "Option<()>".to_string().as_str())) { "_".to_string() } else { @@ -14071,7 +13445,6 @@ pub fn emit_typed_fold_lambda( Rc::new(vec![]), fallback_types, shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -14089,7 +13462,7 @@ pub fn emit_typed_fold_lambda( Some(n) => n.clone(), None => "".to_string(), }; - let needs_unwrap = ((acc_name.clone() != "".to_string()) + let needs_unwrap = ((acc_name.clone().as_str() != "".to_string().as_str()) && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); if needs_unwrap { { @@ -14161,7 +13534,6 @@ pub fn emit_rust_fold_method_call( let elem_type_str = collection_element_type( receiver.inferred.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { @@ -14313,7 +13685,6 @@ pub fn emit_rust_fold_method_call( ), 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(), }), None => emit_info.clone(), } @@ -14346,7 +13717,6 @@ pub fn emit_rust_fold_method_call( owned_bindings: emit_info.owned_bindings.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(), }), None => emit_info.clone(), } @@ -14360,7 +13730,6 @@ pub fn emit_rust_fold_method_call( let acc_type_str = render_rust_type( acc_type_node.clone(), shared_types.clone(), - 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) { @@ -14421,19 +13790,18 @@ pub fn emit_rust_fold_method_call( arg_value(init_arg.clone()), scope.type_env.clone().source_indices.clone(), ); - if ((((init_func.clone() == "empty_map".to_string()) - && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str.clone() != "".to_string())) + if ((((init_func.clone().as_str() == "empty_map".to_string().as_str()) + && (acc_type_str.clone().as_str() != "_".to_string().as_str())) + && (acc_type_str.clone().as_str() != "".to_string().as_str())) && !acc_has_unit_child.clone()) { { let kv_type_str = rust_empty_map_kv_type_str( acc_type_node.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone() != "".to_string()) { + if (kv_type_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -14446,12 +13814,13 @@ pub fn emit_rust_fold_method_call( } } } else { - if (init_func.clone() == "empty_map".to_string()) { + if (init_func.clone().as_str() == "empty_map".to_string().as_str()) { "Rc::new(HashMap::new()) /* BRIDGE: fold empty_map accumulator type unresolved */".to_string() } else { - if ((((init_func.clone() == "empty_set".to_string()) - && (acc_type_str.clone() != "_".to_string())) - && (acc_type_str.clone() != "".to_string())) + if ((((init_func.clone().as_str() + == "empty_set".to_string().as_str()) + && (acc_type_str.clone().as_str() != "_".to_string().as_str())) + && (acc_type_str.clone().as_str() != "".to_string().as_str())) && !acc_has_unit_child.clone()) { emit_rust_empty_set_expr( @@ -14460,7 +13829,8 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func.clone() == "empty_set".to_string()) { + if (init_func.clone().as_str() == "empty_set".to_string().as_str()) + { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -14557,7 +13927,6 @@ pub fn emit_rust_sort_by_method_call( render_rust_type( elem.clone(), shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ) } else { @@ -14582,7 +13951,7 @@ pub fn emit_rust_sort_by_method_call( let iter_str = apply_type_template1(sharing.iter_owned.clone(), recv_str); let a_clone = apply_type_template1(sharing.clone_value.clone(), "a".to_string()); let b_clone = apply_type_template1(sharing.clone_value.clone(), "b".to_string()); - if (elem_type_str.clone() == "_".to_string()) { + if (elem_type_str.clone().as_str() == "_".to_string().as_str()) { 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()) @@ -15069,7 +14438,9 @@ pub fn emit_rust_first_method_call( if (expr_method_name_at( receiver.clone(), scope.type_env.clone().source_indices.clone(), - ) == "skip".to_string()) + ) + .as_str() + == "skip".to_string().as_str()) { { let skip_recv = method_receiver(receiver.clone()); @@ -15307,7 +14678,9 @@ pub fn emit_typed_method_call( if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), - ) == "serde_json::Value".to_string()) + ) + .as_str() + == "serde_json::Value".to_string().as_str()) { __result.push(p); } @@ -15404,7 +14777,7 @@ pub fn emit_typed_method_call( scope.type_env.clone().source_indices.clone(), method_def.clone(), ); - if (method_name.clone() == "fold".to_string()) { + if (method_name.clone().as_str() == "fold".to_string().as_str()) { emit_rust_fold_method_call( method_call_node, fold_accumulator_type.clone(), @@ -15418,7 +14791,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "sort_by".to_string()) { + if (method_name.clone().as_str() == "sort_by".to_string().as_str()) { emit_rust_sort_by_method_call( receiver.clone(), args.clone(), @@ -15429,7 +14802,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "map".to_string()) { + if (method_name.clone().as_str() == "map".to_string().as_str()) { emit_rust_map_method_call( receiver.clone(), args.clone(), @@ -15443,7 +14816,9 @@ pub fn emit_typed_method_call( match Rc::new({ let mut __result = Vec::new(); for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone() == method_name.clone()) { + if (s.method_name.clone().as_str() + == method_name.clone().as_str()) + { __result.push(s); } } @@ -15463,7 +14838,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ), None => { - if (method_name.clone() == "get".to_string()) { + if (method_name.clone().as_str() == "get".to_string().as_str()) + { emit_rust_get_method_call( receiver.clone(), args.clone(), @@ -15474,7 +14850,9 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "with".to_string()) { + if (method_name.clone().as_str() + == "with".to_string().as_str()) + { emit_rust_with_method_call( receiver.clone(), args.clone(), @@ -15485,8 +14863,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() - == "string_contains".to_string()) + if (method_name.clone().as_str() + == "string_contains".to_string().as_str()) { emit_rust_generic_method_call( "string_contains".to_string(), @@ -15500,7 +14878,9 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "concat".to_string()) { + if (method_name.clone().as_str() + == "concat".to_string().as_str()) + { { let recv_str = emit_typed_expr( receiver.clone(), @@ -15537,7 +14917,8 @@ pub fn emit_typed_method_call( ) } } else { - if (method_name.clone() == "first".to_string()) + if (method_name.clone().as_str() + == "first".to_string().as_str()) { emit_rust_first_method_call( receiver.clone(), @@ -15928,8 +15309,8 @@ pub fn emit_typed_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone() != "".to_string()) - && (arm_guard_str.clone() != "".to_string())) + let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) + && (arm_guard_str.clone().as_str() != "".to_string().as_str())) { v1_rt::concat( v1_rt::concat( @@ -15939,10 +15320,10 @@ pub fn emit_typed_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone() != "".to_string()) { + if (field_guards.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone() != "".to_string()) { + if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -16204,13 +15585,14 @@ pub fn wrap_rust_record_field_value( field_name: String, ) -> String { { - let is_bounded_lattice_field = (struct_name.clone() == "BoundedLattice".to_string()); + let is_bounded_lattice_field = + (struct_name.clone().as_str() == "BoundedLattice".to_string().as_str()); if rust_record_field_needs_fn_rc(scope.clone(), struct_name.clone(), field_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone() == "meet".to_string()) - || (field_name.clone() == "join".to_string()))) + && ((field_name.clone().as_str() == "meet".to_string().as_str()) + || (field_name.clone().as_str() == "join".to_string().as_str()))) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -16224,8 +15606,8 @@ pub fn wrap_rust_record_field_value( v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone() == "top".to_string()) - || (field_name.clone() == "bottom".to_string()))) + && ((field_name.clone().as_str() == "top".to_string().as_str()) + || (field_name.clone().as_str() == "bottom".to_string().as_str()))) { v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { @@ -16256,13 +15638,16 @@ pub fn is_already_optional( binding_kind: binding_kind, .. } => { - if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) + if (((n.clone().as_str() == "Present".to_string().as_str()) + || (n.clone().as_str() == "Absent".to_string().as_str())) && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true } else { - if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { + if ((n.clone().as_str() == "none".to_string().as_str()) + || (n.clone().as_str() == "None".to_string().as_str())) + { true } else { match texpr.inferred.clone().as_deref().cloned() { @@ -16286,8 +15671,8 @@ pub fn is_already_optional( } => match tn { Some(name) => { ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) - && ((name.clone() == "Present".to_string()) - || (name.clone() == "Absent".to_string()))) + && ((name.clone().as_str() == "Present".to_string().as_str()) + || (name.clone().as_str() == "Absent".to_string().as_str()))) } None => false, }, @@ -16509,7 +15894,7 @@ pub fn emit_field_value_with_context( Some(en) => en.clone(), None => variant_name.clone(), }; - if ((rc_name.clone() != "".to_string()) + if ((rc_name.clone().as_str() != "".to_string().as_str()) && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) @@ -16761,15 +16146,10 @@ pub fn emit_typed_record_lit( false }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); - if (((((resolved_type.ident_span.clone() != None) - && (rt_name.clone() != tn.clone())) + if ((((resolved_type.ident_span.clone() != None) + && (rt_name.clone().as_str() != tn.clone().as_str())) && !rt_is_type_var) - && (rt_name.clone() != "Error".to_string())) - && variant_belongs_to_enum( - emit_info.type_summaries.clone(), - tn.clone(), - rt_name.clone(), - )) + && (rt_name.clone().as_str() != "Error".to_string().as_str())) { Some(rt_name.clone()) } else { @@ -16781,7 +16161,7 @@ pub fn emit_typed_record_lit( && (is_optional_parent(parent_enum.clone()) || is_optional_parent(effective_parent.clone()))); let rust_tn = if optional_variant.clone() { - if (tn.clone() == "Present".to_string()) { + if (tn.clone().as_str() == "Present".to_string().as_str()) { "Some".to_string() } else { "None".to_string() @@ -16800,7 +16180,8 @@ pub fn emit_typed_record_lit( None => rust_tn, } }; - if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) + if ((optional_variant.clone() + && (tn.clone().as_str() == "Present".to_string().as_str())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -16840,8 +16221,8 @@ pub fn emit_typed_record_lit( let is_positional_ctor = (((fields.clone().len() as i64) == 1) && match fields.clone().first().cloned() { Some(f) => { - (field_init_node_name_at(f.clone(), si.clone()) - == "0".to_string()) + (field_init_node_name_at(f.clone(), si.clone()).as_str() + == "0".to_string().as_str()) } None => false, }); @@ -17003,13 +16384,18 @@ pub fn emit_typed_record_lit( &ftm, fname.clone(), ) { - Some(ft) => match rust_zero_value( - ft.clone(), - emit_info.corpus_repr.clone(), - ) { - Some(_) => true, - None => false, - }, + Some(ft) => { + match rust_zero_value( + ft.clone(), + scope + .type_env + .source_indices + .clone(), + ) { + Some(_) => true, + None => false, + } + } None => false, }; (has_zv.clone() @@ -17033,7 +16419,10 @@ pub fn emit_typed_record_lit( Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { match v1_rt::map_get(&ftm, fname.clone()) { - Some(ft) => match rust_zero_value(ft.clone(), emit_info.corpus_repr.clone()) { + Some(ft) => match rust_zero_value( + ft.clone(), + scope.type_env.source_indices.clone(), + ) { Some(zv) => Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": ".to_string()), zv.clone()), ",".to_string())]), None => Rc::new(vec![]), }, @@ -17049,48 +16438,7 @@ pub fn emit_typed_record_lit( } None => Rc::new(vec![]), }; - let phantom_strs = match lookup_type_by_name( - scope.type_env.clone(), - tn.clone(), - ) { - Some(struct_decl) => { - let is_struct = (struct_decl.connective.clone() - == Connective::Conj); - let pnames = Rc::new({ - let mut __result = Vec::new(); - for p in struct_decl.params.clone().iter().cloned() - { - __result.push(generic_param_name_at( - p.clone(), - si.clone(), - )); - } - __result - }); - let unused = struct_unused_param_names( - pnames, - struct_decl.children.clone(), - si.clone(), - ); - let has_unused = ((unused.len() as i64) > 0); - if (is_struct && has_unused) { - Rc::new(vec![v1_rt::concat( - v1_rt::concat( - " ".to_string(), - rust_phantom_field_name(), - ), - ": std::marker::PhantomData,".to_string(), - )]) - } else { - Rc::new(vec![]) - } - } - None => Rc::new(vec![]), - }; - let all_field_strs = v1_rt::concat( - v1_rt::concat(field_strs, default_strs), - phantom_strs, - ); + let all_field_strs = v1_rt::concat(field_strs, default_strs); let fields_str = all_field_strs.join(&"\n".to_string()); let raw = v1_rt::concat( v1_rt::concat( @@ -17110,15 +16458,18 @@ pub fn emit_typed_record_lit( } } -pub fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> Option { - if (type_name.clone() == "Int".to_string()) { +pub fn rust_zero_value( + type_name: String, + source_indices: Rc>>, +) -> Option { + if (type_name.clone().as_str() == "Int".to_string().as_str()) { Some("0".to_string()) } else { - if (type_name.clone() == "Bool".to_string()) { + if (type_name.clone().as_str() == "Bool".to_string().as_str()) { Some("false".to_string()) } else { - if (type_name.clone() == "String".to_string()) { - if corpus_repr_is_faithful(corpus_repr) { + if (type_name.clone().as_str() == "String".to_string().as_str()) { + if rust_emit_faithful_text_carrier(source_indices) { Some( "crate::v2_std_algebra::freemonoid_empty::()" .to_string(), @@ -17186,8 +16537,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str, - emit_info.corpus_repr.clone(), + l_str.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ")".to_string(), @@ -17200,8 +16551,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str, - emit_info.corpus_repr.clone(), + r_str.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ")".to_string(), @@ -17233,8 +16584,12 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str, - emit_info.corpus_repr.clone(), + l_str.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), ), ), " ".to_string(), @@ -17244,8 +16599,8 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str, - emit_info.corpus_repr.clone(), + r_str.clone(), + scope.type_env.clone().source_indices.clone(), ), ), ")".to_string(), @@ -17378,7 +16733,7 @@ pub fn emit_typed_string_interp( .iter() .cloned() { - if (a.clone() != "".to_string()) { + if (a.clone().as_str() != "".to_string().as_str()) { __result.push(a); } } @@ -17387,7 +16742,7 @@ pub fn emit_typed_string_interp( if ((args.clone().len() as i64) == 0) { emit_rust_host_to_dag_string_via_seam( v1_rt::concat(v1_rt::concat("\"".to_string(), fmt_str), "\"".to_string()), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ) } else { { @@ -17403,7 +16758,7 @@ pub fn emit_typed_string_interp( ), ")".to_string(), ), - emit_info.corpus_repr.clone(), + scope.type_env.clone().source_indices.clone(), ) } } @@ -17564,7 +16919,9 @@ pub fn emit_tco_init_stmt( if (param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) == n.clone()) + ) + .as_str() + == n.clone().as_str()) { __found = true; break; @@ -17918,7 +17275,9 @@ pub fn emit_rust_tco_let( if (param_node_name_at( p.clone(), frame.scope.clone().type_env.clone().source_indices.clone(), - ) == n.clone()) + ) + .as_str() + == n.clone().as_str()) { __found = true; break; @@ -18205,8 +17564,8 @@ pub fn emit_typed_tco_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone() != "".to_string()) - && (arm_guard_str.clone() != "".to_string())) + let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) + && (arm_guard_str.clone().as_str() != "".to_string().as_str())) { v1_rt::concat( v1_rt::concat( @@ -18216,10 +17575,10 @@ pub fn emit_typed_tco_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone() != "".to_string()) { + if (field_guards.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone() != "".to_string()) { + if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -18289,7 +17648,10 @@ 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.clone()).as_str() + == var_name.clone().as_str()) + } _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -18476,7 +17838,6 @@ pub fn emit_service_def( item: Rc, registry: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -18496,7 +17857,6 @@ pub fn emit_service_def( op_children.clone(), registry, shared_types, - corpus_repr, env.clone(), item.clone(), ); @@ -18576,7 +17936,6 @@ pub fn emit_service_impl( op_children: Rc>>, registry: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18599,7 +17958,6 @@ pub fn emit_service_impl( registry.clone(), (depth.clone() + 1), shared_types.clone(), - corpus_repr.clone(), env.clone(), service_item.clone(), )); @@ -18665,7 +18023,7 @@ pub fn emit_service_new_method( }, None => "".to_string(), }; - let base_url_default = if (from_config.clone() != "".to_string()) { + let base_url_default = if (from_config.clone().as_str() != "".to_string().as_str()) { from_config.clone() } else { if fs.has_rest.clone() { @@ -18690,7 +18048,7 @@ pub fn emit_service_new_method( } else { "".to_string() }; - if (from_fallback.clone() != "".to_string()) { + if (from_fallback.clone().as_str() != "".to_string().as_str()) { from_fallback.clone() } else { "http://localhost".to_string() @@ -18758,7 +18116,7 @@ pub fn emit_auth_source_ctor( ) -> String { match (*source_expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { - Some(variant) => if (variant.clone() == "EnvVar".to_string()) { + Some(variant) => if (variant.clone().as_str() == "EnvVar".to_string().as_str()) { 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()) }, @@ -18802,7 +18160,6 @@ pub fn emit_operation_method( registry: Rc>>, depth: i64, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18823,17 +18180,15 @@ pub fn emit_operation_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), - v1_rt::rc_empty_map::(), - env.clone().clone(), + env.clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone() == "".to_string()) { + let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -18841,7 +18196,6 @@ pub fn emit_operation_method( let ret_type = render_rust_type( resolved_type(op_node.clone()), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), ); let eff_transport = effective_operation_transport(op_node.clone(), transport); @@ -18856,7 +18210,6 @@ pub fn emit_operation_method( op_node.clone(), env.source_indices.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), ); let mock_props = Rc::new({ @@ -18880,7 +18233,6 @@ pub fn emit_operation_method( op_node.clone(), env.clone(), shared_types.clone(), - corpus_repr.clone(), ); let body = v1_rt::concat( v1_rt::concat( @@ -18962,7 +18314,6 @@ pub fn emit_dry_run_branch_from_props( op_node: Rc, env: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, ) -> String { { let log_line = v1_rt::concat( @@ -19000,7 +18351,7 @@ let prelude = match wire_opt.clone() { 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()) +v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let __rest_wire: ".to_string(), render_rust_type(wire_ty, shared_types, source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) } }, None => v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()), @@ -19019,7 +18370,7 @@ let raw = match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed dry-run: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for mock field: ".to_string()), ch_name.clone()), "\");".to_string()), }; @@ -19042,6 +18393,13 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } } } else { + // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single + // authority): compile_error! -> panic! in the dry-run missing-fixture branch. + // Applied by hand because regen-fixpoint is temporarily broken (§7 hole). + // DISSOLUTION lane: bright-stag's adhoc-1bdd0259-2e3 (re-repair the hole + add a + // regen-equals-committed CI drift-gate). When it lands, a clean regen reproduces + // this line from the .dag — delete this hand-patch; the dissolution check is + // regen-output == this mirror modulo HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19066,7 +18424,6 @@ pub fn emit_transport_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { if is_rest_transport(transport.clone(), source_indices.clone()) { @@ -19079,7 +18436,6 @@ pub fn emit_transport_call( op_node, source_indices.clone(), shared_types, - corpus_repr, env, ) } else { @@ -19091,7 +18447,6 @@ pub fn emit_transport_call( depth, inferred, op_node, - corpus_repr, source_indices.clone(), ) } else { @@ -19113,7 +18468,6 @@ pub fn emit_rest_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19128,11 +18482,7 @@ pub fn emit_rest_call( http_method, source_indices.clone(), ); - let query_line = emit_rest_query_line( - transport.clone(), - corpus_repr.clone(), - source_indices.clone(), - ); + let query_line = emit_rest_query_line(transport.clone(), source_indices.clone()); let body_line = emit_rest_body_line(transport.clone(), source_indices.clone()); let headers = transport_headers(transport.clone(), source_indices.clone()); let header_lines = Rc::new({ @@ -19165,7 +18515,6 @@ pub fn emit_rest_call( transport.clone(), source_indices.clone(), shared_types, - corpus_repr.clone(), env, ); let all_lines = Rc::new({ @@ -19180,7 +18529,7 @@ pub fn emit_rest_call( .iter() .cloned() { - if (l.clone() != "".to_string()) { + if (l.clone().as_str() != "".to_string().as_str()) { __result.push(l); } } @@ -19425,7 +18774,6 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_rest_query_line( transport: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match transport_query(transport, source_indices.clone()) { @@ -19448,7 +18796,7 @@ pub fn emit_rest_query_line( RenderTarget::Rust, source_indices.clone(), ), - corpus_repr.clone(), + source_indices.clone(), ), ), ")".to_string(), @@ -19511,7 +18859,7 @@ pub fn has_response_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 9) { false } else { - (v1_rt::substring(&name, 0, 9) == "response_".to_string()) + (v1_rt::substring(&name, 0, 9).as_str() == "response_".to_string().as_str()) } } @@ -19522,8 +18870,8 @@ pub fn child_from_key( match Rc::new({ let mut __result = Vec::new(); for p in ch.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "from_key".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "from_key".to_string().as_str()) { __result.push(p); } @@ -19577,8 +18925,8 @@ pub fn has_response_200_property( { let mut __found = false; for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "response_200".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "response_200".to_string().as_str()) { __found = true; break; @@ -19596,8 +18944,8 @@ pub fn operation_response_200_resolved_type( match Rc::new({ let mut __result = Vec::new(); for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "response_200".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "response_200".to_string().as_str()) { __result.push(p); } @@ -19616,7 +18964,7 @@ pub fn operation_response_200_resolved_type( source_indices.clone(), normalize_access_type_node(v.clone()), ); - if (type_name.clone() == "".to_string()) { + if (type_name.clone().as_str() == "".to_string().as_str()) { None } else { lookup_type_by_name(env, type_name.clone()) @@ -19634,7 +18982,7 @@ pub fn is_json_wire_declaration_type( ) -> bool { { let n = authored_name_at(source_indices, normalize_access_type_node(t)); - if (n.clone() == "Json".to_string()) { + if (n.clone().as_str() == "Json".to_string().as_str()) { true } else { { @@ -19645,7 +18993,7 @@ pub fn is_json_wire_declaration_type( .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone() == "Json".to_string()), + Some(last) => (last.clone().as_str() == "Json".to_string().as_str()), None => false, } } @@ -19696,7 +19044,7 @@ pub fn wire_child_for_segment( Some(k) => k.clone(), None => authored.clone(), }; - (wire_key.clone() == seg.clone()) + (wire_key.clone().as_str() == seg.clone().as_str()) } { __result.push(ch); } @@ -19812,7 +19160,7 @@ pub fn emit_wire_struct_path_chain( .iter() .cloned() { - if (s.clone() != "".to_string()) { + if (s.clone().as_str() != "".to_string().as_str()) { __result.push(s); } } @@ -19878,7 +19226,6 @@ pub fn emit_json_value_extract( var_name: String, from_path: String, dag_type_name: String, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19900,8 +19247,9 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); - let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name.clone()); - let accessor = if (dag_type_name.clone() == "String".to_string()) { + let is_dag_string = dag_type_name.as_str() == "String"; + let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); + let accessor = if is_dag_string { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19909,7 +19257,7 @@ pub fn emit_json_value_extract( ".and_then(|v| v.as_str()).map(|s| ".to_string(), emit_rust_host_to_dag_string_via_seam( "s.to_string()".to_string(), - corpus_repr, + source_indices.clone(), ), ), ").ok_or(\"missing field: ".to_string(), @@ -19919,7 +19267,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "i64".to_string()) { + if (rust_type.clone().as_str() == "i64".to_string().as_str()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_i64()).ok_or(\"missing field: ".to_string(), @@ -19928,7 +19276,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "f64".to_string()) { + if (rust_type.clone().as_str() == "f64".to_string().as_str()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_f64()).ok_or(\"missing field: ".to_string(), @@ -19937,7 +19285,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone() == "bool".to_string()) { + if (rust_type.clone().as_str() == "bool".to_string().as_str()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -19974,7 +19322,6 @@ pub fn emit_from_key_extraction( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20012,7 +19359,6 @@ pub fn emit_from_key_extraction( render_rust_type( wire_ty, shared_types, - corpus_repr.clone(), source_indices.clone(), ), ), @@ -20042,7 +19388,7 @@ match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed response: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for output field: ".to_string()), ch_name.clone()), "\");".to_string()), } @@ -20097,7 +19443,8 @@ pub fn emit_plain_response_body( { let is_text = match transport_response_format(transport, source_indices.clone()) { Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) + (authored_name_at(source_indices.clone(), fmt.clone()).as_str() + == "Text".to_string().as_str()) } None => false, }; @@ -20114,7 +19461,6 @@ pub fn emit_response_code_handling( transport: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20134,7 +19480,6 @@ pub fn emit_response_code_handling( op_node.clone(), source_indices.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), ) } else { @@ -20152,7 +19497,6 @@ pub fn emit_response_code_handling( transport.clone(), source_indices.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), )); } @@ -20184,22 +19528,21 @@ pub fn emit_response_arm( transport: Rc, source_indices: Rc>>, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 9, v1_rt::string_length(&name)); let is_success = if (v1_rt::string_length(&code_str) >= 1) { - (v1_rt::substring(&code_str, 0, 1) == "2".to_string()) + (v1_rt::substring(&code_str, 0, 1).as_str() == "2".to_string().as_str()) } else { false }; - let pattern = if (code_str.clone() == "nonzero".to_string()) { + let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { "_".to_string() } else { if ((v1_rt::string_length(&code_str) == 3) - && (v1_rt::substring(&code_str, 1, 3) == "xx".to_string())) + && (v1_rt::substring(&code_str, 1, 3).as_str() == "xx".to_string().as_str())) { { let prefix = v1_rt::substring(&code_str, 0, 1); @@ -20227,7 +19570,6 @@ pub fn emit_response_arm( op_node, source_indices.clone(), shared_types, - corpus_repr, env, ), ), @@ -20255,14 +19597,13 @@ pub fn has_exit_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5) == "exit_".to_string()) + (v1_rt::substring(&name, 0, 5).as_str() == "exit_".to_string().as_str()) } } pub fn emit_exit_code_handling( op_node: Rc, inferred: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -20282,8 +19623,8 @@ pub fn emit_exit_code_handling( let has_nonzero = { let mut __found = false; for p in exit_props.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "exit_nonzero".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "exit_nonzero".to_string().as_str()) { __found = true; break; @@ -20297,7 +19638,6 @@ pub fn emit_exit_code_handling( __result.push(emit_exit_arm( p.clone(), inferred.clone(), - corpus_repr.clone(), source_indices.clone(), )); } @@ -20306,7 +19646,16 @@ pub fn emit_exit_code_handling( let default_arm = if has_nonzero { "".to_string() } else { - v1_rt::concat(v1_rt::concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr.clone())), ") },".to_string()) + v1_rt::concat( + v1_rt::concat( + "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), + emit_rust_host_to_dag_string_via_seam( + "stderr".to_string(), + source_indices.clone(), + ), + ), + ") },".to_string(), + ) }; v1_rt::concat( v1_rt::concat( @@ -20329,18 +19678,17 @@ pub fn emit_exit_code_handling( pub fn emit_exit_arm( prop: Rc, inferred: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 5, v1_rt::string_length(&name)); - let pattern = if (code_str.clone() == "nonzero".to_string()) { + let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { "_".to_string() } else { code_str.clone() }; - let is_success = (code_str.clone() == "0".to_string()); + let is_success = (code_str.clone().as_str() == "0".to_string().as_str()); if is_success { v1_rt::concat( v1_rt::concat( @@ -20353,7 +19701,22 @@ pub fn emit_exit_arm( " },".to_string(), ) } else { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string()), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr)), ") },".to_string()) + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(" ".to_string(), pattern), + " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), + ), + emit_rust_host_to_dag_string_via_seam( + "stderr".to_string(), + source_indices.clone(), + ), + ), + ") },".to_string(), + ), + "".to_string(), + ) } } } @@ -20365,7 +19728,6 @@ pub fn emit_shell_call( depth: i64, inferred: Rc, op_node: Rc, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -20410,7 +19772,6 @@ pub fn emit_shell_call( emit_shell_argv_element( first_arg.clone(), optional_params.clone(), - corpus_repr.clone(), source_indices.clone(), ), ), @@ -20452,7 +19813,6 @@ pub fn emit_shell_call( emit_shell_argv_element( arg.clone(), optional_params.clone(), - corpus_repr.clone(), source_indices.clone(), ), ), @@ -20513,12 +19873,8 @@ pub fn emit_shell_call( let wait_line = "let output = output.wait_with_output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = emit_exit_code_handling( - op_node.clone(), - inferred, - corpus_repr.clone(), - source_indices.clone(), - ); + let return_line = + emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![ @@ -20538,12 +19894,8 @@ pub fn emit_shell_call( let output_line = " .output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = emit_exit_code_handling( - op_node.clone(), - inferred, - corpus_repr.clone(), - source_indices.clone(), - ); + let return_line = + emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![wd_line, output_line, check_line, return_line]), @@ -20557,7 +19909,6 @@ pub fn emit_shell_call( pub fn emit_shell_argv_element( arg: Rc, optional_params: Rc>, - corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match (*arg.expr_data.clone()).clone() { @@ -20656,10 +20007,10 @@ pub fn emit_shell_argv_element( if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), - corpus_repr, + source_indices.clone(), ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), source_indices.clone()) } } _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), @@ -20726,7 +20077,7 @@ pub fn emit_shell_return( } __result }); - let lines = if (stderr_line.clone() != "".to_string()) { + let lines = if (stderr_line.clone().as_str() != "".to_string().as_str()) { v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() @@ -20753,13 +20104,13 @@ pub fn emit_shell_return( pub fn emit_shell_channel_expr(channel: String, is_optional: bool) -> String { { - let base = if (channel.clone() == "exit_success".to_string()) { + let base = if (channel.clone().as_str() == "exit_success".to_string().as_str()) { "output.status.success()".to_string() } else { - if (channel.clone() == "stderr".to_string()) { + if (channel.clone().as_str() == "stderr".to_string().as_str()) { "stderr.clone()".to_string() } else { - if (channel.clone() == "stdout_lines".to_string()) { + if (channel.clone().as_str() == "stdout_lines".to_string().as_str()) { "Rc::new(stdout.lines().filter(|l| !l.is_empty()).map(|l| l.trim().to_string()).collect())".to_string() } else { "stdout.clone()".to_string() @@ -20831,7 +20182,6 @@ pub fn emit_local_call(op_name: String) -> String { pub fn emit_resource_def( item: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20854,7 +20204,6 @@ pub fn emit_resource_def( __result.push(emit_capability_method( c.clone(), shared_types.clone(), - corpus_repr.clone(), env.clone(), )); } @@ -20885,7 +20234,6 @@ pub fn emit_resource_def( pub fn emit_capability_method( cap_node: Rc, shared_types: Rc>, - corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20904,17 +20252,15 @@ pub fn emit_capability_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), - v1_rt::rc_empty_map::(), - env.clone().clone(), + env.clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone() == "".to_string()) { + let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -20922,7 +20268,6 @@ pub fn emit_capability_method( let ret = render_rust_type( resolved_type(cap_node.clone()), shared_types.clone(), - corpus_repr.clone(), env.source_indices.clone(), ); let items = rust_items(); @@ -21011,11 +20356,10 @@ pub fn emit_data_def( let raw_ty_str = render_rust_type_with_applied_binding( render_type_node, shared_types.clone(), - emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) - || (raw_ty_str.clone() == "Rc".to_string())) + let ty_str = if ((raw_ty_str.clone().as_str() == "BoundedLattice".to_string().as_str()) + || (raw_ty_str.clone().as_str() == "Rc".to_string().as_str())) { match field_value_by_name( value.clone(), @@ -21027,10 +20371,12 @@ pub fn emit_data_def( scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); - if (top_type_name.clone() == "".to_string()) { + if (top_type_name.clone().as_str() == "".to_string().as_str()) { raw_ty_str.clone() } else { - if (raw_ty_str.clone() == "Rc".to_string()) { + if (raw_ty_str.clone().as_str() + == "Rc".to_string().as_str()) + { v1_rt::concat( v1_rt::concat( "Rc { let lattice_value = field_value_by_name( @@ -21333,31 +20678,38 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( + v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), - ), - ), "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), ), - emit_info.corpus_repr.clone(), + "\"".to_string(), ), + scope + .type_env + .clone() + .source_indices + .clone(), + ), + ), + v1_rt::concat( + v1_rt::concat( + ", ".to_string(), + val_str.clone(), ), - ", ".to_string(), + ");".to_string(), ), - val_str.clone(), ), - ");".to_string(), + "".to_string(), ) }); } @@ -21433,18 +20785,13 @@ pub fn emit_data_def_body( pub fn emit_test_file( module_name: String, projections: Rc>>, - corpus_repr: RustCorpusRepr, ) -> Rc { { let depth = 0; let test_fns = Rc::new({ let mut __result = Vec::new(); for p in projections.iter().cloned() { - __result.push(emit_operation_test( - p.clone(), - (depth.clone() + 1), - corpus_repr.clone(), - )); + __result.push(emit_operation_test(p.clone(), (depth.clone() + 1))); } __result }); @@ -21495,16 +20842,13 @@ pub fn emit_test_file( } } -pub fn rust_test_signature_comment( - projection: Rc, - corpus_repr: RustCorpusRepr, -) -> String { +pub fn rust_test_signature_comment(projection: Rc) -> String { { let stub_env = Rc::new(TypeEnv { - bindings: v1_rt::rc_empty_map::>(), + bindings: Rc::new(HashMap::new()), recursive_types: Rc::new(vec![]), - recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), + recursive_type_set: Rc::new(HashMap::new()), + inductive_fields: Rc::new(HashMap::new()), source_indices: projection.source_indices.clone(), intern_table: empty_intern_table(), }); @@ -21520,9 +20864,7 @@ pub fn rust_test_signature_comment( param_node_type_expr(p.clone()), Rc::new(vec![]), v1_rt::rc_empty_set::(), - corpus_repr.clone(), projection.source_indices.clone(), - v1_rt::rc_empty_map::(), stub_env.clone(), ), )); @@ -21559,11 +20901,7 @@ pub fn rust_test_signature_comment( } } -pub fn emit_operation_test( - projection: Rc, - depth: i64, - corpus_repr: RustCorpusRepr, -) -> String { +pub fn emit_operation_test(projection: Rc, depth: i64) -> String { { let test_name = rust_test_name(projection.clone()); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -21580,12 +20918,12 @@ pub fn emit_operation_test( __result }); let args_str = param_args.join(&", ".to_string()); - let call_args = if (args_str.clone() == "".to_string()) { + let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { 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.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())), "\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()) } } @@ -21682,8 +21020,8 @@ pub fn emit_cargo_dep(name: String, version: String, features: Rc>) pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { { let header = v1_rt::concat( - format!("[package]\nname = \"{}\"\nversion = \"0.1.0\"", crate_name), - "\nedition = \"2021\"\n".to_string(), + v1_rt::concat("[package]\nname = \"".to_string(), crate_name), + "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n".to_string(), ); let workspace = "\n[workspace]\n".to_string(); let base_deps = Rc::new(vec![ @@ -21783,8 +21121,8 @@ pub fn resolve_param_default( ItemKind::DataItem => match Rc::new({ let mut __result = Vec::new(); for i in module_items.iter().cloned() { - if (authored_name_at(source_indices.clone(), i.clone()) - == authored_name_at(source_indices.clone(), dv.clone())) + if (authored_name_at(source_indices.clone(), i.clone()).as_str() + == authored_name_at(source_indices.clone(), dv.clone()).as_str()) { __result.push(i); } @@ -21994,7 +21332,9 @@ pub fn find_resource_module(resource_name: String, modules: Rc String { { - let about_attr = if (about.clone() != "".to_string()) { + let about_attr = if (about.clone().as_str() != "".to_string().as_str()) { v1_rt::concat( v1_rt::concat(", about = \"".to_string(), about.clone()), "\"".to_string(), @@ -22566,18 +21907,11 @@ pub fn emit_cli_param_type_node( if ((n.children.clone().len() as i64) == 0) { { let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone() == "String".to_string()) { - "String".to_string() + let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); + if (mapped.clone().as_str() != nname.clone().as_str()) { + mapped.clone() } else { - { - let mapped = - coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone() != nname.clone()) { - mapped.clone() - } else { - "String".to_string() - } - } + "String".to_string() } } } else { @@ -22648,7 +21982,7 @@ pub fn emit_main_fn( ";".to_string(), ) }; - let body_lines = if (dry_run_line.clone() == "".to_string()) { + let body_lines = if (dry_run_line.clone().as_str() == "".to_string().as_str()) { v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) } else { v1_rt::concat( @@ -22683,7 +22017,15 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) + v1_rt::concat( + v1_rt::concat( + "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" + .to_string(), + " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" + .to_string(), + ), + " },".to_string(), + ) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index e716da211b3..a0c3dd4540f 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -35,14 +35,13 @@ pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_access::AccessCheckResultNode; pub use crate::v1_compiler_infer_access::{check_index_access_node, check_slice_access_node}; pub use crate::v1_compiler_infer_cycle::detect_type_cycles_kahn; -use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ add_emit_item_summary, build_enum_field_summaries, build_struct_field_summaries, derive_variant_to_enum, empty_emit_graph_info, lookup_emit_type_summary, }; pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, + EmitGraphInfo, EmitInfoBuildState, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ inductive_fields_for, inductive_fields_list_to_map, is_recursive_type, @@ -164,7 +163,8 @@ use std::collections::HashMap; use std::rc::Rc; pub fn is_witness_type_name(name: String) -> bool { - ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) + ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -547,7 +547,7 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (field_type_name.clone() == parent_name.clone()) { + if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -575,15 +575,17 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = ((value_type.clone() == parent_name.clone()) + let is_recursive_element = ((value_type.clone().as_str() + == parent_name.clone().as_str()) || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = if (value_type.clone() == parent_name.clone()) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = + if (value_type.clone().as_str() == parent_name.clone().as_str()) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -751,8 +753,8 @@ pub fn namespace_root_from_properties( match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "namespace_root".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "namespace_root".to_string().as_str()) { __result.push(p); } @@ -882,7 +884,8 @@ pub fn rejects_string_for_optional_coproduct_field( let expected_is_optional_coproduct = ((expected.return_cardinality.clone() == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); - let got_is_string = (authored_name_at(source_indices, got) == "String".to_string()); + let got_is_string = + (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); (expected_is_optional_coproduct && got_is_string) } } @@ -903,7 +906,9 @@ pub fn record_lit_expected_fields( if (authored_name_at( scope.type_env.clone().source_indices.clone(), v.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) { __result.push(v); } @@ -937,7 +942,9 @@ pub fn record_lit_expanded_from_expected( if (((authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -948,7 +955,9 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), expanded.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) { Some(expanded.clone()) } else { @@ -960,7 +969,9 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), rt.clone(), - ) == tn.clone()) + ) + .as_str() + == tn.clone().as_str()) { Some(rt.clone()) } else { @@ -1004,7 +1015,8 @@ pub fn record_lit_instantiated_fields( Some(tn) => match expected { Some(exp) => { if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - != tn.clone()) + .as_str() + != tn.clone().as_str()) { None } else { @@ -1174,9 +1186,10 @@ pub fn type_node_is_callable(n: Rc) -> bool { pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (v1_rt::substring(&module_name, 0, 3) == "v2.".to_string())); + && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (v1_rt::substring(&module_name, 0, 13) == "v1.compiler.".to_string())); + && (v1_rt::substring(&module_name, 0, 13).as_str() + == "v1.compiler.".to_string().as_str())); (is_v4 || is_compiler_substrate) } } @@ -1191,11 +1204,13 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (formal_name.clone() != "".to_string())) - && (actual_name.clone() != "".to_string())) - && (formal_name.clone() != actual_name.clone())) + && (formal_name.clone().as_str() != "".to_string().as_str())) + && (actual_name.clone().as_str() != "".to_string().as_str())) + && (formal_name.clone().as_str() != actual_name.clone().as_str())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) - == structural_carrier_template_name(actual.clone(), source_indices.clone()))) + .as_str() + == structural_carrier_template_name(actual.clone(), source_indices.clone()) + .as_str())) && !is_declared_container_alias_spelling(formal_name.clone())) && !is_declared_container_alias_spelling(actual_name.clone())) } @@ -1210,8 +1225,8 @@ pub fn container_element_nominal_brand_mismatch( ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), formal.clone()) - == authored_name_at(source_indices.clone(), actual.clone()))) + && (authored_name_at(source_indices.clone(), formal.clone()).as_str() + == authored_name_at(source_indices.clone(), actual.clone()).as_str())) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1342,7 +1357,8 @@ pub fn infer_tier2b_builtin_with_kernel_diags( scope: Rc, span: Rc, ) -> Rc { - if ((func_name.clone() == "lookup".to_string()) || (func_name.clone() == "map_get".to_string())) + if ((func_name.clone().as_str() == "lookup".to_string().as_str()) + || (func_name.clone().as_str() == "map_get".to_string().as_str())) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1358,7 +1374,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (func_name.clone() == "lookup".to_string()) { + if (func_name.clone().as_str() == "lookup".to_string().as_str()) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1374,7 +1390,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (func_name.clone() == "map_keys".to_string()) { + if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1411,7 +1427,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (func_name.clone() == "map_values".to_string()) { + if (func_name.clone().as_str() == "map_values".to_string().as_str()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1449,13 +1465,14 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((func_name.clone() == "set_insert".to_string()) - || (func_name.clone() == "set_union".to_string())) - || (func_name.clone() == "set_contains".to_string())) + if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) + || (func_name.clone().as_str() == "set_union".to_string().as_str())) + || (func_name.clone().as_str() == "set_contains".to_string().as_str())) { { - let operand_elem = if ((func_name.clone() == "set_insert".to_string()) - || (func_name.clone() == "set_contains".to_string())) + let operand_elem = if ((func_name.clone().as_str() + == "set_insert".to_string().as_str()) + || (func_name.clone().as_str() == "set_contains".to_string().as_str())) { match typed_args.clone().get(1 as usize).cloned() { Some(insert_arg) => match arg_value(insert_arg.clone()) @@ -1499,17 +1516,18 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - 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(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + let union_other_bad = + if (func_name.clone().as_str() == "set_union".to_string().as_str()) { + match typed_args.clone().get(1 as usize).cloned() { + Some(other_arg) => set_union_other_operand_is_resolved_non_set( + other_arg.clone(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1572,7 +1590,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (func_name.clone() == "set_contains".to_string()) { + let result_bt = if (func_name.clone().as_str() + == "set_contains".to_string().as_str()) + { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1615,7 +1635,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (func_name.clone() == "set_contains".to_string()) { + let build_diags = if (func_name.clone().as_str() + == "set_contains".to_string().as_str()) + { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1667,7 +1689,7 @@ pub fn method_pipe_map_keys_values_fallback( scope: Rc, span: Rc, ) -> Rc { - if (method_name.clone() == "map_keys".to_string()) { + if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { 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()); @@ -1682,7 +1704,7 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (method_name.clone() == "map_values".to_string()) { + if (method_name.clone().as_str() == "map_values".to_string().as_str()) { 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()); @@ -1730,7 +1752,7 @@ pub fn validate_cast( match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (source_name.clone() == target_name.clone()) { + if (source_name.clone().as_str() == target_name.clone().as_str()) { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1858,18 +1880,23 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (scrutinee_name.clone() != "Optional".to_string())); - let optional_coproduct_subject = ((scrutinee_name.clone() - == "Optional".to_string()) - && ((variant_name.clone() == "Present".to_string()) - || (variant_name.clone() == "Absent".to_string()))); + && (scrutinee_name.clone().as_str() + != "Optional".to_string().as_str())); + let optional_coproduct_subject = ((scrutinee_name.clone().as_str() + == "Optional".to_string().as_str()) + && ((variant_name.clone().as_str() == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((variant_name.clone() == "Holds".to_string()) - || (variant_name.clone() == "Violates".to_string()))); + && ((variant_name.clone().as_str() + == "Holds".to_string().as_str()) + || (variant_name.clone().as_str() + == "Violates".to_string().as_str()))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((variant_name.clone() == "Present".to_string()) - || (variant_name.clone() == "Absent".to_string()))) + && ((variant_name.clone().as_str() == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))) { Some("Optional".to_string()) } else { @@ -2114,7 +2141,7 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (scrut_type_name.clone() == "".to_string()) { + if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2123,8 +2150,8 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.variant_name.clone() == variant_name.clone()) - && (f.field_name.clone() == field_name.clone())) + if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) + && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } @@ -2252,7 +2279,7 @@ pub fn method_name_is(opt: Option, expected: String) -> bool { if (opt.clone() == None) { false } else { - (opt.clone().unwrap() == expected) + (opt.clone().unwrap().as_str() == expected.as_str()) } } @@ -2266,7 +2293,7 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (n.clone().unwrap() == name) + (n.clone().unwrap().as_str() == name.as_str()) } } } @@ -2340,7 +2367,9 @@ pub fn derive_element_provenance( if (authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - ) == "".to_string()) + ) + .as_str() + == "".to_string().as_str()) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2748,18 +2777,11 @@ pub fn infer_expr( ); match field_type_lookup { Some(field_type) => { - let field_summary = match field_summary_for_type( + let field_summary = field_summary_for_type( base_rt.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(), - field_name.clone(), - ), - }; + ); let fa_texpr = make_named_expr_node( field_name.clone(), Rc::new(ExprData::ExprFieldAccess { @@ -3403,7 +3425,7 @@ pub fn infer_expr( }) } } else { - if (func_name.clone() == "empty_map".to_string()) { + if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3467,7 +3489,8 @@ match bare_m { } } } else { - if (func_name.clone() == "empty_set".to_string()) { + if (func_name.clone().as_str() == "empty_set".to_string().as_str()) + { { let bare_s = bare_set_node(); match expected.clone() { @@ -3540,12 +3563,13 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = - if (func_name.clone() == "lookup".to_string()) { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = if (func_name.clone().as_str() + == "lookup".to_string().as_str()) + { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4276,7 +4300,9 @@ match bare_s { (authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - ) == let_name.clone()) + ) + .as_str() + == let_name.clone().as_str()) } _ => false, }, @@ -5280,7 +5306,7 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (pn.clone() == fname.clone()) { + if (pn.clone().as_str() == fname.clone().as_str()) { __found = true; break; } @@ -5354,7 +5380,7 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone() == "".to_string())) + let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5482,8 +5508,8 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((type_name.clone().unwrap() == "Present".to_string()) + let is_present_ctor = ((type_name.clone().unwrap().as_str() + == "Present".to_string().as_str()) && (local_variant_parent.clone().as_deref() == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { @@ -5818,7 +5848,9 @@ pub fn infer_record_lit( if (field_init_node_name_at( fir.typed_field.clone(), scope.type_env.clone().source_indices.clone(), - ) == "value".to_string()) + ) + .as_str() + == "value".to_string().as_str()) { __result.push(fir); } @@ -5910,7 +5942,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()); - if (mname == "count".to_string()) { + if (mname.as_str() == "count".to_string().as_str()) { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6007,7 +6039,7 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone() == param_name.clone()) { + if (p.clone().as_str() == param_name.clone().as_str()) { match (*lit_expr.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { @@ -6063,7 +6095,9 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { + if ((mname.clone().as_str() == "take".to_string().as_str()) + || (mname.clone().as_str() == "skip".to_string().as_str())) + { { let receiver = method_receiver(arg_expr.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6074,7 +6108,7 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (rname == param_name.clone()) { + if (rname.as_str() == param_name.clone().as_str()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { @@ -6088,7 +6122,8 @@ pub fn classify_collection_shrink( unreachable!() }; if ((k.clone() > 0) - && (mname.clone() == "skip".to_string())) + && (mname.clone().as_str() + == "skip".to_string().as_str())) { match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { @@ -6131,7 +6166,9 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p.clone() == param_name.clone()) { + if (p.clone().as_str() + == param_name.clone().as_str()) + { match proportional_divisor_from_int_at_least_two(d.clone()) { Some(div_w) => { let synth_field = Rc::new(InductiveField { @@ -6162,7 +6199,8 @@ Rc::new(SubValueRelation::StrictSubValue { ExprData::ExprBinOp { op, .. } => { match op.clone() { BinOp::Add => { - if (mname.clone() == "skip".to_string()) + if (mname.clone().as_str() + == "skip".to_string().as_str()) { { let left = @@ -6283,15 +6321,16 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (lookup_type.clone() != "".to_string()) { + if (lookup_type.clone().as_str() != "".to_string().as_str()) { { 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() { - if ((f.field_name.clone() == field_label.clone()) - && ((f.variant_name.clone() == vname.clone()) - || (f.variant_name.clone() == "".to_string()))) + if ((f.field_name.clone().as_str() == field_label.clone().as_str()) + && ((f.variant_name.clone().as_str() == vname.clone().as_str()) + || (f.variant_name.clone().as_str() + == "".to_string().as_str()))) { __result.push(f); } @@ -6483,7 +6522,7 @@ pub fn resolve_collection_field( } } }; - if (base_type.clone() != "".to_string()) { + if (base_type.clone().as_str() != "".to_string().as_str()) { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6495,7 +6534,8 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (f.field_name.clone() == fname.clone()) { + if (f.field_name.clone().as_str() == fname.clone().as_str()) + { __result.push(f); } } @@ -6566,12 +6606,12 @@ pub fn resolve_collection_field( } => { 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())); + let is_collection_preserving = (((((inner_mname.clone().as_str() + == "enumerate".to_string().as_str()) + || (inner_mname.clone().as_str() == "skip".to_string().as_str())) + || (inner_mname.clone().as_str() == "take".to_string().as_str())) + || (inner_mname.clone().as_str() == "filter".to_string().as_str())) + || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); if is_collection_preserving { { let __tco_0 = method_receiver(expr); @@ -6625,7 +6665,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (type_name.clone() != "".to_string()) { + if (type_name.clone().as_str() != "".to_string().as_str()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6705,7 +6745,9 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option "".to_string(), }, }; - if (inner_type.clone() != "".to_string()) { + if (inner_type.clone().as_str() + != "".to_string().as_str()) + { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6848,7 +6892,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if ((elem.clone() != "".to_string()) + if ((elem.clone().as_str() != "".to_string().as_str()) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -6993,7 +7037,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if (left_name.clone() != "".to_string()) { + if (left_name.clone().as_str() != "".to_string().as_str()) { match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -7035,12 +7079,12 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - if (mname.clone() == "skip".to_string()) { + if (mname.clone().as_str() == "skip".to_string().as_str()) { { let skip_args = method_arg_nodes(val.clone()); let skip_amount = match skip_args.first().cloned() { @@ -7253,7 +7297,7 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (vname.clone() == param_name.clone()) { + if (vname.clone().as_str() == param_name.clone().as_str()) { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7299,7 +7343,7 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone() == field.clone()) { + if (f.field_name.clone().as_str() == field.clone().as_str()) { __result.push(f); } } @@ -7443,7 +7487,9 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) == param_name.clone()) + ) + .as_str() + == param_name.clone().as_str()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7487,7 +7533,9 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) == param_name.clone()) + ) + .as_str() + == param_name.clone().as_str()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7505,7 +7553,9 @@ pub fn classify_argument( ((expr_var_name_at( inner_left.clone(), ctx.type_env.clone().source_indices.clone(), - ) == param_name.clone()) + ) + .as_str() + == param_name.clone().as_str()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7647,7 +7697,8 @@ pub fn read_arg_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone() == field.clone()) { + if (f.field_name.clone().as_str() == field.clone().as_str()) + { __result.push(f); } } @@ -7787,7 +7838,7 @@ pub fn build_call_evidence( } pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { - if (found.clone() != "".to_string()) { + if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -7834,7 +7885,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let arg_val = arg_value(child.clone()); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLambda => { - if (source_type.clone() != "".to_string()) { + if (source_type.clone().as_str() != "".to_string().as_str()) { { let lparams = lambda_param_names_at( arg_val.clone(), @@ -7851,7 +7902,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }; let lambda_ctx = Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (p2.clone() != "".to_string()) { + param_names: if (p2.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.param_names.clone(), @@ -7862,7 +7915,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { source_type.clone(), ) } else { - if (p1.clone() != "".to_string()) { + if (p1.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( ctx.param_names.clone(), p1.clone(), @@ -7874,7 +7929,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: if (p1.clone() != "".to_string()) { + sub_value_vars: if (p1.clone().as_str() + != "".to_string().as_str()) + { { let source_fields = inductive_fields_for( ctx.type_env.clone(), @@ -7902,7 +7959,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }), None => Rc::new(SubValueRelation::PreservedValue), }; - if (p2.clone() != "".to_string()) { + if (p2.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), @@ -8041,7 +8100,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Some(t) => t.clone(), None => "".to_string(), }; - if (base_type.clone() != "".to_string()) { + if (base_type.clone().as_str() != "".to_string().as_str()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), @@ -8050,7 +8109,9 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { - if (f.field_name.clone() == fname.clone()) { + if (f.field_name.clone().as_str() + == fname.clone().as_str()) + { __result.push(f); } } @@ -8074,8 +8135,8 @@ 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.clone() == "last".to_string())) + if ((mname.clone().as_str() == "first".to_string().as_str()) + || (mname.clone().as_str() == "last".to_string().as_str())) { { let receiver = method_receiver(scrut.clone()); @@ -8087,7 +8148,8 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } _ => None, }; - let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) + let scrut_has_inductive = (((scrut_type.clone().as_str() + != "".to_string().as_str()) && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) @@ -8128,7 +8190,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (vname.clone() == "Present".to_string()) { + Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8152,9 +8214,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == inner_vname.clone()) && (f.field_name.clone() == inner_field_name.clone())) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (inner_bind_name.clone() != "".to_string()) { + Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { 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()), @@ -8189,9 +8251,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == vname.clone()) && (f.field_name.clone() == field_name.clone())) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (bind_name.clone() != "".to_string()) { + Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8214,7 +8276,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone() != "".to_string()) { + MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8307,7 +8369,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (sub_type.clone() != "".to_string()) { + param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8424,7 +8486,9 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (sub_type.clone() != "".to_string()) { + param_names: if (sub_type.clone().as_str() + != "".to_string().as_str()) + { v1_rt::rc_map_insert( acc.ctx.clone().param_names.clone(), bname.clone(), @@ -8528,7 +8592,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (inner_mname == "enumerate".to_string()) { + if (inner_mname.as_str() == "enumerate".to_string().as_str()) { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8574,7 +8638,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota None => "".to_string(), }, }; - if (base_type.clone() != "".to_string()) { + if (base_type.clone().as_str() != "".to_string().as_str()) { Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( @@ -8584,7 +8648,9 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .iter() .cloned() { - if (f.field_name.clone() == fname.clone()) { + if (f.field_name.clone().as_str() + == fname.clone().as_str()) + { __result.push(f); } } @@ -8888,7 +8954,9 @@ pub fn infer_output_provenance( |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone() != "".to_string()) && (ptype.clone() != "".to_string())) { + if ((pname.clone().as_str() != "".to_string().as_str()) + && (ptype.clone().as_str() != "".to_string().as_str())) + { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { acc.clone() @@ -8954,7 +9022,7 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (pn.clone() == vname.clone()) { + if (pn.clone().as_str() == vname.clone().as_str()) { __found = true; break; } @@ -9003,7 +9071,7 @@ pub fn classify_body_provenance( } _ => "".to_string(), }; - if (type_for_lookup.clone() != "".to_string()) { + if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { { let fields = inductive_fields_for( type_env.clone(), @@ -9012,7 +9080,9 @@ pub fn classify_body_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { - if (f.field_name.clone() == field.clone()) { + if (f.field_name.clone().as_str() + == field.clone().as_str()) + { __result.push(f); } } @@ -9168,7 +9238,7 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((bind_name.clone() != "".to_string()) && (field_label.clone() != "".to_string())) { +if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { { let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) @@ -9356,7 +9426,7 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (first_pname.clone() != "".to_string()) { + if (first_pname.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), first_pname.clone(), @@ -9768,8 +9838,8 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((bind_name.clone() == "".to_string()) - || (field_label.clone() == "".to_string())) + if ((bind_name.clone().as_str() == "".to_string().as_str()) + || (field_label.clone().as_str() == "".to_string().as_str())) { c.clone() } else { @@ -9927,8 +9997,8 @@ pub fn compute_variant_provenance( param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone() != "".to_string()) - && (ptype.clone() != "".to_string())) + if ((pname.clone().as_str() != "".to_string().as_str()) + && (ptype.clone().as_str() != "".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -9979,7 +10049,7 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (enum_name.clone() == parent_enum.clone()) { + if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10003,7 +10073,7 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (fname.clone() != "".to_string()) { + if (fname.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -10040,7 +10110,9 @@ pub fn collect_variant_constructors( if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) == parent_enum.clone()) + ) + .as_str() + == parent_enum.clone().as_str()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10324,8 +10396,8 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((ptype.clone() != "".to_string()) - && (pname.clone() != "".to_string())) + if ((ptype.clone().as_str() != "".to_string().as_str()) + && (pname.clone().as_str() != "".to_string().as_str())) { { let fields = inductive_fields_for( @@ -10617,7 +10689,9 @@ pub fn infer_auth_source_properties( if (field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) == "svc_auth_source".to_string()) + ) + .as_str() + == "svc_auth_source".to_string().as_str()) { { let val = field_init_node_value(p.clone()); @@ -11041,10 +11115,11 @@ pub fn infer_items( } pub fn is_type_variable_name(name: String) -> bool { - (((((name.clone() == "T".to_string()) || (name.clone() == "K".to_string())) - || (name.clone() == "V".to_string())) - || (name.clone() == "MappedElement".to_string())) - || (name.clone() == "FoldAccumulator".to_string())) + (((((name.clone().as_str() == "T".to_string().as_str()) + || (name.clone().as_str() == "K".to_string().as_str())) + || (name.clone().as_str() == "V".to_string().as_str())) + || (name.clone().as_str() == "MappedElement".to_string().as_str())) + || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -11059,7 +11134,7 @@ pub fn type_node_label( ) -> String { { let authored = authored_name_at(source_indices, n.clone()); - if (authored.clone() != "".to_string()) { + if (authored.clone().as_str() != "".to_string().as_str()) { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11084,9 +11159,9 @@ pub fn param_is_generic_decl( }; (((((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().as_str() != "".to_string().as_str())) + && ((pname.clone().as_str() == tname.as_str()) + || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) } } @@ -11109,7 +11184,7 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone() == bind_name.clone()) { + if (g.clone().as_str() == bind_name.clone().as_str()) { __found = true; break; } @@ -11168,9 +11243,9 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); 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.clone().as_str() != "".to_string().as_str()) + && (record_name.clone().as_str() != "".to_string().as_str())) + && (formal_name.clone().as_str() == record_name.clone().as_str())) } } } @@ -11195,7 +11270,9 @@ pub fn unify_record_lit_field_walk( if (field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - ) == field_name.clone()) + ) + .as_str() + == field_name.clone().as_str()) { __result.push(fi); } @@ -11250,7 +11327,7 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone() == formal_name.clone()) { + if (g.clone().as_str() == formal_name.clone().as_str()) { __found = true; break; } @@ -11272,8 +11349,8 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((record_type_name.clone() != "".to_string()) - && (formal_name.clone() == record_type_name.clone())) + if ((record_type_name.clone().as_str() != "".to_string().as_str()) + && (formal_name.clone().as_str() == record_type_name.clone().as_str())) { unify_record_lit_field_walk( record_lit_expected_fields( @@ -11746,6 +11823,9 @@ pub fn build_type_env( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); + // §3 single-authority: no implicit std.types base-injection. Resolution + // flows through each module's explicit import graph only (mirrors + // v1.compiler.infer build_type_env in src/v1/04_infer.dag). let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); @@ -11768,7 +11848,7 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone() == "std.types".to_string()) { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12340,7 +12420,8 @@ 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()); + // §3 single-authority: no implicit std.types base-injection (mirrors + // build_type_env_unresolved in src/v1/04_infer.dag). let parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12362,7 +12443,7 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone() == "std.types".to_string()) { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -13276,8 +13357,8 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (dep.clone() == "None".to_string())) - || (dep.clone() == "".to_string())) + || (dep.clone().as_str() == "None".to_string().as_str())) + || (dep.clone().as_str() == "".to_string().as_str())) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13490,7 +13571,9 @@ 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.clone(), source_indices).as_str() == "0".to_string().as_str()) + } None => false, }) } @@ -13617,40 +13700,6 @@ pub fn build_positional_payload_variants( ) } -pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { - { - let has_seed = { - let mut __found = false; - 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() - { - if (v1_rt::contains(k.clone(), "/v1/".to_string()) - || v1_rt::contains(k.clone(), "src/v1".to_string())) - { - __found = true; - break; - } - } - __found - } { - __found = true; - break; - } - } - __found - }; - if has_seed { - RustCorpusRepr::HostNative - } else { - RustCorpusRepr::FaithfulFreeMonoid - } - } -} - pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { @@ -13707,7 +13756,6 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), - corpus_repr: rust_corpus_repr(modules.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 5aa8cda70bb..98745ada53b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -1,7 +1,6 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.infer_emit_info -use self::RustCorpusRepr::*; use self::TypeRepr::*; pub use crate::v1_compiler_infer_types::{ child_type_node, emit_map_has, node_type_equals, normalize_access_type_node, @@ -63,15 +62,6 @@ pub struct TypeSummary { pub has_fn_fields: bool, } -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] -#[serde(tag = "_variant")] -pub enum RustCorpusRepr { - HostNative, - FaithfulFreeMonoid, -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EmitGraphInfo { pub type_summaries: Rc>>, @@ -85,7 +75,6 @@ pub struct EmitGraphInfo { pub owned_bindings: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, - pub corpus_repr: RustCorpusRepr, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -107,7 +96,6 @@ pub fn empty_emit_graph_info() -> Rc { read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), - corpus_repr: RustCorpusRepr::FaithfulFreeMonoid, }) } @@ -465,8 +453,9 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((resolved_name.clone() != "".to_string()) && !ft_is_type_var.clone()) - && (resolved_name.clone() != "Dynamic".to_string())) + if (((resolved_name.clone().as_str() != "".to_string().as_str()) + && !ft_is_type_var.clone()) + && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -632,6 +621,3 @@ pub fn add_emit_item_summary( None => state, } } - -pub struct HostNative; -pub struct FaithfulFreeMonoid; From e6d38e6d36857703a68a30454ca942c766b71067 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 05:45:49 +0000 Subject: [PATCH 39/61] =?UTF-8?q?class-3=20review=20fix:=20correct=20?= =?UTF-8?q?=C2=A76=20dissolution-direction=20comment=20(src/v1=20deleted?= =?UTF-8?q?=20=E2=86=92=20FaithfulFreeMonoid,=20not=20HostNative)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit quick-seal by-execution review: 05_emit_rust.dag:221 stated the dissolution collapse backwards. src/v1 deleted → no seed → has_seed=false → FaithfulFreeMonoid (the pure-v2 faithful target), matching 04_infer.dag:6395 and the §6 ruling. Comment-only; the code (04_infer.dag else-branch) was already correct. Co-Authored-By: Claude Opus 4.8 --- src/v1/05_emit_rust.dag | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index c27f9083c3d..6e5a9a4a711 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -218,7 +218,8 @@ fn rust_type_is_rc_wrapped(type_name: String) -> Bool { // The old per-module gates (rust_corpus_includes_v1_compiler / rust_emit_faithful_text_carrier) // were deleted: a per-module gate let a dsl module in a v1-bundled crate emit the faithful // carrier while its siblings emit host — divergence was WRITABLE (a §5 dual-authority breach). -// §6-transitional: corpus_repr collapses to HostNative when src/v1 is deleted (seed→zero). +// §6-transitional: when src/v1 is deleted (seed→zero) no module has_seed, so corpus_repr +// resolves uniformly to FaithfulFreeMonoid — the pure-v2 faithful target; HostNative dissolves with the seed. // Shape-reading predicates over the single corpus_repr authority (match, not `==`: // a bare-variant `==` adjacent to a block `{` collides with record-literal syntax). fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> Bool { From 3b28498eb4a9153bc58af74c6cbd9b8e4d653f5f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 06:43:50 +0000 Subject: [PATCH 40/61] =?UTF-8?q?PATH=20A=20=E2=80=94=20land=20class-3-emb?= =?UTF-8?q?odying=20cargo-green=20seed=20via=20overlay-3-committed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HAND-SYNCED MIRROR, not a regen fixpoint. Splice the three class-3 emitter files (v1_compiler_emit_rust.rs, v1_compiler_infer.rs, v1_compiler_infer_emit_info.rs) from a faithful regen of the class-3 .dag onto the committed seed; every other module stays byte-identical to committed. Two local drifts hand-resolved: - cargo header inlined in emit_rust so it does not import the deliberately-unwired extdeps_cargo_version orphan (byte-identical to committed emit); - wire policy passed by value (Rc clone) at wire_value_serialize.rs to match the class-3 by-value policy_* signatures. The std-tower orphans (std_measure / std_algebra / std_realization_schedule / std_machine_constraints / std_integer / extdeps_version_semver / extdeps_cargo_version) stay UNWIRED exactly as on main. A faithful full regen would wire them and surface the deferred ~150-gap emitter-completeness lane (regen-fixpoint emitter-self-host); that lane is NOT closed here and `regen_stage0 --verify` is expected to differ. Carrier mark recorded in regen_stage0.rs + the 3 spliced file headers (self-contained; breadcrumb node://adhoc-80af9ff8-40f). Validated in scratch: cargo build -p v1-compiler --release --features text_lookup_work_counter --bins = 0 errors / 0 warnings (all 5 bins); cargo fmt --all --check clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/v1/stage0/src/bin/regen_stage0.rs | 29 + src/v1/stage0/src/v1_compiler_emit_rust.rs | 3712 ++++++++++------- src/v1/stage0/src/v1_compiler_infer.rs | 520 ++- .../stage0/src/v1_compiler_infer_emit_info.rs | 40 +- src/v1/stage0/src/wire_value_serialize.rs | 11 +- 5 files changed, 2517 insertions(+), 1795 deletions(-) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 94bb0e23bea..98b4dd55282 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -109,6 +109,35 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "v1_std_core.rs", ]; +// ========================================================================= +// CARRIER MARK -- HAND-SYNCED MIRROR, NOT a regen fixpoint (class-3 splice). +// +// The committed stage0 seed is a HAND-SYNCED MIRROR of the .dag authority, NOT a +// clean-regen fixpoint. `regen_stage0 --verify` is therefore EXPECTED to differ +// from the committed seed today: a faithful full regen wires every emitted module, +// including the std-tower modules that are DELIBERATELY UNWIRED in lib.rs here +// (std_measure / std_algebra / std_realization_schedule / std_machine_constraints +// / std_integer / extdeps_version_semver / extdeps_cargo_version), and that wiring +// surfaces ~150 latent emitter-completeness gaps (std numeric/measure-tower generic +// emission). Those modules stay UNWIRED here exactly as on main. +// +// The class-3 emitter mirror (v1_compiler_emit_rust.rs / v1_compiler_infer.rs / +// v1_compiler_infer_emit_info.rs) was landed by overlay-3-committed: faithful regen +// of the class-3 .dag for those three modules, spliced onto the committed seed, +// with two local drifts hand-resolved (cargo header inlined to avoid importing the +// unwired extdeps_cargo_version orphan; wire policy passed by value, Rc clone, at +// wire_value_serialize.rs). Every other module is byte-identical to committed. +// +// LANE (deferred): regen-fixpoint emitter-self-host (~150-gap) -- wire-all-emitted- +// modules so a clean regen reproduces the committed seed bit-identically (the §7 +// reproduce-fixpoint that licenses deleting src/v1). +// PROVENANCE (#5514 verbatim deferral): "regen-write still emits a non-building seed +// from ~150 emitter-completeness gaps, the clean green regen fixpoint is deferred, +// converges with the Route-A emitter self-host". +// DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host -- +// when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh +// work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// ========================================================================= const HAND_MAINTAINED_STAGE0_FILES: &[&str] = &[ "cache_purity_oracle.rs", "cli_run.rs", diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 5aaf143fb95..a440313ddf5 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -1,5 +1,28 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.emit_rust +// +// HAND-SYNCED MIRROR (class-3 splice) -- this committed seed is a HAND-SYNCED +// MIRROR of the .dag authority, NOT a regen fixpoint. This file is one of three +// (with v1_compiler_infer.rs, v1_compiler_infer_emit_info.rs) spliced from a +// faithful regen of the class-3 .dag onto the committed seed, with two local +// drifts hand-resolved (cargo header inlined below so it does not import the +// deliberately-unwired extdeps_cargo_version orphan; policy ref/value alignment +// at wire_value_serialize.rs). The other modules stay byte-identical to committed. +// +// LANE (deferred): regen-fixpoint emitter-self-host (~150-gap) -- wire-all-emitted- +// modules so a clean regen reproduces this committed seed bit-identically (the +// §7 reproduce-fixpoint that licenses deleting src/v1). +// SCOPE: a faithful full regen wires the deliberately-unwired orphan std modules +// (std_measure / std_algebra / std_realization_schedule / std_machine_constraints +// / std_integer / extdeps_version_semver / extdeps_cargo_version) and surfaces +// ~150 latent emitter-completeness gaps (std numeric/measure-tower generic +// emission). They stay UNWIRED here exactly as on main. +// PROVENANCE (#5514 verbatim deferral): "regen-write still emits a non-building +// seed from ~150 emitter-completeness gaps, the clean green regen fixpoint is +// deferred, converges with the Route-A emitter self-host". +// DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host +// -- when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh +// work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) pub use crate::extdeps_languages_rust_emit::HigherOrderMethodSpec; pub use crate::extdeps_languages_rust_emit::{ @@ -8,8 +31,8 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_templates, rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_struct_derives, rust_struct_derives_copy, }; -pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::SubValueUnknown; +pub use crate::std_induction::{InductiveField, SubValueRelation}; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{is_container_type, is_kernel_type}; @@ -45,19 +68,25 @@ pub use crate::v1_compiler_emit_core_support::{ pub use crate::v1_compiler_emit_core_support::{EmitResult, TestProjection}; pub use crate::v1_compiler_infer::InferScope; pub use crate::v1_compiler_infer::{ - build_emit_graph_info, build_params_scope, expr_span, extend_scope, resolved_type_name, + build_emit_graph_info, build_params_scope, expand_type_for_field_access, expr_span, + extend_scope, resolved_type_name, }; +use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ find_variant_parent, is_enum_in_summaries, is_known_variant, lookup_emit_type_summary, variant_belongs_to_enum, variant_summary_key, }; -pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; +pub use crate::v1_compiler_infer_emit_info::{ + EmitGraphInfo, RustCorpusRepr, TypeRepr, TypeSummary, +}; pub use crate::v1_compiler_infer_env::{authored_name, lookup_type_by_name, lookup_type_for}; pub use crate::v1_compiler_infer_env::{TypeBinding, TypeEnv}; use crate::v1_compiler_infer_items::ItemKind::{DataItem, OtherItem, TypeItem}; pub use crate::v1_compiler_infer_items::{ItemInfo, ItemKind, ResolvedGraph, TypedModule}; -pub use crate::v1_compiler_infer_resolve::lookup_unit_variant_phantom_type; +pub use crate::v1_compiler_infer_resolve::{ + is_width_nat_type_literal, lookup_unit_variant_phantom_type, +}; pub use crate::v1_compiler_infer_service::{ extract_typed_service_name, is_typed_service_call_receiver, }; @@ -83,7 +112,6 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -112,16 +140,16 @@ use crate::v1_std_core::VarBindingKind::{ }; pub use crate::v1_std_core::{ arg_name_at, arg_value, arm_body, arm_guard, arm_pattern, authored_name_at, binop_left, - binop_right, cast_expr, cast_target, expr_call_func_at, expr_has_non_tail_self_call, - expr_has_self_call, expr_method_name_at, expr_var_name_at, field_access_base, - 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, - find_property, foreach_body, foreach_collection, foreach_variable_at, generic_param_name_at, - if_condition, if_else_branch, if_then_branch, import_is_all, import_specific_names_at, - index_base, index_expr, is_compiler_error, is_file_transport, is_rest_transport, - is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, let_body, - let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, make_span, - match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, + binop_right, cast_expr, cast_target, empty_intern_table, expr_call_func_at, + expr_has_non_tail_self_call, expr_has_self_call, expr_method_name_at, expr_var_name_at, + field_access_base, 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, find_property, foreach_body, foreach_collection, foreach_variable_at, + generic_param_name_at, if_condition, if_else_branch, if_then_branch, import_is_all, + import_specific_names_at, index_base, index_expr, is_compiler_error, is_file_transport, + is_rest_transport, is_shell_transport, lambda_body, lambda_param_names_at, let_binding_name_at, + let_body, let_value, make_arg_node, make_error_node, make_expr_node, make_named_expr_node, + make_span, match_arm_nodes, match_scrutinee, method_arg_nodes, method_receiver, module_imports, module_items, param_node_default_value, param_node_name_at, param_node_type_expr, record_lit_type_name_at, resource_use_name_at, resource_use_resource, return_value, service_config_auth, service_config_auth_input, service_config_auth_source, @@ -144,6 +172,7 @@ use std::rc::Rc; pub fn render_rust_type( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match n.inferred.clone().as_deref().cloned() { @@ -159,12 +188,26 @@ pub fn render_rust_type( applied.clone(), Rc::new(vec![]), shared_types, + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { render_rust_type_without_applied_binding( n.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -172,6 +215,7 @@ pub fn render_rust_type( None => render_rust_type_without_applied_binding( n.clone(), shared_types, + corpus_repr, source_indices.clone(), ), }, @@ -181,6 +225,7 @@ pub fn render_rust_type( pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if (((n.connective.clone() == Connective::NoConnective) @@ -191,7 +236,17 @@ pub fn render_rust_type_without_applied_binding( n.clone(), Rc::new(vec![]), shared_types, + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::>>>(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -231,19 +286,20 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { - let tn = authored_name_at(source_indices.clone(), n.clone()); - if (tn.clone().as_str() == "String".to_string().as_str() - && ((n.children.clone().len() as i64) == 0) - && rust_emit_faithful_text_carrier(source_indices.clone())) { - render_rust_text_carrier(shared_types.clone()) - } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) + let tn = authored_name_at(source_indices.clone(), n.clone()); + if (((tn == "String".to_string()) && ((n.children.clone().len() as i64) == 0)) + && corpus_repr_is_faithful(corpus_repr)) + { + render_rust_text_carrier(shared_types) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) + } } } } @@ -255,22 +311,21 @@ pub fn empty_string_bool_map() -> Rc> { pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { ((v1_rt::string_length(&type_name) >= 3) - && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) + && (v1_rt::substring(&type_name, 0, 3) == "Rc<".to_string())) } -pub fn rust_corpus_includes_v1_compiler( - source_indices: Rc>>, -) -> bool { - v1_rt::map_keys(&source_indices) - .iter() - .cloned() - .any(|k| k.contains("/v1/") || k.contains("src/v1")) +pub fn corpus_repr_is_faithful(corpus_repr: RustCorpusRepr) -> bool { + match corpus_repr { + RustCorpusRepr::FaithfulFreeMonoid => true, + RustCorpusRepr::HostNative => false, + } } -pub fn rust_emit_faithful_text_carrier( - source_indices: Rc>>, -) -> bool { - !rust_corpus_includes_v1_compiler(source_indices) +pub fn corpus_repr_is_host(corpus_repr: RustCorpusRepr) -> bool { + match corpus_repr { + RustCorpusRepr::HostNative => true, + RustCorpusRepr::FaithfulFreeMonoid => false, + } } pub fn render_rust_text_carrier(shared_types: Rc>) -> String { @@ -283,9 +338,9 @@ pub fn render_rust_text_carrier(shared_types: Rc>>, + corpus_repr: RustCorpusRepr, ) -> String { - if rust_emit_faithful_text_carrier(source_indices) { + if corpus_repr_is_faithful(corpus_repr) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), @@ -300,9 +355,9 @@ pub fn emit_rust_host_to_dag_string_via_seam( pub fn emit_rust_dag_string_to_host_via_seam( dag_expr: String, - source_indices: Rc>>, + corpus_repr: RustCorpusRepr, ) -> String { - if rust_emit_faithful_text_carrier(source_indices) { + if corpus_repr_is_faithful(corpus_repr) { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), @@ -316,57 +371,52 @@ pub fn emit_rust_dag_string_to_host_via_seam( } pub fn rust_host_string_seam_fn_emit(name: String) -> Option { - if name.as_str() == "host_string_text_from_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), - " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), - ), - "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), - ), - "}\n".to_string(), - )) - } else if name.as_str() == "host_string_text_to_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), - " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), - ), - "}\n".to_string(), - ), - "".to_string(), - )) + if (name.clone() == "host_string_text_from_rust_host".to_string()) { + Some(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string()), "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string()), "}\n".to_string())) } else { - None + if (name.clone() == "host_string_text_to_rust_host".to_string()) { + Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) + } else { + None + } } } pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if (name.clone().as_str() == "Json".to_string().as_str()) - || (name.clone().as_str() == "Bytes".to_string().as_str()) - { + if ((name.clone() == "Json".to_string()) || (name.clone() == "Bytes".to_string())) { Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { None } } -pub fn rust_named_type_base( - name: String, - source_indices: Rc>>, -) -> String { - if ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn rust_seed_host_numeric_alias(name: String, corpus_repr: RustCorpusRepr) -> Option { + if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) + && corpus_repr_is_host(corpus_repr)) { + Some("i64".to_string()) + } else { + None + } +} + +pub fn rust_seed_host_container_base(name: String, corpus_repr: RustCorpusRepr) -> Option { + if ((name == "List".to_string()) && corpus_repr_is_host(corpus_repr)) { + Some("Vec".to_string()) + } else { + None + } +} + +pub fn rust_named_type_base(name: String, corpus_repr: RustCorpusRepr) -> String { + if ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) { "Witness".to_string() - } else if name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices) - { - "FreeMonoid".to_string() } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) + if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr)) { + "FreeMonoid".to_string() + } else { + coerce_primitive_type(RenderTarget::Rust, name.clone()) + } } } @@ -394,15 +444,112 @@ 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()), + None => false, + } +} + +pub fn is_parametric_opaque_type_base( + type_name: String, + def_mod_filename: String, + typed_modules: Rc>>, + source_indices: Rc>>, + module_index: Rc, +) -> bool { + match type_item_by_name_in_module_filename( + type_name, + def_mod_filename, + typed_modules, + source_indices.clone(), + module_index, + ) { + Some(item) => is_parametric_opaque_type_decl_item(item.clone(), source_indices.clone()), + None => false, + } +} + +pub fn render_rust_phantom_opaque_applied_type_arg( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + corpus_repr: RustCorpusRepr, + source_indices: Rc>>, + scope: Rc, + imports: Rc>>, + registry: Rc>>, + module_name: String, + export_sets: Rc>>>, + typed_modules: Rc>>, + module_index: Rc, + variant_to_enum: Rc>, +) -> String { + if is_width_nat_type_literal(n.clone()) { + "()".to_string() + } else { + render_rust_alias_rhs_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + scope, + imports, + registry, + module_name, + export_sets, + typed_modules, + module_index, + variant_to_enum, + ) + } +} + +pub fn render_rust_phantom_opaque_applied_decl_arg( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + corpus_repr: RustCorpusRepr, + source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_width_nat_type_literal(n.clone()) { + "()".to_string() + } else { + render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + variant_to_enum, + env, + ) + } +} + pub fn render_rust_applied_type_arg( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), + _ => render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + corpus_repr, + source_indices, + variant_to_enum, + env, + ), } } @@ -410,26 +557,46 @@ pub fn render_rust_applied_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { - let base = rust_named_type_base( - authored_name_at(source_indices.clone(), n.clone()), - source_indices.clone(), - ); + let base_name = authored_name_at(source_indices.clone(), n.clone()); + let base = 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()), + }; if ((n.children.clone().len() as i64) == 0) { base } else { { + 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() { - __result.push(render_rust_applied_type_arg( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - )); + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_decl_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + }); } __result }) @@ -460,14 +627,20 @@ pub fn render_rust_applied_type_shared( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { let rendered = render_rust_applied_type( n.clone(), generic_param_names, shared_types.clone(), + corpus_repr, source_indices.clone(), + variant_to_enum, + env, ); let type_name = authored_name_at(source_indices.clone(), n.clone()); render_rust_shared_type_if_needed(type_name, rendered, shared_types.clone()) @@ -478,7 +651,10 @@ pub fn render_rust_decl_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -486,8 +662,7 @@ pub fn render_rust_decl_type( "__applied_type_args".to_string(), source_indices.clone(), ); - let has_applied_prop = applied_prop.is_some(); - let applied_overlay = match applied_prop { + let applied_overlay = match applied_prop.clone() { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) @@ -502,7 +677,10 @@ pub fn render_rust_decl_type( applied.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -511,7 +689,7 @@ pub fn render_rust_decl_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (g.clone() == name.clone()) { __found = true; break; } @@ -520,67 +698,103 @@ pub fn render_rust_decl_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && v1_rt::set_contains(&shared_types, name.clone())) - { - let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), - recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }); - let rendered = rust_render_type_leaf_name( - name.clone(), - v1_rt::rc_empty_map::(), - stub_env, - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + if (((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && (name.clone() == "String".to_string())) + && corpus_repr_is_faithful(corpus_repr.clone())) { + render_rust_text_carrier(shared_types.clone()) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && v1_rt::set_contains(&shared_types, name.clone())) { - let base = rust_named_type_base(name.clone(), source_indices.clone()); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), + { + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + if (!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(), - source_indices.clone(), - )); + ) + } else { + { + let base = + rust_named_type_base(name.clone(), corpus_repr.clone()); + let peel = is_parametric_opaque_type_by_name( + env.clone(), + name.clone(), + ); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_decl_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + }); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base, "<".to_string()), + args, + ), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) + } } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - ) } } } @@ -589,53 +803,78 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - if name.clone().as_str() == "String".to_string().as_str() { - return false; - } - let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b, - None => { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b, - None => return false, - } + { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if (name.clone() == "String".to_string()) { + return false; } - }; - (binding.params.clone().len() as i64) == 0 + let binding = match lookup_type_for(env.clone(), n.clone()) { + 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()) { + Some(b) => b.clone(), + None => return false, + } + } + }; + ((binding.params.clone().len() as i64) == 0) + } } pub fn render_rust_fn_sig_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - render_rust_text_carrier(shared_types.clone()) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0) - && !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()) - } else if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) - } else { - render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (name.clone() == "String".to_string())) + && corpus_repr_is_faithful(corpus_repr.clone())) + { + render_rust_text_carrier(shared_types) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !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) + } else { + if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types, + corpus_repr.clone(), + source_indices.clone(), + variant_to_enum, + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types, + corpus_repr.clone(), + source_indices.clone(), + env.clone(), + ) + } + } + } } } pub fn render_rust_fn_sig_type_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, env: Rc, ) -> String { @@ -646,25 +885,42 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if ((((outer_name.clone() != "".to_string()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + && rust_fn_sig_peel_closed_alias(env, n.clone())) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) + } } } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) } } - None => render_rust_type_with_applied_binding(n, shared_types, source_indices), + None => render_rust_type_with_applied_binding( + n.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ), } } @@ -672,6 +928,7 @@ pub fn render_rust_alias_rhs_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, scope: Rc, imports: Rc>>, @@ -689,7 +946,7 @@ pub fn render_rust_alias_rhs_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (g.clone() == name.clone()) { __found = true; break; } @@ -698,85 +955,140 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - { - if name.clone().as_str() == "String".to_string().as_str() - && rust_emit_faithful_text_carrier(source_indices.clone()) + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) { - render_rust_text_carrier(shared_types.clone()) - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier + match rust_seed_host_numeric_alias(name.clone(), corpus_repr.clone()) { + Some(host) => host.clone(), + None => { + if ((name.clone() == "String".to_string()) + && corpus_repr_is_faithful(corpus_repr.clone())) + { + render_rust_text_carrier(shared_types.clone()) + } else { + 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(), + scope.type_env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } + } + } + } } else { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - scope.type_env.clone(), - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) - } - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { - { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = if (def_mod.clone().as_str() != local_mod.as_str()) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - }; - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - scope.clone(), + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), imports.clone(), + scope.clone(), registry.clone(), - module_name.clone(), export_sets.clone(), typed_modules.clone(), + source_indices.clone(), module_index.clone(), - variant_to_enum.clone(), - )); + ); + let base = match rust_seed_host_container_base( + name.clone(), + corpus_repr.clone(), + ) { + Some(host) => host.clone(), + None => { + if (def_mod.clone() != local_mod) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + } + } + }; + let peel = is_parametric_opaque_type_base( + name.clone(), + def_mod.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(if peel.clone() { + render_rust_phantom_opaque_applied_type_arg( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + ) + } else { + render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + ) + }); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + } else { + applied_ty.clone() + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - applied_ty.clone() + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } - } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -903,14 +1215,14 @@ pub fn rust_nominal_identity_carrier_def(name: String) -> String { } pub fn rust_nominal_identity_carrier_type_eligible(type_name: String) -> bool { - (type_name.as_str() == "Symbol".to_string().as_str()) + (type_name == "Symbol".to_string()) } pub fn rust_nominal_identity_carrier_shape_eligible( n: Rc, source_indices: Rc>>, ) -> bool { - ((((authored_name_at(source_indices, n.clone()).as_str() == "Symbol".to_string().as_str()) + ((((authored_name_at(source_indices, n.clone()) == "Symbol".to_string()) && ((n.children.clone().len() as i64) == 0)) && ((n.params.clone().len() as i64) == 0)) && (n.connective.clone() == Connective::NoConnective)) @@ -921,8 +1233,7 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( children: Rc>>, source_indices: Rc>>, ) -> bool { - if ((name.as_str() != "DiffId".to_string().as_str()) || ((children.clone().len() as i64) != 1)) - { + if ((name != "DiffId".to_string()) || ((children.clone().len() as i64) != 1)) { false } else { match children.clone().first().cloned() { @@ -956,8 +1267,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().as_str() == "Symbol".to_string().as_str()) - || (type_name.clone().as_str() == "DiffId".to_string().as_str()))) + && ((type_name.clone() == "Symbol".to_string()) + || (type_name.clone() == "DiffId".to_string()))) } } @@ -1058,9 +1369,7 @@ pub fn field_value_by_name( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at(fi.clone(), source_indices.clone()).as_str() - == field_name.clone().as_str()) - { + if (field_init_node_name_at(fi.clone(), source_indices.clone()) == field_name.clone()) { __result.push(fi); } } @@ -1130,18 +1439,16 @@ pub fn rust_string_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (naming_name.clone() == "AsAuthored".to_string()) { rust_string_as_authored_policy() } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (naming_name.clone() == "SnakeCase".to_string()) { rust_snake_string_policy() } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { rust_screaming_snake_string_policy() } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1158,9 +1465,7 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1177,35 +1482,15 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) + if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) { - 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()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + 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())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1227,7 +1512,7 @@ pub fn rust_internal_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (naming_name.clone() == "AsAuthored".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1238,7 +1523,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (naming_name.clone() == "SnakeCase".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1249,7 +1534,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1260,9 +1545,7 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "prefix".to_string(), @@ -1282,9 +1565,7 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) - { + if (naming_name.clone() == "StripSuffixAndSnakeCase".to_string()) { match required_literal_string_policy_field( naming.clone(), "suffix".to_string(), @@ -1304,41 +1585,15 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) + if (naming_name.clone() == "StripPrefixSuffixAndSnakeCase".to_string()) { - 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()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + 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())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1384,10 +1639,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ) -> Rc { { let encoding_name = authored_name_at(source_indices.clone(), ve.clone()); - if (encoding_name.clone().as_str() == "InternallyTaggedObject".to_string().as_str()) { + if (encoding_name.clone() == "InternallyTaggedObject".to_string()) { rust_internal_policy_for_encoding(ve.clone(), source_indices.clone()) } else { - if (encoding_name.clone().as_str() == "StringVariant".to_string().as_str()) { + 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()), None => rust_serde_error_policy( @@ -1395,10 +1650,10 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ), } } else { - if (encoding_name.clone().as_str() == "UntaggedVariant".to_string().as_str()) { + if (encoding_name.clone() == "UntaggedVariant".to_string()) { rust_untagged_policy() } else { - if (encoding_name.clone().as_str() == "TaggedVariant".to_string().as_str()) { + if (encoding_name.clone() == "TaggedVariant".to_string()) { rust_tagged_object_policy() } else { rust_serde_error_policy(v1_rt::concat( @@ -1428,8 +1683,7 @@ pub fn resolve_wire_serde_policy( } pub fn item_binding_is_named(env: Rc, node: Rc, name: String) -> bool { - ((authored_name(env, node.clone()).as_str() == name.clone().as_str()) - || (node.name.clone().as_str() == name.clone().as_str())) + ((authored_name(env, node.clone()) == name.clone()) || (node.name.clone() == name.clone())) } pub fn resolve_wire_serde_policy_for_coproduct( @@ -1622,7 +1876,7 @@ pub fn variant_encoding_is_string_variant( encoding: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, encoding).as_str() == "StringVariant".to_string().as_str()) + (authored_name_at(source_indices, encoding) == "StringVariant".to_string()) } pub fn coproduct_wire_contract_targets( @@ -1633,7 +1887,7 @@ pub fn coproduct_wire_contract_targets( match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { - Some(target_name) => (target_name.clone().as_str() == coproduct_name.as_str()), + Some(target_name) => (target_name.clone() == coproduct_name), None => false, } } @@ -1662,15 +1916,15 @@ pub fn module_imports_std_serialization_coproduct_wire_contract( { let mut __found = false; for imp in imports.iter().cloned() { - if ((authored_name_at(source_indices.clone(), imp.clone()).as_str() - == "std.serialization".to_string().as_str()) + if ((authored_name_at(source_indices.clone(), imp.clone()) + == "std.serialization".to_string()) && (import_is_all(imp.clone()) || { let mut __found = false; for name in import_specific_names_at(imp.clone(), source_indices.clone()) .iter() .cloned() { - if (name.clone().as_str() == "CoproductWireContract".to_string().as_str()) { + if (name.clone() == "CoproductWireContract".to_string()) { __found = true; break; } @@ -1693,8 +1947,8 @@ 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.clone()).as_str() - == "CoproductWireContract".to_string().as_str()) + ((authored_name_at(source_indices.clone(), type_node.clone()) + == "CoproductWireContract".to_string()) && module_imports_std_serialization_coproduct_wire_contract( imports, source_indices.clone(), @@ -1714,8 +1968,8 @@ pub fn module_defines_local_coproduct_wire_contract_type( if (((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), item.clone()).as_str() - == "CoproductWireContract".to_string().as_str())) + && (authored_name_at(source_indices.clone(), item.clone()) + == "CoproductWireContract".to_string())) { __found = true; break; @@ -1776,7 +2030,7 @@ pub fn emit_coproduct_wire_contract_target_validation( if { let mut __found = false; for name in local_coproduct_names.iter().cloned() { - if (name.clone().as_str() == target_name.clone().as_str()) { + if (name.clone() == target_name.clone()) { __found = true; break; } @@ -1841,7 +2095,7 @@ pub fn emit_coproduct_wire_contract_validations( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (text.clone() != "".to_string()) { __result.push(text); } } @@ -2198,19 +2452,166 @@ pub fn emit_rust_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; - remaining = __tco_0; - text = __tco_1; - scope = __tco_2; - continue; + let __tco_0 = rest.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; + continue; + } + } + } + } + } + } +} + +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + 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(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name.clone() + } else { + match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum), + } + } +} + +pub fn rust_phantom_zst_marker_def(vname: String) -> String { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]\n".to_string(), rust_visibility_prefix()), rust_items().struct_keyword.clone()), " ".to_string()), vname), ";".to_string()) +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + { + let markers = Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if ((child.children.clone().len() as i64) == 0) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + if is_phantom_unit_variant_type_arg( + env.clone(), + authored_name(env.clone(), child.clone()), + ) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + __result.push({ + let vname = authored_name(env.clone(), child.clone()); + rust_phantom_zst_marker_def(vname.clone()) + }); + } + __result + }) + .join(&"\n".to_string()); + markers + } +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (is_type_def_item(item.clone()) && { + let mut __all = true; + for c in item.children.clone().iter().cloned() { + if !((c.children.clone().len() as i64) == 0) { + __all = false; + break; + } + } + __all + }) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { + item.children.clone().iter().cloned().fold( + acc, + |inner: Rc>, child: Rc| { + if ((child.children.clone().len() as i64) == 0) { + { + let vname = authored_name(env.clone(), child.clone()); + if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !{ + let mut __found = false; + for n in inner.clone().iter().cloned() { + if (n.clone() == vname.clone()) { + __found = true; + break; + } + } + __found + }) + { + v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + } else { + inner.clone() } } + } else { + inner.clone() } - } + }, + ) + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { + __result.push(rust_phantom_zst_marker_def(vname.clone())); } - } + __result + }) + .join(&"\n".to_string()) } pub fn has_complex_variants(item: Rc) -> bool { @@ -2352,9 +2753,8 @@ pub fn build_shared_types( .iter() .cloned() { - if ((sharing.needs_sharing.clone() - && (k.clone().as_str() != "optional".to_string().as_str())) - && (k.clone().as_str() != "boolean_algebra".to_string().as_str())) + if ((sharing.needs_sharing.clone() && (k.clone() != "optional".to_string())) + && (k.clone() != "boolean_algebra".to_string())) { __result.push(k); } @@ -2532,6 +2932,7 @@ pub fn emit_rust(typed: Rc) -> Rc { owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let registry = typed.item_registry.clone(); @@ -2612,18 +3013,18 @@ pub fn emit_rust(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone().as_str() + if (p.module_name.clone() == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ) - .as_str()) + )) { __result.push(p); } } __result }), + emit_info.corpus_repr.clone(), )); } __result @@ -2631,7 +3032,7 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (f.path.clone() != "".to_string()) { __result.push(f); } } @@ -2642,8 +3043,7 @@ pub fn emit_rust(typed: Rc) -> Rc { 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()) - .as_str() - == "v1.compiler.compile".to_string().as_str()) + == "v1.compiler.compile".to_string()) { __found = true; break; @@ -2762,9 +3162,6 @@ pub fn emit_lib_rs_from_files( "".to_string() }; let shared_types = emit_non_empty_wrappers(); - // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (single authority): - // crate-root #![recursion_limit = "256"] added (serde_json::json! recursion fix). - // DISSOLUTION lane adhoc-1bdd0259-2e3; a clean regen reproduces this from the .dag. let content = 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\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, unreachable_patterns, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), mod_decls.join(&"\n".to_string())), hand_maintained_mods), "\n\n".to_string()), shared_types), test_mod); Rc::new(TextFile { path: v1_rt::concat( @@ -2799,6 +3196,7 @@ pub fn emit_module( owned_bindings: v1_rt::rc_empty_set::(), 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(), }); let shared_types = emit_info.shared_types.clone(); let export_sets = build_module_export_sets(Rc::new(vec![typed_module.clone()])); @@ -2895,7 +3293,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), module_index.clone(), ); - let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { + let imports_section = if (imports_str.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat("\n".to_string(), imports_str.clone()) @@ -2925,7 +3323,7 @@ pub fn emit_module_full( __result.extend( (*match v1_rt::map_get(&svc_module_map, sn.clone()) { Some(mod_file) => { - if (mod_file.clone().as_str() == this_mod_filename.clone().as_str()) { + if (mod_file.clone() == this_mod_filename.clone()) { Rc::new(vec![]) } else { Rc::new(vec![v1_rt::concat( @@ -3012,7 +3410,7 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = - if (coproduct_wire_contract_validations.clone().as_str() == "".to_string().as_str()) { + if (coproduct_wire_contract_validations.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat( @@ -3073,19 +3471,19 @@ 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()); - let phantom_section = if phantom_zst_markers.as_str() == "" { + 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(authored_name(scope.type_env.clone(), m.clone())); - let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { + 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()).as_str() - == "std.error_primitives".to_string().as_str()) + 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 { @@ -3287,10 +3685,10 @@ pub fn has_physical_type_def_in_module_filename( if { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) - && (is_type_def_item(item.clone()) - || is_type_alias_item(item.clone(), source_indices.clone()) + if ((authored_name_at(source_indices.clone(), item.clone()) + == rhs_name.clone()) + && ((is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; @@ -3342,8 +3740,8 @@ pub fn find_variant_parent_in_module( if { let mut __found = false; for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()).as_str() - == variant_name.clone().as_str()) + if (authored_name_at(source_indices.clone(), child.clone()) + == variant_name.clone()) { __found = true; break; @@ -3385,8 +3783,7 @@ pub fn type_name_is_export_source_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3419,8 +3816,7 @@ pub fn type_name_is_rust_importable_in_module( Some(tm) => match Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) == name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3502,7 +3898,7 @@ pub fn name_in_transitive_export_surface( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (v.clone() == module_name.clone()) { __found = true; break; } @@ -3597,7 +3993,7 @@ pub fn reexport_source_module_name_with_visited( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == import_module.clone().as_str()) { + if (v.clone() == import_module.clone()) { __found = true; break; } @@ -3651,8 +4047,7 @@ pub fn reexport_source_module_name_with_visited( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) - { + if (n.clone() == name.clone()) { __found = true; break; } @@ -3826,7 +4221,7 @@ pub fn import_module_enum_scope( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { __result.push(p); } } @@ -3901,8 +4296,7 @@ pub fn enum_physically_defined_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if (((authored_name_at(source_indices.clone(), item.clone()).as_str() - == enum_name.clone().as_str()) + if (((authored_name_at(source_indices.clone(), item.clone()) == enum_name.clone()) && is_type_def_item(item.clone())) && is_coproduct_type(item.clone())) { @@ -3927,7 +4321,7 @@ pub fn wildcard_import_pool_surface_names( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (v.clone() == module_name.clone()) { __found = true; break; } @@ -4024,7 +4418,7 @@ pub fn wildcard_reexport_surface_names( source_indices.clone(), module_index.clone(), ) { - Some(src) => (src.clone().as_str() != import_module.clone().as_str()), + Some(src) => (src.clone() != import_module.clone()), None => false, } { __result.push(n); @@ -4097,7 +4491,7 @@ pub fn variant_defining_module_filename_for_import( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != import_module.clone().as_str()) { + if (hop.clone() != import_module.clone()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4135,7 +4529,7 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone().as_str() == parent_enum.clone().as_str()) { + if (local_parent.clone() == parent_enum.clone()) { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -4187,7 +4581,7 @@ pub fn explicit_import_source_module_for_name( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (n.clone() == name.clone()) { __found = true; break; } @@ -4300,7 +4694,7 @@ pub fn reexport_variant_parent_in_import_module( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != src_mod.clone().as_str()) { + if (hop.clone() != src_mod.clone()) { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4391,7 +4785,7 @@ pub fn alias_rhs_base_module_filename( let local_mod = module_to_filename(alias_module.clone()); match lookup_item(scope.item_registry.clone(), name.clone()) { Some(info) => { - if ((info.module_name.clone().as_str() == alias_module.clone().as_str()) + if ((info.module_name.clone() == alias_module.clone()) && ((info.kind.clone() == ItemKind::TypeItem) || (info.kind.clone() == ItemKind::OtherItem))) { @@ -4444,7 +4838,7 @@ pub fn alias_rhs_base_module_from_import_or_registry( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (n.clone() == name.clone()) { __found = true; break; } @@ -4551,8 +4945,8 @@ pub fn type_item_by_name_in_module_filename( Some(tm) => Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) + if ((authored_name_at(source_indices.clone(), item.clone()) + == rhs_name.clone()) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -4599,28 +4993,12 @@ pub fn type_item_has_rust_nominal_shell_authority( { true } else { - let rhs = resolved_type(item.clone()); - if is_type_alias_return_node(rhs.clone(), source_indices.clone()) - && ((rhs.children.clone().len() as i64) > 0) - { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else if is_type_alias_return_node(rhs.clone(), source_indices.clone()) { - let rhs_name = - authored_name_at(source_indices.clone(), rhs.clone()); - (rhs_name.as_str() != item_text.as_str()) - && rhs_name.as_str() != "" - && alias_rhs_nominal_shell_has_rust_authority( + let rhs = resolved_type(item.clone()); + if (is_type_alias_return_node(rhs.clone(), source_indices.clone()) + && ((rhs.children.clone().len() as i64) > 0)) + { + alias_rhs_nominal_shell_has_rust_authority( rhs.clone(), module_name, imports, @@ -4631,8 +5009,34 @@ pub fn type_item_has_rust_nominal_shell_authority( source_indices.clone(), module_index, ) - } else { - false + } else { + if is_type_alias_return_node( + rhs.clone(), + source_indices.clone(), + ) { + { + let rhs_name = authored_name_at( + source_indices.clone(), + rhs.clone(), + ); + (((rhs_name.clone() != item_text.clone()) + && (rhs_name.clone() != "".to_string())) + && alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + )) + } + } else { + false + } + } } } } else { @@ -4830,9 +5234,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( } else { { let name = authored_name_at(source_indices.clone(), n.clone()); - if ((name.clone().as_str() == "".to_string().as_str()) - || is_kernel_type(name.clone())) - { + if ((name.clone() == "".to_string()) || is_kernel_type(name.clone())) { true } else { if is_phantom_unit_variant_type_arg( @@ -4881,91 +5283,100 @@ pub fn is_self_referential_opaque_type_resolved( item: Rc, source_indices: Rc>>, ) -> bool { - 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 + { + 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)) + } } pub fn is_zero_param_self_referential_opaque_decl( item: Rc, source_indices: Rc>>, ) -> bool { - is_bare_leaf_item(item.clone()) - && is_self_referential_opaque_type_resolved(item.clone(), source_indices) + (is_bare_leaf_item(item.clone()) + && is_self_referential_opaque_type_resolved(item.clone(), source_indices)) } pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((item.params.clone().len() as i64) > 0) - && item.body.is_none() - && item.transport.is_none() - && (item.children.clone().len() as i64) == 0 + ((((((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)) + || is_self_referential_opaque_type_resolved(item.clone(), source_indices.clone()))) } pub fn emit_zero_param_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - v1_rt::concat( + { + let item_text = authored_name_at(source_indices, item); v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), + v1_rt::concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), + rust_visibility_prefix(), + ), + rust_items().struct_keyword.clone(), ), - rust_items().struct_keyword.clone(), - ), - v1_rt::concat( - v1_rt::concat(" ".to_string(), item_text), - "(pub std::marker::PhantomData<()>);".to_string(), + " ".to_string(), ), + item_text, ), - "".to_string(), - ), - "".to_string(), - ) + "(pub std::marker::PhantomData<()>);".to_string(), + ) + } } pub fn emit_parametric_phantom_opaque_struct( item: Rc, source_indices: Rc>>, ) -> String { - let item_text = authored_name_at(source_indices.clone(), item.clone()); - let type_params = emit_type_params(item.params.clone(), source_indices.clone()); - 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(), g), - ">".to_string(), - ), - None => "std::marker::PhantomData<()>".to_string(), - }; - v1_rt::concat( + { + let item_text = authored_name_at(source_indices.clone(), item.clone()); + let type_params = emit_type_params(item.params.clone(), source_indices.clone()); + 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(), g.clone()), + ">".to_string(), + ), + None => "std::marker::PhantomData<()>".to_string(), + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n".to_string(), - rust_visibility_prefix(), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\n" + .to_string(), + rust_visibility_prefix(), + ), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + item_text, + ), + type_params, ), - rust_items().struct_keyword.clone(), + "(pub ".to_string(), ), - v1_rt::concat(v1_rt::concat(" ".to_string(), item_text), type_params), + marker_ty, ), - v1_rt::concat( - v1_rt::concat("(pub ".to_string(), marker_ty), - ");".to_string(), - ), - ), - "".to_string(), - ) + ");".to_string(), + ) + } } pub fn is_emittable_parametric_type_alias_item( @@ -4995,37 +5406,21 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs_name = authored_name_at(source_indices.clone(), rhs.clone()); - if rhs_name.as_str() != item_text.as_str() { - if (rhs.children.clone().len() as i64) > 0 { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else if rhs_name.as_str() != "" { - alias_rhs_nominal_shell_has_rust_authority( - rhs.clone(), - module_name, - imports, - scope, - registry, - export_sets, - typed_modules, - source_indices.clone(), - module_index, - ) - } else { - false - } - } else { - false - } + ((rhs_name.clone() != item_text) + && (((rhs.children.clone().len() as i64) > 0) + || ((((rhs.children.clone().len() as i64) == 0) + && (rhs_name.clone() != "".to_string())) + && alias_rhs_nominal_shell_has_rust_authority( + rhs.clone(), + module_name, + imports, + scope, + registry, + export_sets, + typed_modules, + source_indices.clone(), + module_index, + )))) } } } @@ -5053,7 +5448,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for ln in local_names.clone().iter().cloned() { - if !(ln.clone().as_str() != n.clone().as_str()) { + if !(ln.clone() != n.clone()) { __all = false; break; } @@ -5195,7 +5590,7 @@ pub fn emit_specific_import_block( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { __result.push(p); } } @@ -5229,7 +5624,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, } { __found = true; @@ -5251,7 +5646,7 @@ pub fn emit_specific_import_block( if { let mut __all = true; for n in direct_names.clone().iter().cloned() { - if !(n.clone().as_str() != p.clone().as_str()) { + if !(n.clone() != p.clone()) { __all = false; break; } @@ -5276,7 +5671,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, } { __found = true; @@ -5360,9 +5755,7 @@ pub fn emit_specific_import_block( export_sets.clone(), source_indices.clone(), module_index.clone(), - ) - .as_str() - == def_mod.clone().as_str()) + ) == def_mod.clone()) { __result.push(n); } @@ -5440,13 +5833,13 @@ pub fn emit_specific_import_block( Rc::new({ let mut __result = Vec::new(); for l in type_direct_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } __result }), - if (other_direct_line.clone().as_str() != "".to_string().as_str()) { + if (other_direct_line.clone() != "".to_string()) { Rc::new(vec![other_direct_line.clone()]) } else { Rc::new(vec![]) @@ -5466,9 +5859,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } + Some(found) => (found.clone() == p.clone()), None => match reexport_variant_parent_in_import_module( n.clone(), import_module.clone(), @@ -5479,9 +5870,7 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } + Some(found) => (found.clone() == p.clone()), None => false, }, } { @@ -5520,15 +5909,15 @@ pub fn emit_specific_import_block( __result.push({ let group = Rc::new({ let mut __result = Vec::new(); for p in remote_parent_list.clone().iter().cloned() { if { let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (found.clone() == p.clone()), None => false, }, } { __result.push(n); } } __result }).first().cloned(); match rep_variant.clone() { - Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()).as_str() == def_mod.clone().as_str()), - None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()).as_str() == def_mod.clone().as_str()), + Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()) == def_mod.clone()), + None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()) == def_mod.clone()), } } { __result.push(p); } } __result }); if ((group.clone().len() as i64) > 0) { @@ -5549,7 +5938,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5560,7 +5949,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5596,10 +5985,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib source_indices.clone(), module_index.clone(), ) { - Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) - } + Some(found) => (found.clone() == parent.clone()), None => { match reexport_variant_parent_in_import_module( n.clone(), @@ -5612,8 +5998,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib module_index.clone(), ) { Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) + (found.clone() == parent.clone()) } None => match find_variant_parent( type_summaries.clone(), @@ -5692,7 +6077,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib if ({ let mut __found = false; for p in parent_list.clone().iter().cloned() { - if (p.clone().as_str() == en.clone().as_str()) { + if (p.clone() == en.clone()) { __found = true; break; } @@ -5726,7 +6111,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5735,7 +6120,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in variant_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5859,7 +6244,7 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { } pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: String) -> bool { - (((rust_pub_use_module_name(line.clone()).as_str() == mod_name.as_str()) + (((rust_pub_use_module_name(line.clone()) == mod_name) && v1_rt::contains(line.clone(), "::{".to_string())) && (((v1_rt::contains( line.clone(), @@ -5892,9 +6277,7 @@ pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> b { let mod_name = rust_pub_use_module_name(line.clone()); let name = rust_pub_use_singleton_name(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || (name.clone().as_str() == "".to_string().as_str())) - { + if ((mod_name.clone() == "".to_string()) || (name.clone() == "".to_string())) { false } else { { @@ -5919,17 +6302,14 @@ pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || ((names.clone().len() as i64) == 0)) - { + if ((mod_name.clone() == "".to_string()) || ((names.clone().len() as i64) == 0)) { false } else { { let mut __found = false; for other in lines.iter().cloned() { - if (((((other.clone().as_str() != line.clone().as_str()) - && (rust_pub_use_module_name(other.clone()).as_str() - == mod_name.clone().as_str())) + if (((((other.clone() != line.clone()) + && (rust_pub_use_module_name(other.clone()) == mod_name.clone())) && v1_rt::contains(other.clone(), "::{".to_string())) && ((rust_pub_use_braced_names(other.clone()).len() as i64) > (names.clone().len() as i64))) @@ -5968,9 +6348,7 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> Rc> { let exact = unique_strings(Rc::new({ let mut __result = Vec::new(); for line in lines.iter().cloned() { - if (line.clone().as_str() != "".to_string().as_str()) { + if (line.clone() != "".to_string()) { __result.push(line); } } @@ -6083,8 +6461,7 @@ pub fn emit_imports( let mut __result = Vec::new(); for imp in imports.clone().iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - .as_str() - == import_module.clone().as_str()) + == import_module.clone()) { __result.push(imp); } @@ -6154,8 +6531,7 @@ pub fn emit_imports( source_indices.clone(), module_index.clone(), ); - if (specific_block.clone().as_str() != "".to_string().as_str()) - { + if (specific_block.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat(wildcard_line.clone(), "\n".to_string()), specific_block.clone(), @@ -6285,44 +6661,74 @@ pub fn emit_typed_item( && rust_nominal_identity_carrier_type_eligible(item_text.clone())) { rust_nominal_identity_carrier_def(item_text.clone()) - } else if is_zero_param_self_referential_opaque_decl( - item.clone(), - env.source_indices.clone(), - ) { - emit_zero_param_phantom_opaque_struct(item.clone(), env.source_indices.clone()) } else { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( + if is_zero_param_self_referential_opaque_decl( + item.clone(), + env.source_indices.clone(), + ) { + emit_zero_param_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + match rust_seed_host_numeric_alias( + item_text.clone(), + emit_info.corpus_repr.clone(), + ) { + Some(host) => v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), + ), + " ".to_string(), + ), + item_text.clone(), ), - " ".to_string(), + " = ".to_string(), ), - item_text.clone(), + host.clone(), ), - " = ".to_string(), + ";".to_string(), ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - Rc::new(vec![]), - shared_types, - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().type_alias_keyword.clone(), + ), + " ".to_string(), + ), + item_text.clone(), + ), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + Rc::new(vec![]), + shared_types, + emit_info.corpus_repr.clone(), + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), ), - ), - ";".to_string(), - ) + } + } } } else { if is_type_decl_item(item.clone(), env.source_indices.clone()) { @@ -6331,19 +6737,11 @@ pub fn emit_typed_item( { rust_nominal_identity_carrier_def(item_text.clone()) } else { - if is_emittable_parametric_type_alias_item( - item.clone(), + match rust_seed_host_container_base( item_text.clone(), - env.source_indices.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), + emit_info.corpus_repr.clone(), ) { - { + Some(host) => { let type_params = emit_type_params( item.params.clone(), env.source_indices.clone(), @@ -6359,45 +6757,105 @@ pub fn emit_typed_item( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - rust_items().type_alias_keyword.clone(), + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items() + .type_alias_keyword + .clone(), + ), + " ".to_string(), + ), + item_text.clone(), ), - " ".to_string(), + type_params, ), - item_text.clone(), + " = ".to_string(), ), - type_params, + host.clone(), ), - " = ".to_string(), - ), - render_rust_alias_rhs_type( - resolved_type(item.clone()), - generic_names, - shared_types, - env.source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - emit_info.variant_to_enum.clone(), + "<".to_string(), ), + generic_names.join(&", ".to_string()), ), - ";".to_string(), + ">;".to_string(), ) } - } else if is_parametric_opaque_type_decl_item( - item.clone(), - env.source_indices.clone(), - ) { - emit_parametric_phantom_opaque_struct( - item.clone(), - env.source_indices.clone(), - ) - } else { - "".to_string() + None => { + if is_emittable_parametric_type_alias_item( + item.clone(), + item_text.clone(), + env.source_indices.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + ) { + { + let type_params = emit_type_params( + item.params.clone(), + env.source_indices.clone(), + ); + let generic_names = item_generic_param_names( + item.clone(), + env.source_indices.clone(), + ); + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items() + .type_alias_keyword + .clone(), + ), + " ".to_string(), + ), + item_text.clone(), + ), + type_params, + ), + " = ".to_string(), + ), + render_rust_alias_rhs_type( + resolved_type(item.clone()), + generic_names, + shared_types, + emit_info.corpus_repr.clone(), + env.source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + emit_info.variant_to_enum.clone(), + ), + ), + ";".to_string(), + ) + } + } else { + if is_parametric_opaque_type_decl_item( + item.clone(), + env.source_indices.clone(), + ) { + emit_parametric_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + "".to_string() + } + } + } } } } else { @@ -6441,6 +6899,7 @@ pub fn emit_typed_item( owned_bindings: v1_rt::rc_empty_set::(), 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(), @@ -6495,11 +6954,17 @@ pub fn emit_typed_item( item.clone(), registry.clone(), shared_types, + emit_info.corpus_repr.clone(), env.clone(), ) } else { if is_resource_def_item(item.clone()) { - emit_resource_def(item.clone(), shared_types, env.clone()) + emit_resource_def( + item.clone(), + shared_types, + emit_info.corpus_repr.clone(), + env.clone(), + ) } else { v1_rt::concat( v1_rt::concat( @@ -6530,9 +6995,7 @@ pub fn needs_box_wrapping( if v1_rt::set_contains(&shared_types, name.clone()) { break false; } else { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()).as_str() - != name.clone().as_str()) - { + if (coerce_primitive_type(RenderTarget::Rust, name.clone()) != name.clone()) { break false; } else { break v1_rt::set_contains(&recursive_types, name.clone()); @@ -6583,12 +7046,11 @@ pub fn is_function_type_param(param: Rc) -> bool { Some(inf) => is_type_variable(inf.clone()), None => false, }; - let same_source_span = (((param.span.clone().file.clone().as_str() - == type_expr.span.clone().file.clone().as_str()) + let same_source_span = (((param.span.clone().file.clone() + == type_expr.span.clone().file.clone()) && (param.span.clone().start.clone() == type_expr.span.clone().start.clone())) && (param.span.clone().end.clone() == type_expr.span.clone().end.clone())); - (((param.name.clone().as_str() != "".to_string().as_str()) - && (param.name.clone().as_str() == type_expr.name.clone().as_str())) + (((param.name.clone() != "".to_string()) && (param.name.clone() == type_expr.name.clone())) && (type_expr_is_var || same_source_span)) } } @@ -6709,11 +7171,10 @@ pub fn emit_type_def_from_connective( Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; - let validations = if (policy_validation.clone().as_str() == "".to_string().as_str()) - { + let validations = if (policy_validation.clone() == "".to_string()) { rename_validations.clone() } else { - if (rename_validations.clone().as_str() == "".to_string().as_str()) { + if (rename_validations.clone() == "".to_string()) { policy_validation.clone() } else { v1_rt::concat( @@ -6740,7 +7201,7 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), emit_info, ); - if (validations.clone().as_str() == "".to_string().as_str()) { + if (validations.clone() == "".to_string()) { enum_text } else { v1_rt::concat( @@ -6753,6 +7214,73 @@ pub fn emit_type_def_from_connective( } } +pub fn type_node_mentions_name( + n: Rc, + target: String, + source_indices: Rc>>, +) -> bool { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (authored_name_at(source_indices.clone(), n.clone()) == target.clone()) { + true + } else { + { + let mut __found = false; + for c in n.children.clone().iter().cloned() { + if type_node_mentions_name(c.clone(), target.clone(), source_indices.clone()) { + __found = true; + break; + } + } + __found + } + } + }) +} + +pub fn struct_unused_param_names( + generic_param_names: Rc>, + children: Rc>>, + source_indices: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for p in generic_param_names.iter().cloned() { + if !{ + let mut __found = false; + for child in children.clone().iter().cloned() { + if type_node_mentions_name( + field_node_type_expr(child.clone()), + p.clone(), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + } { + __result.push(p); + } + } + __result + }) +} + +pub fn rust_phantom_marker_inner(unused: Rc>) -> String { + if ((unused.clone().len() as i64) == 1) { + unused.clone().join(&", ".to_string()) + } else { + v1_rt::concat( + v1_rt::concat("(".to_string(), unused.clone().join(&", ".to_string())), + ")".to_string(), + ) + } +} + +pub fn rust_phantom_field_name() -> String { + "_phantom".to_string() +} + pub fn emit_struct_from_children( name: String, type_params: String, @@ -6775,9 +7303,7 @@ pub fn emit_struct_from_children( name.clone(), children.clone(), env.source_indices.clone(), - ) - .as_str() - != "".to_string().as_str()) + ) != "".to_string()) { rust_nominal_ord_derives_for_shape( name.clone(), @@ -6829,7 +7355,32 @@ pub fn emit_struct_from_children( } __result }); - let fields_str = field_lines.join(&"\n".to_string()); + let unused_params = struct_unused_param_names( + generic_param_names.clone(), + children.clone(), + env.source_indices.clone(), + ); + let all_field_lines = if ((unused_params.clone().len() as i64) > 0) { + v1_rt::concat( + field_lines, + Rc::new(vec![v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(" ".to_string(), rust_visibility_prefix()), + rust_phantom_field_name(), + ), + ": std::marker::PhantomData<".to_string(), + ), + rust_phantom_marker_inner(unused_params.clone()), + ), + ">,".to_string(), + )]), + ) + } else { + field_lines + }; + let fields_str = all_field_lines.join(&"\n".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -6863,6 +7414,7 @@ pub fn emit_struct_from_children( pub fn render_rust_type_with_applied_binding( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match find_property( @@ -6872,51 +7424,93 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 { - if outer_name != applied_name { - render_rust_shared_type_if_needed( - 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, - shared_types.clone(), - ) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if (((outer_name.clone() != "".to_string()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + { + if (outer_name.clone() != applied_name) { + render_rust_shared_type_if_needed( + outer_name.clone(), + 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.clone(), + shared_types.clone(), + ) + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >( + ), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), + ) + } + } } else { render_rust_applied_type_shared( applied.clone(), Rc::new(vec![]), - shared_types, + shared_types.clone(), + corpus_repr, source_indices.clone(), + v1_rt::rc_empty_map::(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + String, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types, - source_indices.clone(), - ) } } else { - render_rust_type(n.clone(), shared_types, source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + ) } } - None => render_rust_type(n.clone(), shared_types, source_indices.clone()), + None => render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr, + source_indices.clone(), + ), } } pub fn render_rust_field_type_with_applied_binding( field: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -6930,6 +7524,7 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( field.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } else { @@ -6942,17 +7537,24 @@ pub fn render_rust_field_type_with_applied_binding( render_rust_type_with_applied_binding( authored_type.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } else { if ((authored_type.connective.clone() == Connective::NoConnective) && ((authored_type.children.clone().len() as i64) > 0)) { - render_rust_type(authored_type.clone(), shared_types, source_indices.clone()) + render_rust_type( + authored_type.clone(), + shared_types, + corpus_repr, + source_indices.clone(), + ) } else { render_rust_type_with_applied_binding( resolved_type(field.clone()), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -6990,6 +7592,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7002,6 +7605,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( authored_child_type.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7014,6 +7618,7 @@ pub fn emit_struct_field_from_child( render_rust_type_with_applied_binding( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -7060,6 +7665,7 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7067,6 +7673,7 @@ pub fn emit_struct_field_from_child( None => render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), } @@ -7075,6 +7682,7 @@ pub fn emit_struct_field_from_child( render_rust_type( rt_child.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } @@ -7082,7 +7690,7 @@ pub fn emit_struct_field_from_child( } } }; - let generic_ty = if (struct_name.as_str() == "PartialFunction".to_string().as_str()) { + let generic_ty = if (struct_name == "PartialFunction".to_string()) { rust_normalize_partial_function_field_type_text(rust_normalize_witness_type_text(ty)) } else { ty @@ -7113,8 +7721,8 @@ pub fn emit_struct_field_from_child( let rename_attr = match Rc::new({ let mut __result = Vec::new(); for p in child.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), env.source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (field_init_node_name_at(p.clone(), env.source_indices.clone()) + == "from_key".to_string()) { __result.push(p); } @@ -7159,19 +7767,18 @@ pub fn emit_rust_field_definition( { let snake = to_snake(authored.clone()); let emitted = emit_ident(authored.clone(), RenderTarget::Rust); - let keyword_rename = if ((emitted.clone().as_str() != snake.clone().as_str()) - && (rename_attr.clone().as_str() == "".to_string().as_str())) - { - v1_rt::concat( + let keyword_rename = + if ((emitted.clone() != snake.clone()) && (rename_attr.clone() == "".to_string())) { v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + v1_rt::concat( + v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), + snake.clone(), + ), + "\")]\n".to_string(), + ) + } else { + "".to_string() + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7241,7 +7848,7 @@ pub fn emit_enum_from_children( __result }); let variants_str = variant_lines.join(&"\n".to_string()); - let tag_line = if (serde_policy.enum_attr.clone().as_str() == "".to_string().as_str()) { + let tag_line = if (serde_policy.enum_attr.clone() == "".to_string()) { "".to_string() } else { v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) @@ -7283,7 +7890,7 @@ pub fn emit_enum_from_children( env.clone(), emit_info.clone(), ); - if (accessor_impl.clone().as_str() == "".to_string().as_str()) { + if (accessor_impl.clone() == "".to_string()) { enum_def } else { v1_rt::concat( @@ -7332,9 +7939,7 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> if !({ let mut __found = false; for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __found = true; break; } @@ -7398,8 +8003,7 @@ pub fn emit_enum_shared_accessors( match Rc::new({ let mut __result = Vec::new(); for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __result.push(f); } @@ -7412,6 +8016,7 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "".to_string(), @@ -7427,7 +8032,7 @@ pub fn emit_enum_shared_accessors( { let mut __all = true; for t in types.clone().iter().cloned() { - if !(t.clone().as_str() == first_type.clone().as_str()) { + if !(t.clone() == first_type.clone()) { __all = false; break; } @@ -7450,9 +8055,7 @@ pub fn emit_enum_shared_accessors( let ty = match Rc::new({ let mut __result = Vec::new(); for f in first_fielded.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (authored_name(env.clone(), f.clone()) == fname.clone()) { __result.push(f); } } @@ -7464,6 +8067,7 @@ pub fn emit_enum_shared_accessors( Some(f) => render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ), None => "compile_error!(\"enum shared accessor missing field metadata\")" @@ -7609,8 +8213,7 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) - && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)).as_str() - == prefix.clone().as_str())) + && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)) == prefix.clone())) { Some(v1_rt::substring( &value, @@ -7632,9 +8235,7 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { &value, (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), v1_rt::string_length(&value), - ) - .as_str() - == suffix.clone().as_str())) + ) == suffix.clone())) { Some(v1_rt::substring( &value, @@ -7647,67 +8248,120 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } +pub fn string_index_of_from(mut haystack: String, mut needle: String, mut pos: i64) -> Option { + loop { + if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { + break None; + } else { + if (v1_rt::substring( + &haystack, + pos.clone(), + (pos.clone() + v1_rt::string_length(&needle)), + ) == needle.clone()) + { + break Some(pos.clone()); + } else { + { + let __tco_0 = (pos + 1); + pos = __tco_0; + continue; + } + } + } + } +} + +pub fn string_index_of(haystack: String, needle: String) -> Option { + string_index_of_from(haystack, needle, 0) +} + pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, ) -> Option { - if policy.error_message.is_some() { - return None; - } - match policy.rename_style.clone() { - Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { - let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix) { - Some(stripped) => stripped, - 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, - }, - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } else { - None + if (policy.error_message.clone() != None) { + None + } else { + match policy.rename_style.clone() { + Some(style) => { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { + { + let without_prefix = match policy.rename_prefix.clone() { + 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.clone()) { + Some(stripped) => stripped.clone(), + None => return None, + } + } + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } + } else { + None + } } - } - None => { - if policy.enum_attr.contains("rename_all = \"snake_case\"") { - Some(to_snake(authored)) - } else if policy.enum_attr.is_empty() - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - { - Some(authored) - } else { - None + None => { + if v1_rt::contains( + policy.enum_attr.clone(), + "rename_all = \"snake_case\"".to_string(), + ) { + Some(to_snake(authored)) + } else { + if (((policy.enum_attr.clone() == "".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + { + Some(authored) + } else { + None + } + } } } } } -pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { - let needle = "tag = \""; - let start = policy.enum_attr.find(needle)? + needle.len(); - let rest = &policy.enum_attr[start..]; - let end = rest.find('"')?; - Some(rest[..end].to_string()) +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)); + 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(), + )), + None => None, + } + } + None => None, + } + } } -pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { - policy.enum_attr.contains("untagged") +pub fn policy_is_untagged(policy: Rc) -> bool { + v1_rt::contains(policy.enum_attr.clone(), "untagged".to_string()) } -pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { - !policy.enum_attr.contains("tag =") - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - && policy.rename_style.is_none() +pub fn policy_is_string_variant(policy: Rc) -> bool { + (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + && (policy.rename_style.clone() == None)) } pub fn wire_variant_rename_attr_for_policy( @@ -7717,9 +8371,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.as_str() == "StripAffixAndSnakeCase" { + 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 { @@ -7738,7 +8392,7 @@ pub fn variant_rename_validation_for_policy( ) -> String { match policy.rename_style.clone() { Some(style) => { - if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { + if (style.clone() == "StripAffixAndSnakeCase".to_string()) { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { @@ -7801,7 +8455,7 @@ pub fn variant_rename_validations_for_policy( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (text.clone() != "".to_string()) { __result.push(text); } } @@ -7843,6 +8497,7 @@ pub fn enum_variant_field_type_node( pub fn render_variant_payload_type( n: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { if ((n.connective.clone() == Connective::NoConnective) @@ -7856,6 +8511,7 @@ pub fn render_variant_payload_type( __result.push(render_rust_type( child_type_node(c.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), )); } @@ -7874,7 +8530,12 @@ pub fn render_variant_payload_type( ) } } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) + render_rust_type( + n.clone(), + shared_types.clone(), + corpus_repr.clone(), + source_indices.clone(), + ) } } @@ -7886,9 +8547,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).as_str() == "0".to_string().as_str()) - } + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, } } @@ -7923,8 +8582,7 @@ pub fn emit_variant_from_child( env.source_indices.clone(), ); let tuple_style = (positional_payload.clone() - || (serde_policy.enum_attr.clone().as_str() - == "#[serde(untagged)]".to_string().as_str())); + || (serde_policy.enum_attr.clone() == "#[serde(untagged)]".to_string())); if tuple_style { match child.children.clone().first().cloned() { Some(f) => { @@ -7945,12 +8603,14 @@ pub fn emit_variant_from_child( render_variant_payload_type( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { render_rust_type( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) }; @@ -7963,6 +8623,7 @@ pub fn emit_variant_from_child( render_rust_type_with_applied_binding( type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ) } else { @@ -8013,6 +8674,7 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8066,6 +8728,7 @@ pub fn emit_variant_from_child( let ty = render_rust_field_type_with_applied_binding( f.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), env.source_indices.clone(), ); let final_ty = if needs_box_wrapping( @@ -8122,71 +8785,78 @@ pub fn emit_fn_def( shared_types: Rc>, emit_info: Rc, ) -> String { - if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { - if rust_emit_faithful_text_carrier(scope.type_env.source_indices.clone()) { - return seam_fn; - } else { - return "".to_string(); - } - } { let si = scope.type_env.clone().source_indices.clone(); - let type_params = function_type_params(params.clone()); - let value_params = function_value_params(params.clone()); - if function_type_params_have_collision(type_params.clone()) { - return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); - } - let type_params_str = emit_type_params(type_params.clone(), si.clone()); - let generic_param_names = Rc::new({ - let mut __result = Vec::new(); - for p in type_params.clone().iter().cloned() { - __result.push(generic_param_name_at(p.clone(), si.clone())); + 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() + } else { + "".to_string() + } } - __result - }); - let params_str = emit_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - emit_info.read_only_params.clone(), - scope.type_env.clone(), - ); - let ret_str = emit_inferred( - inferred, - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - scope.type_env.clone(), - ); - let body_scope = build_params_scope(scope.clone(), value_params.clone()); - let depth = 0; - let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); - let needs_stacker = - (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) - && (use_tco.clone() == false)); - if use_tco.clone() { - { - let tco_params_str = emit_tco_params( + None => { + let type_params = function_type_params(params.clone()); + let value_params = function_value_params(params.clone()); + if function_type_params_have_collision(type_params.clone()) { + return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); + } + let type_params_str = emit_type_params(type_params.clone(), si.clone()); + let generic_param_names = Rc::new({ + let mut __result = Vec::new(); + for p in type_params.clone().iter().cloned() { + __result.push(generic_param_name_at(p.clone(), si.clone())); + } + __result + }); + let params_str = emit_params( value_params.clone(), generic_param_names.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), si.clone(), + emit_info.read_only_params.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); - let body_str = emit_typed_tco_body( - body.clone(), - name.clone(), - value_params.clone(), - registry.clone(), - body_scope, - (depth.clone() + 1), + let ret_str = emit_inferred( + inferred, + generic_param_names.clone(), shared_types.clone(), - emit_info.clone(), + emit_info.corpus_repr.clone(), + si.clone(), + emit_info.variant_to_enum.clone(), + scope.type_env.clone(), ); - let kw = rust_items().func_keyword.clone(); - v1_rt::concat( - v1_rt::concat( + let body_scope = build_params_scope(scope.clone(), value_params.clone()); + let depth = 0; + let use_tco = + is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); + let needs_stacker = + (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) + && (use_tco.clone() == false)); + if use_tco.clone() { + { + let tco_params_str = emit_tco_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + emit_info.corpus_repr.clone(), + 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.clone(), + registry.clone(), + body_scope, + (depth.clone() + 1), + shared_types.clone(), + emit_info.clone(), + ); + let kw = rust_items().func_keyword.clone(); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -8197,49 +8867,53 @@ pub fn emit_fn_def( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - kw, + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + kw, + ), + " ".to_string(), + ), + emit_ident( + name.clone(), + RenderTarget::Rust, + ), ), - " ".to_string(), - ), - emit_ident( - name.clone(), - RenderTarget::Rust, + type_params_str, ), + "(".to_string(), ), - type_params_str, + tco_params_str, ), - "(".to_string(), + ")".to_string(), ), - tco_params_str, + ret_str, ), - ")".to_string(), + " {\n".to_string(), ), - ret_str, + make_indent((depth.clone() + 1)), ), - " {\n".to_string(), + body_str, ), - make_indent((depth.clone() + 1)), - ), - body_str, - ), - "\n}".to_string(), - ) + "\n}".to_string(), + ) + } + } else { + emit_fn_def_non_tco( + name.clone(), + type_params_str, + params_str, + ret_str, + body.clone(), + registry.clone(), + body_scope, + depth.clone(), + shared_types.clone(), + emit_info.clone(), + needs_stacker, + ) + } } - } else { - emit_fn_def_non_tco( - name.clone(), - type_params_str, - params_str, - ret_str, - body.clone(), - registry.clone(), - body_scope, - depth.clone(), - shared_types.clone(), - emit_info.clone(), - needs_stacker, - ) } } } @@ -8399,13 +9073,16 @@ pub fn emit_func_def( uses.clone(), service_names, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), + emit_info.variant_to_enum.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(), ); let body_scope = build_params_scope(scope.clone(), params.clone()); @@ -8619,7 +9296,9 @@ pub fn emit_tco_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8630,7 +9309,9 @@ pub fn emit_tco_params( p.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8644,7 +9325,9 @@ pub fn emit_tco_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8654,15 +9337,19 @@ pub fn emit_tco_param( authored.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8687,8 +9374,10 @@ pub fn emit_func_params( uses: Rc>>, service_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8699,8 +9388,10 @@ pub fn emit_func_params( p.clone(), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8720,6 +9411,7 @@ pub fn emit_func_params( render_rust_type( resource_use_resource(u.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ), )); @@ -8744,12 +9436,13 @@ pub fn emit_func_params( pub fn emit_func_inferred( inferred: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { v1_rt::concat( v1_rt::concat( " -> Result<".to_string(), - render_rust_type(inferred, shared_types, source_indices), + render_rust_type(inferred, shared_types, corpus_repr, source_indices), ), ", Box>".to_string(), ) @@ -8759,8 +9452,10 @@ pub fn emit_params( params: Rc>>, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8771,8 +9466,10 @@ pub fn emit_params( p.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8786,16 +9483,20 @@ pub fn render_rust_param_sig_type( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param.clone()); + let type_node = resolved_type(param); render_rust_fn_sig_type( type_node, generic_param_names, shared_types, + corpus_repr, source_indices, + variant_to_enum, env, ) } @@ -8805,7 +9506,9 @@ pub fn emit_rust_param_type( n: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -8817,7 +9520,9 @@ pub fn emit_rust_param_type( param_node_type_expr(p.clone()), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8829,7 +9534,9 @@ pub fn emit_rust_param_type( rt.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8850,8 +9557,10 @@ pub fn emit_rust_param_type( n.clone(), generic_param_names.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), - env, + variant_to_enum.clone(), + env.clone(), ) } } @@ -8860,8 +9569,10 @@ pub fn emit_param( param: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8871,15 +9582,19 @@ pub fn emit_param( authored.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( param.clone(), generic_param_names, shared_types, + corpus_repr, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8898,7 +9613,9 @@ pub fn emit_inferred( inferred: Rc, generic_param_names: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -8907,7 +9624,9 @@ pub fn emit_inferred( inferred, generic_param_names, shared_types, + corpus_repr, source_indices, + variant_to_enum, env, ), ) @@ -8990,12 +9709,11 @@ pub fn collect_field_binding_string_guards( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) - } else { - v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) - }; + let field_path = if (fb_name.clone() == "0".to_string()) { + v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) + } else { + v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) + }; let bind_name = pattern_string_binding_name(field_path.clone()); match positional_payload_string_guard( fb_pat.clone(), @@ -9014,7 +9732,7 @@ pub fn collect_field_binding_string_guards( nested_path.clone(), source_indices.clone(), ); - if (nested.clone().as_str() == "".to_string().as_str()) { + if (nested.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![nested.clone()]) @@ -9045,7 +9763,7 @@ pub fn collect_pattern_string_guards( field_bindings: fbs, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) + if (((n.clone() == "Present".to_string()) && (parent.clone().as_deref() == Some("Optional".to_string()).as_deref())) && ((fbs.clone().len() as i64) == 1)) { @@ -9088,8 +9806,7 @@ pub fn collect_pattern_string_guards( match fbs.clone().first().cloned() { Some(fb) => { if (field_binding_name_at(fb.clone(), source_indices.clone()) - .as_str() - == "0".to_string().as_str()) + == "0".to_string()) { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( @@ -9230,7 +9947,7 @@ pub fn pattern_parent_enum( type_summaries: Rc>>, ) -> Option { { - let scrut_is_known_enum = ((scrut_type.clone().as_str() != "".to_string().as_str()) + 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() @@ -9273,13 +9990,12 @@ pub fn unique_variant_parent( } pub fn is_optional_variant_name(name: String) -> bool { - ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str())) + ((name.clone() == "Present".to_string()) || (name.clone() == "Absent".to_string())) } pub fn is_optional_parent(parent_enum: Option) -> bool { match parent_enum { - Some(parent) => (parent.clone().as_str() == "Optional".to_string().as_str()), + Some(parent) => (parent.clone() == "Optional".to_string()), None => false, } } @@ -9337,7 +10053,7 @@ pub fn emit_variant_pattern( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -9350,7 +10066,7 @@ pub fn emit_variant_pattern( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (parent.clone() == "Witness".to_string()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9362,7 +10078,7 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -9393,8 +10109,8 @@ pub fn emit_variant_pattern( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (field_binding_name_at(fb.clone(), source_indices.clone()) + == "0".to_string()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -9597,25 +10313,24 @@ pub fn emit_variant_pattern( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone() == "0".to_string()) { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -9626,15 +10341,13 @@ pub fn emit_variant_pattern( } } else { { - let is_shorthand = match (*fb_pat.clone()) - .clone() - { - MatchPattern::Bind { name: n, .. } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } - _ => false, - }; + let is_shorthand = + match (*fb_pat.clone()).clone() { + MatchPattern::Bind { + name: n, .. + } => (n.clone() == fb_name.clone()), + _ => false, + }; if is_shorthand.clone() { emit_ident( fb_name.clone(), @@ -9642,26 +10355,25 @@ pub fn emit_variant_pattern( ) } else { { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { + let field_path = if (fb_name.clone() + == "0".to_string()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let pat_str = emit_pattern( fb_pat.clone(), field_path.clone(), @@ -9732,7 +10444,7 @@ pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc { let mut __found = false; for name in rc_analysis.ref_bound_fields.clone().iter().cloned() { - if (name.clone().as_str() == field_name.clone().as_str()) { + if (name.clone() == field_name.clone()) { __found = true; break; } @@ -9768,8 +10480,7 @@ pub fn analyze_rc_pattern( ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone().as_str() - == "Present".to_string().as_str()) + 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![]), @@ -9799,18 +10510,17 @@ pub fn analyze_rc_pattern( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - let inner_scrut = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - positional_payload_scrut_type( - resolved_parent.clone(), - n.clone(), - fb.clone(), - emit_info.clone(), - source_indices.clone(), - ) - } else { - "".to_string() - }; + let inner_scrut = if (fb_name.clone() == "0".to_string()) { + positional_payload_scrut_type( + resolved_parent.clone(), + n.clone(), + fb.clone(), + emit_info.clone(), + source_indices.clone(), + ) + } else { + "".to_string() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -9970,7 +10680,7 @@ pub fn emit_variant_pattern_rc_aware( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -9983,7 +10693,7 @@ pub fn emit_variant_pattern_rc_aware( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (parent.clone() == "Witness".to_string()) { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9995,7 +10705,7 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (name.clone() == "Present".to_string())) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -10034,8 +10744,8 @@ pub fn emit_variant_pattern_rc_aware( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (field_binding_name_at(fb.clone(), source_indices.clone()) + == "0".to_string()) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10270,25 +10980,24 @@ pub fn emit_variant_pattern_rc_aware( let fb_pat = field_binding_pattern(fb.clone()); if is_string_lit_pattern(fb_pat.clone()) { { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( + let field_path = + if (fb_name.clone() == "0".to_string()) { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + v1_rt::rc_list_push( + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let bind_name = pattern_string_binding_name( field_path.clone(), ); @@ -10316,10 +11025,7 @@ pub fn emit_variant_pattern_rc_aware( { MatchPattern::Bind { name: n, .. - } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } + } => (n.clone() == fb_name.clone()), _ => false, }; if is_shorthand.clone() { @@ -10329,26 +11035,26 @@ pub fn emit_variant_pattern_rc_aware( ) } else { { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { + let field_path = if (fb_name + .clone() + == "0".to_string()) + { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { + path_prefix.clone(), + name.clone(), + ), + "0".to_string(), + ) + } else { + v1_rt::rc_list_push( v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; + path_prefix.clone(), + name.clone(), + ), + fb_name.clone(), + ) + }; let inner_analysis = analyze_rc_pattern( fb_pat.clone(), @@ -10456,7 +11162,7 @@ pub fn rc_pattern_preludes( (*{ let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); - if (fb_name.clone().as_str() == "0".to_string().as_str()) { + if (fb_name.clone() == "0".to_string()) { { let payload_scrut = positional_payload_scrut_type( resolved_parent.clone(), @@ -10479,9 +11185,7 @@ pub fn rc_pattern_preludes( source_indices.clone(), emit_info.clone(), ); - if (inner_preludes.clone().as_str() - == "".to_string().as_str()) - { + if (inner_preludes.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![inner_preludes.clone()]) @@ -10566,7 +11270,7 @@ pub fn explicit_record_struct_name( false }; let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone().as_str() == "__EmitTypeCacheMiss".to_string().as_str()) { + if (nname.clone() == "__EmitTypeCacheMiss".to_string()) { type_name.clone() } else { if n_is_error { @@ -10615,141 +11319,30 @@ pub fn variant_parent_from_binding_kind( } } -pub fn apply_clone(expr: String) -> String { - apply_type_template1( - sharing_for_target(RenderTarget::Rust).clone_value.clone(), - expr, - ) -} - -pub fn apply_deref_clone(expr: String) -> String { - apply_type_template1( - sharing_for_target(RenderTarget::Rust).deref_clone.clone(), - expr, - ) -} - -pub fn apply_field_clone(expr: String, field: String) -> String { - apply_type_template2( - sharing_for_target(RenderTarget::Rust).field_clone.clone(), - expr, - field, - ) -} - -pub fn clone_iterator_suffix() -> String { - sharing_for_target(RenderTarget::Rust).clone_suffix.clone() -} - -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - match v1_rt::map_get(&variant_to_enum, name.clone()) { - Some(parent) => { - if parent.as_str() != "" { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier - } else { - rust_qualify_type_leaf_name(name, variant_to_enum) - } -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - } - } - __result - }) - .join("\n") -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut names: Vec = Vec::new(); - for item in items.iter().cloned() { - if is_type_def_item(item.clone()) - && item - .children - .clone() - .iter() - .all(|c| c.children.clone().len() as i64 == 0) - { - for child in item.children.clone().iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !names.iter().any(|n| n == &vname) - { - names.push(vname); - } - } - } - } - } - names - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env.clone()) - .iter() - .cloned() - { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - __result - }) - .join("\n") +pub fn apply_clone(expr: String) -> String { + apply_type_template1( + sharing_for_target(RenderTarget::Rust).clone_value.clone(), + expr, + ) +} + +pub fn apply_deref_clone(expr: String) -> String { + apply_type_template1( + sharing_for_target(RenderTarget::Rust).deref_clone.clone(), + expr, + ) +} + +pub fn apply_field_clone(expr: String, field: String) -> String { + apply_type_template2( + sharing_for_target(RenderTarget::Rust).field_clone.clone(), + expr, + field, + ) +} + +pub fn clone_iterator_suffix() -> String { + sharing_for_target(RenderTarget::Rust).clone_suffix.clone() } pub fn effective_variant_parent( @@ -10762,7 +11355,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().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { Some(p.clone()) } else { None @@ -10775,8 +11368,7 @@ pub fn effective_variant_parent( None => match resolved_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); - if (((rt.ident_span.clone() != None) - && (rt_name.clone().as_str() != name.clone().as_str())) + if (((rt.ident_span.clone() != None) && (rt_name.clone() != name.clone())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), name.clone(), @@ -10803,14 +11395,10 @@ pub fn emit_var_ref( emit_info: Rc, source_indices: Rc>>, ) -> String { - if ((name.clone().as_str() == "none".to_string().as_str()) - || (name.clone().as_str() == "None".to_string().as_str())) - { + if ((name.clone() == "none".to_string()) || (name.clone() == "None".to_string())) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((name.clone().as_str() == "true".to_string().as_str()) - || (name.clone().as_str() == "false".to_string().as_str())) - { + if ((name.clone() == "true".to_string()) || (name.clone() == "false".to_string())) { emit_keyword(name.clone(), RenderTarget::Rust) } else { { @@ -10826,9 +11414,9 @@ pub fn emit_var_ref( let ref_str = match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(name.clone()) - && (enum_name.clone().as_str() == "Optional".to_string().as_str())) + && (enum_name.clone() == "Optional".to_string())) { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (name.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -10918,14 +11506,10 @@ pub fn emit_typed_expr_base( .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) - { + if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((n.clone().as_str() == "true".to_string().as_str()) - || (n.clone().as_str() == "false".to_string().as_str())) - { + if ((n.clone() == "true".to_string()) || (n.clone() == "false".to_string())) { emit_keyword(n.clone(), RenderTarget::Rust) } else { { @@ -10939,10 +11523,9 @@ pub fn emit_typed_expr_base( match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(n.clone()) - && (enum_name.clone().as_str() - == "Optional".to_string().as_str())) + && (enum_name.clone() == "Optional".to_string())) { - if (n.clone().as_str() == "Present".to_string().as_str()) { + if (n.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -10991,6 +11574,35 @@ pub fn emit_typed_expr_base( } } +pub fn field_access_field_is_boxed( + base: Rc, + field: String, + scope: Rc, + shared_types: Rc>, + emit_info: Rc, +) -> bool { + { + let base_struct = expand_type_for_field_access( + resolved_type(base), + scope.type_env.clone(), + scope.module_name.clone(), + ); + match find_child_named( + base_struct, + field, + scope.type_env.clone().source_indices.clone(), + ) { + Some(field_child) => needs_box_wrapping( + resolved_type(field_child.clone()), + emit_info.recursive_type_set.clone(), + shared_types, + scope.type_env.clone().source_indices.clone(), + ), + None => false, + } + } +} + pub fn emit_typed_field_access( base: Rc, field: String, @@ -11053,9 +11665,7 @@ pub fn emit_typed_field_access( if (authored_name_at( scope.type_env.clone().source_indices.clone(), pair.1.clone(), - ) - .as_str() - == field.clone().as_str()) + ) == field.clone()) { __result.push(pair); } @@ -11125,19 +11735,39 @@ pub fn emit_typed_field_access( } _ => false, }; - if base_is_owned { + let field_is_boxed = field_access_field_is_boxed( + base.clone(), + field.clone(), + scope.clone(), + shared_types.clone(), + emit_info.clone(), + ); + if field_is_boxed { v1_rt::concat( - v1_rt::concat(base_str, ".".to_string()), - emit_ident(field.clone(), RenderTarget::Rust), + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(*".to_string(), base_str), + ".".to_string(), + ), + emit_ident(field.clone(), RenderTarget::Rust), + ), + ").clone()".to_string(), ) } else { - apply_type_template1( - sharing.clone_value.clone(), + if base_is_owned { v1_rt::concat( v1_rt::concat(base_str, ".".to_string()), emit_ident(field.clone(), RenderTarget::Rust), - ), - ) + ) + } else { + apply_type_template1( + sharing.clone_value.clone(), + v1_rt::concat( + v1_rt::concat(base_str, ".".to_string()), + emit_ident(field.clone(), RenderTarget::Rust), + ), + ) + } } } }, @@ -11192,7 +11822,7 @@ pub fn type_needs_rc_seen( } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); if (normed.inferred.clone() != None) { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11205,12 +11835,12 @@ pub fn type_needs_rc_seen( continue; } } else { - if ((canonical.clone().as_str() != "".to_string().as_str()) + if ((canonical.clone() != "".to_string()) && emit_map_has(seen.clone(), canonical.clone())) { break false; } else { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11248,6 +11878,7 @@ pub fn rust_runtime_bridge_name(function_name: String) -> String { pub fn rust_empty_map_value_type_str( map_type: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match map_type.children.clone().get(1 as usize).cloned() { @@ -11255,9 +11886,10 @@ pub fn rust_empty_map_value_type_str( let rendered = render_rust_type( child_type_node(value_child.clone()), shared_types, + corpus_repr, source_indices, ); - if (rendered.clone().as_str() == "".to_string().as_str()) { + if (rendered.clone() == "".to_string()) { "".to_string() } else { rendered.clone() @@ -11270,6 +11902,7 @@ pub fn rust_empty_map_value_type_str( pub fn rust_empty_map_kv_type_str( map_type: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -11277,6 +11910,7 @@ pub fn rust_empty_map_kv_type_str( Some(key_child) => render_rust_type( child_type_node(key_child.clone()), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ), None => "".to_string(), @@ -11284,11 +11918,10 @@ pub fn rust_empty_map_kv_type_str( let val_str = rust_empty_map_value_type_str( map_type.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), ); - if ((key_str.clone().as_str() != "".to_string().as_str()) - && (val_str.clone().as_str() != "".to_string().as_str())) - { + 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(), @@ -11316,12 +11949,12 @@ pub fn rust_btree_set_element_ord_eligible( ) -> bool { { let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); - (((((((elem_name.clone().as_str() == "String".to_string().as_str()) - || (elem_name.clone().as_str() == "Int".to_string().as_str())) - || (elem_name.clone().as_str() == "Bool".to_string().as_str())) - || (elem_name.clone().as_str() == "Unit".to_string().as_str())) - || (elem_name.clone().as_str() == "Secret".to_string().as_str())) - || (elem_name.clone().as_str() == "Bytes".to_string().as_str())) + (((((((elem_name.clone() == "String".to_string()) + || (elem_name.clone() == "Int".to_string())) + || (elem_name.clone() == "Bool".to_string())) + || (elem_name.clone() == "Unit".to_string())) + || (elem_name.clone() == "Secret".to_string())) + || (elem_name.clone() == "Bytes".to_string())) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -11394,7 +12027,7 @@ pub fn emit_rust_empty_set_expr( shared_types, source_indices.clone(), ); - if (elem_str.clone().as_str() != "".to_string().as_str()) { + if (elem_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_set::<".to_string(), @@ -11697,36 +12330,70 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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.module_name.clone(), + ); + let variant_name = match tn.clone() { + Some(n) => n.clone(), + None => "".to_string(), + }; + let peeled_type_name = if (((parent_enum.clone() == None) + && (expanded_rt.connective.clone() == Connective::Conj)) + && (expanded_rt.ident_span.clone() != None)) + { + { + let concrete = authored_name_at(si.clone(), expanded_rt.clone()); + if ((concrete.clone() != "".to_string()) + && (concrete.clone() != variant_name.clone())) + { + Some(concrete.clone()) + } else { + tn.clone() + } + } + } else { + tn.clone() + }; let raw = emit_typed_record_lit( - tn.clone(), + peeled_type_name, fs, parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), registry, scope.clone(), depth, shared_types.clone(), emit_info.clone(), ); - let si = scope.type_env.clone().source_indices.clone(); - let variant_name = match tn.clone() { - Some(n) => n.clone(), - None => "".to_string(), - }; let rc_name = match parent_enum.clone() { Some(en) => en.clone(), None => match contextual_variant_parent( variant_name.clone(), parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), emit_info.clone(), si.clone(), ) { - Some(p) => p, - None => variant_name.clone(), + Some(p) => p.clone(), + None => { + 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.clone() + } else { + variant_name.clone() + } + } }, }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + 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()) @@ -12161,7 +12828,7 @@ pub fn contextual_variant_parent( None => { let rt_name = authored_name_at(source_indices, resolved_type.clone()); if (((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != variant_name.clone().as_str())) + && (rt_name.clone() != variant_name.clone())) && variant_belongs_to_enum( emit_info.type_summaries.clone(), variant_name.clone(), @@ -12204,7 +12871,7 @@ pub fn emit_discriminant_call_lowering( scope.clone(), depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ); let ty_name = @@ -12266,7 +12933,7 @@ pub fn emit_discriminant_call_lowering( ), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), ), ",".to_string(), @@ -12303,7 +12970,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } } @@ -12312,7 +12979,7 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat("\"".to_string(), ty_name.clone()), "\"".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), } } @@ -12329,15 +12996,16 @@ pub fn emit_typed_call_expr( emit_info: Rc, ) -> String { { - let call_str = if (func.clone().as_str() == "empty_map".to_string().as_str()) { + let call_str = if (func.clone() == "empty_map".to_string()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( ret_type.clone(), shared_types, + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -12354,7 +13022,7 @@ pub fn emit_typed_call_expr( .to_string(), } } else { - if (func.clone().as_str() == "empty_set".to_string().as_str()) { + if (func.clone() == "empty_set".to_string()) { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( @@ -12398,7 +13066,7 @@ pub fn emit_typed_call( emit_info: Rc, ) -> String { { - if (func.clone().as_str() == "get".to_string().as_str()) { + if (func.clone() == "get".to_string()) { { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); @@ -12442,7 +13110,7 @@ pub fn emit_typed_call( return get_result; } } - if (func.clone().as_str() == "with".to_string().as_str()) { + if (func.clone() == "with".to_string()) { { let with_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); if ((with_args.clone().len() as i64) == 0) { @@ -12540,7 +13208,7 @@ pub fn emit_typed_call( } } } - if (func.clone().as_str() == "to_string".to_string().as_str()) { + if (func.clone() == "to_string".to_string()) { { let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12561,45 +13229,24 @@ pub fn emit_typed_call( ), ").to_string()".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ), None => "compile_error!(\"to_string call missing value argument\")".to_string(), }; return ts_result; } } - if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { + if (func.clone() == "utf8_decode_bytes".to_string()) { { let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let decode_result = match decode_args.first().cloned() { - Some(value_arg) => v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "String::from_utf8(".to_string(), - emit_typed_expr( - arg_value(value_arg.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ), - ), - ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" - .to_string(), - ), - "".to_string(), - ), - None => { - "compile_error!(\"utf8_decode_bytes call missing value argument\")" - .to_string() - } - }; + Some(value_arg) => v1_rt::concat(v1_rt::concat("String::from_utf8(".to_string(), emit_typed_expr(arg_value(value_arg.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)), ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?".to_string()), + None => "compile_error!(\"utf8_decode_bytes call missing value argument\")".to_string(), +}; return decode_result; } } - if (func.clone().as_str() == "discriminant".to_string().as_str()) { + if (func.clone() == "discriminant".to_string()) { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { @@ -12618,10 +13265,10 @@ pub fn emit_typed_call( return disc_result; } } - let collection_scope = if ((((func.clone().as_str() == "map".to_string().as_str()) - || (func.clone().as_str() == "filter".to_string().as_str())) - || (func.clone().as_str() == "flat_map".to_string().as_str())) - || (func.clone().as_str() == "fold".to_string().as_str())) + let collection_scope = if ((((func.clone() == "map".to_string()) + || (func.clone() == "filter".to_string())) + || (func.clone() == "flat_map".to_string())) + || (func.clone() == "fold".to_string())) { { let call_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12796,8 +13443,7 @@ pub fn emit_typed_call( } else { func_ident }; - let call_str = if ((is_rt.clone() - && (func.clone().as_str() == "concat".to_string().as_str())) + 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.clone(), "".to_string(), shared_types.clone()) @@ -12853,12 +13499,11 @@ pub fn fill_default_args( let is_provided = { let mut __found = false; for n in provided_names.clone().iter().cloned() { - if (n.clone().as_str() + if (n.clone() == param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str()) + )) { __found = true; break; @@ -12971,7 +13616,7 @@ pub fn emit_nested_rt_concat( break acc.clone(); } Some(arg) => { - let next_acc = if (acc.clone().as_str() == "".to_string().as_str()) { + let next_acc = if (acc.clone() == "".to_string()) { arg.clone() } else { v1_rt::concat( @@ -13171,6 +13816,7 @@ pub fn emit_typed_slice( pub fn collection_element_type( receiver_type: Option>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match receiver_type.as_deref().cloned() { @@ -13196,6 +13842,7 @@ pub fn collection_element_type( render_rust_type( elem_node.clone(), shared_types, + corpus_repr, source_indices.clone(), ) } @@ -13252,6 +13899,7 @@ pub fn lambda_param_type_strs( param_nodes: Rc>>, fallback_types: Rc>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> Rc> { Rc::new({ @@ -13291,6 +13939,7 @@ pub fn lambda_param_type_strs( Some(render_rust_type( param_type.clone(), shared_types.clone(), + corpus_repr.clone(), source_indices.clone(), )) } @@ -13354,6 +14003,7 @@ pub fn emit_typed_collection_lambda( pn.clone(), Rc::new(vec![elem_type_str]), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13364,7 +14014,7 @@ pub fn emit_typed_collection_lambda( lambda_scope, depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ); v1_rt::concat( @@ -13378,7 +14028,7 @@ pub fn emit_typed_collection_lambda( scope.clone(), depth, shared_types.clone(), - emit_info, + emit_info.clone(), 1024, ), } @@ -13410,10 +14060,9 @@ pub fn emit_typed_fold_lambda( .skip(1 as usize) .collect::>(), ); - let safe_acc_type = if (((acc_type_str.clone().as_str() - == "Rc>".to_string().as_str()) - || (acc_type_str.clone().as_str() == "Vec<()>".to_string().as_str())) - || (acc_type_str.clone().as_str() == "Option<()>".to_string().as_str())) + let safe_acc_type = if (((acc_type_str.clone() == "Rc>".to_string()) + || (acc_type_str.clone() == "Vec<()>".to_string())) + || (acc_type_str.clone() == "Option<()>".to_string())) { "_".to_string() } else { @@ -13445,6 +14094,7 @@ pub fn emit_typed_fold_lambda( Rc::new(vec![]), fallback_types, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let params_str = param_strs.join(&", ".to_string()); @@ -13462,7 +14112,7 @@ pub fn emit_typed_fold_lambda( Some(n) => n.clone(), None => "".to_string(), }; - let needs_unwrap = ((acc_name.clone().as_str() != "".to_string().as_str()) + let needs_unwrap = ((acc_name.clone() != "".to_string()) && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); if needs_unwrap { { @@ -13534,6 +14184,7 @@ pub fn emit_rust_fold_method_call( let elem_type_str = collection_element_type( receiver.inferred.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); let contextual_acc_type = match result_type.as_deref().cloned() { @@ -13685,6 +14336,7 @@ pub fn emit_rust_fold_method_call( ), 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(), }), None => emit_info.clone(), } @@ -13717,6 +14369,7 @@ pub fn emit_rust_fold_method_call( owned_bindings: emit_info.owned_bindings.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(), }), None => emit_info.clone(), } @@ -13730,6 +14383,7 @@ pub fn emit_rust_fold_method_call( let acc_type_str = render_rust_type( acc_type_node.clone(), shared_types.clone(), + 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) { @@ -13790,18 +14444,19 @@ pub fn emit_rust_fold_method_call( arg_value(init_arg.clone()), scope.type_env.clone().source_indices.clone(), ); - if ((((init_func.clone().as_str() == "empty_map".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + if ((((init_func.clone() == "empty_map".to_string()) + && (acc_type_str.clone() != "_".to_string())) + && (acc_type_str.clone() != "".to_string())) && !acc_has_unit_child.clone()) { { let kv_type_str = rust_empty_map_kv_type_str( acc_type_node.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (kv_type_str.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -13814,13 +14469,12 @@ pub fn emit_rust_fold_method_call( } } } else { - if (init_func.clone().as_str() == "empty_map".to_string().as_str()) { + if (init_func.clone() == "empty_map".to_string()) { "Rc::new(HashMap::new()) /* BRIDGE: fold empty_map accumulator type unresolved */".to_string() } else { - if ((((init_func.clone().as_str() - == "empty_set".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + 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()) { emit_rust_empty_set_expr( @@ -13829,8 +14483,7 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func.clone().as_str() == "empty_set".to_string().as_str()) - { + if (init_func.clone() == "empty_set".to_string()) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -13927,6 +14580,7 @@ pub fn emit_rust_sort_by_method_call( render_rust_type( elem.clone(), shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ) } else { @@ -13951,7 +14605,7 @@ pub fn emit_rust_sort_by_method_call( let iter_str = apply_type_template1(sharing.iter_owned.clone(), recv_str); let a_clone = apply_type_template1(sharing.clone_value.clone(), "a".to_string()); let b_clone = apply_type_template1(sharing.clone_value.clone(), "b".to_string()); - if (elem_type_str.clone().as_str() == "_".to_string().as_str()) { + 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()) @@ -14438,9 +15092,7 @@ pub fn emit_rust_first_method_call( if (expr_method_name_at( receiver.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "skip".to_string().as_str()) + ) == "skip".to_string()) { { let skip_recv = method_receiver(receiver.clone()); @@ -14678,9 +15330,7 @@ pub fn emit_typed_method_call( if (coerce_primitive_type( RenderTarget::Rust, authored_name_at(si.clone(), param_node_type_expr(p.clone())), - ) - .as_str() - == "serde_json::Value".to_string().as_str()) + ) == "serde_json::Value".to_string()) { __result.push(p); } @@ -14777,7 +15427,7 @@ pub fn emit_typed_method_call( scope.type_env.clone().source_indices.clone(), method_def.clone(), ); - if (method_name.clone().as_str() == "fold".to_string().as_str()) { + if (method_name.clone() == "fold".to_string()) { emit_rust_fold_method_call( method_call_node, fold_accumulator_type.clone(), @@ -14791,7 +15441,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "sort_by".to_string().as_str()) { + if (method_name.clone() == "sort_by".to_string()) { emit_rust_sort_by_method_call( receiver.clone(), args.clone(), @@ -14802,7 +15452,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "map".to_string().as_str()) { + if (method_name.clone() == "map".to_string()) { emit_rust_map_method_call( receiver.clone(), args.clone(), @@ -14816,9 +15466,7 @@ pub fn emit_typed_method_call( match Rc::new({ let mut __result = Vec::new(); for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone().as_str() - == method_name.clone().as_str()) - { + if (s.method_name.clone() == method_name.clone()) { __result.push(s); } } @@ -14838,8 +15486,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ), None => { - if (method_name.clone().as_str() == "get".to_string().as_str()) - { + if (method_name.clone() == "get".to_string()) { emit_rust_get_method_call( receiver.clone(), args.clone(), @@ -14850,9 +15497,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "with".to_string().as_str()) - { + if (method_name.clone() == "with".to_string()) { emit_rust_with_method_call( receiver.clone(), args.clone(), @@ -14863,8 +15508,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "string_contains".to_string().as_str()) + if (method_name.clone() + == "string_contains".to_string()) { emit_rust_generic_method_call( "string_contains".to_string(), @@ -14878,9 +15523,7 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "concat".to_string().as_str()) - { + if (method_name.clone() == "concat".to_string()) { { let recv_str = emit_typed_expr( receiver.clone(), @@ -14917,8 +15560,7 @@ pub fn emit_typed_method_call( ) } } else { - if (method_name.clone().as_str() - == "first".to_string().as_str()) + if (method_name.clone() == "first".to_string()) { emit_rust_first_method_call( receiver.clone(), @@ -15309,8 +15951,8 @@ pub fn emit_typed_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) + let guard_str = if ((field_guards.clone() != "".to_string()) + && (arm_guard_str.clone() != "".to_string())) { v1_rt::concat( v1_rt::concat( @@ -15320,10 +15962,10 @@ pub fn emit_typed_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { + if (field_guards.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { + if (arm_guard_str.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -15585,14 +16227,13 @@ pub fn wrap_rust_record_field_value( field_name: String, ) -> String { { - let is_bounded_lattice_field = - (struct_name.clone().as_str() == "BoundedLattice".to_string().as_str()); + let is_bounded_lattice_field = (struct_name.clone() == "BoundedLattice".to_string()); if rust_record_field_needs_fn_rc(scope.clone(), struct_name.clone(), field_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "meet".to_string().as_str()) - || (field_name.clone().as_str() == "join".to_string().as_str()))) + && ((field_name.clone() == "meet".to_string()) + || (field_name.clone() == "join".to_string()))) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -15606,8 +16247,8 @@ pub fn wrap_rust_record_field_value( v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "top".to_string().as_str()) - || (field_name.clone().as_str() == "bottom".to_string().as_str()))) + && ((field_name.clone() == "top".to_string()) + || (field_name.clone() == "bottom".to_string()))) { v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { @@ -15638,16 +16279,13 @@ pub fn is_already_optional( binding_kind: binding_kind, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) - || (n.clone().as_str() == "Absent".to_string().as_str())) + if (((n.clone() == "Present".to_string()) || (n.clone() == "Absent".to_string())) && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true } else { - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) - { + if ((n.clone() == "none".to_string()) || (n.clone() == "None".to_string())) { true } else { match texpr.inferred.clone().as_deref().cloned() { @@ -15671,8 +16309,8 @@ pub fn is_already_optional( } => match tn { Some(name) => { ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) - && ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str()))) + && ((name.clone() == "Present".to_string()) + || (name.clone() == "Absent".to_string()))) } None => false, }, @@ -15894,7 +16532,7 @@ pub fn emit_field_value_with_context( Some(en) => en.clone(), None => variant_name.clone(), }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + 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()) @@ -16146,10 +16784,15 @@ pub fn emit_typed_record_lit( false }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); - if ((((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != tn.clone().as_str())) + if (((((resolved_type.ident_span.clone() != None) + && (rt_name.clone() != tn.clone())) && !rt_is_type_var) - && (rt_name.clone().as_str() != "Error".to_string().as_str())) + && (rt_name.clone() != "Error".to_string())) + && variant_belongs_to_enum( + emit_info.type_summaries.clone(), + tn.clone(), + rt_name.clone(), + )) { Some(rt_name.clone()) } else { @@ -16161,7 +16804,7 @@ pub fn emit_typed_record_lit( && (is_optional_parent(parent_enum.clone()) || is_optional_parent(effective_parent.clone()))); let rust_tn = if optional_variant.clone() { - if (tn.clone().as_str() == "Present".to_string().as_str()) { + if (tn.clone() == "Present".to_string()) { "Some".to_string() } else { "None".to_string() @@ -16180,8 +16823,7 @@ pub fn emit_typed_record_lit( None => rust_tn, } }; - if ((optional_variant.clone() - && (tn.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() && (tn.clone() == "Present".to_string())) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -16221,8 +16863,8 @@ pub fn emit_typed_record_lit( let is_positional_ctor = (((fields.clone().len() as i64) == 1) && match fields.clone().first().cloned() { Some(f) => { - (field_init_node_name_at(f.clone(), si.clone()).as_str() - == "0".to_string().as_str()) + (field_init_node_name_at(f.clone(), si.clone()) + == "0".to_string()) } None => false, }); @@ -16384,18 +17026,13 @@ pub fn emit_typed_record_lit( &ftm, fname.clone(), ) { - Some(ft) => { - match rust_zero_value( - ft.clone(), - scope - .type_env - .source_indices - .clone(), - ) { - Some(_) => true, - None => false, - } - } + Some(ft) => match rust_zero_value( + ft.clone(), + emit_info.corpus_repr.clone(), + ) { + Some(_) => true, + None => false, + }, None => false, }; (has_zv.clone() @@ -16419,10 +17056,7 @@ pub fn emit_typed_record_lit( Rc::new(vec![v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": None,".to_string())]) } else { match v1_rt::map_get(&ftm, fname.clone()) { - Some(ft) => match rust_zero_value( - ft.clone(), - scope.type_env.source_indices.clone(), - ) { + Some(ft) => match rust_zero_value(ft.clone(), emit_info.corpus_repr.clone()) { Some(zv) => Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), emit_ident(fname.clone(), RenderTarget::Rust)), ": ".to_string()), zv.clone()), ",".to_string())]), None => Rc::new(vec![]), }, @@ -16438,7 +17072,48 @@ pub fn emit_typed_record_lit( } None => Rc::new(vec![]), }; - let all_field_strs = v1_rt::concat(field_strs, default_strs); + let phantom_strs = match lookup_type_by_name( + scope.type_env.clone(), + tn.clone(), + ) { + Some(struct_decl) => { + let is_struct = (struct_decl.connective.clone() + == Connective::Conj); + let pnames = Rc::new({ + let mut __result = Vec::new(); + for p in struct_decl.params.clone().iter().cloned() + { + __result.push(generic_param_name_at( + p.clone(), + si.clone(), + )); + } + __result + }); + let unused = struct_unused_param_names( + pnames, + struct_decl.children.clone(), + si.clone(), + ); + let has_unused = ((unused.len() as i64) > 0); + if (is_struct && has_unused) { + Rc::new(vec![v1_rt::concat( + v1_rt::concat( + " ".to_string(), + rust_phantom_field_name(), + ), + ": std::marker::PhantomData,".to_string(), + )]) + } else { + Rc::new(vec![]) + } + } + None => Rc::new(vec![]), + }; + let all_field_strs = v1_rt::concat( + v1_rt::concat(field_strs, default_strs), + phantom_strs, + ); let fields_str = all_field_strs.join(&"\n".to_string()); let raw = v1_rt::concat( v1_rt::concat( @@ -16458,18 +17133,15 @@ pub fn emit_typed_record_lit( } } -pub fn rust_zero_value( - type_name: String, - source_indices: Rc>>, -) -> Option { - if (type_name.clone().as_str() == "Int".to_string().as_str()) { +pub fn rust_zero_value(type_name: String, corpus_repr: RustCorpusRepr) -> Option { + if (type_name.clone() == "Int".to_string()) { Some("0".to_string()) } else { - if (type_name.clone().as_str() == "Bool".to_string().as_str()) { + if (type_name.clone() == "Bool".to_string()) { Some("false".to_string()) } else { - if (type_name.clone().as_str() == "String".to_string().as_str()) { - if rust_emit_faithful_text_carrier(source_indices) { + if (type_name.clone() == "String".to_string()) { + if corpus_repr_is_faithful(corpus_repr) { Some( "crate::v2_std_algebra::freemonoid_empty::()" .to_string(), @@ -16537,8 +17209,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - scope.type_env.clone().source_indices.clone(), + l_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16551,8 +17223,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), - scope.type_env.clone().source_indices.clone(), + r_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16584,12 +17256,8 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + l_str, + emit_info.corpus_repr.clone(), ), ), " ".to_string(), @@ -16599,8 +17267,8 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), - scope.type_env.clone().source_indices.clone(), + r_str, + emit_info.corpus_repr.clone(), ), ), ")".to_string(), @@ -16733,7 +17401,7 @@ pub fn emit_typed_string_interp( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (a.clone() != "".to_string()) { __result.push(a); } } @@ -16742,7 +17410,7 @@ pub fn emit_typed_string_interp( if ((args.clone().len() as i64) == 0) { emit_rust_host_to_dag_string_via_seam( v1_rt::concat(v1_rt::concat("\"".to_string(), fmt_str), "\"".to_string()), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } else { { @@ -16758,7 +17426,7 @@ pub fn emit_typed_string_interp( ), ")".to_string(), ), - scope.type_env.clone().source_indices.clone(), + emit_info.corpus_repr.clone(), ) } } @@ -16919,9 +17587,7 @@ pub fn emit_tco_init_stmt( if (param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + ) == n.clone()) { __found = true; break; @@ -17275,9 +17941,7 @@ pub fn emit_rust_tco_let( if (param_node_name_at( p.clone(), frame.scope.clone().type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + ) == n.clone()) { __found = true; break; @@ -17564,8 +18228,8 @@ pub fn emit_typed_tco_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) + let guard_str = if ((field_guards.clone() != "".to_string()) + && (arm_guard_str.clone() != "".to_string())) { v1_rt::concat( v1_rt::concat( @@ -17575,10 +18239,10 @@ pub fn emit_typed_tco_match_arm( arm_guard_str.clone(), ) } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { + if (field_guards.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { + if (arm_guard_str.clone() != "".to_string()) { v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) } else { "".to_string() @@ -17648,10 +18312,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()).as_str() - == var_name.clone().as_str()) - } + } => (expr_var_name_at(node.clone(), source_indices.clone()) == var_name.clone()), _ => { let mut __found = false; for c in node.children.clone().iter().cloned() { @@ -17838,6 +18499,7 @@ pub fn emit_service_def( item: Rc, registry: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -17857,6 +18519,7 @@ pub fn emit_service_def( op_children.clone(), registry, shared_types, + corpus_repr, env.clone(), item.clone(), ); @@ -17936,6 +18599,7 @@ pub fn emit_service_impl( op_children: Rc>>, registry: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -17958,6 +18622,7 @@ pub fn emit_service_impl( registry.clone(), (depth.clone() + 1), shared_types.clone(), + corpus_repr.clone(), env.clone(), service_item.clone(), )); @@ -18023,7 +18688,7 @@ pub fn emit_service_new_method( }, None => "".to_string(), }; - let base_url_default = if (from_config.clone().as_str() != "".to_string().as_str()) { + let base_url_default = if (from_config.clone() != "".to_string()) { from_config.clone() } else { if fs.has_rest.clone() { @@ -18048,7 +18713,7 @@ pub fn emit_service_new_method( } else { "".to_string() }; - if (from_fallback.clone().as_str() != "".to_string().as_str()) { + if (from_fallback.clone() != "".to_string()) { from_fallback.clone() } else { "http://localhost".to_string() @@ -18116,7 +18781,7 @@ pub fn emit_auth_source_ctor( ) -> String { match (*source_expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { - Some(variant) => if (variant.clone().as_str() == "EnvVar".to_string().as_str()) { + 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()) }, @@ -18160,6 +18825,7 @@ pub fn emit_operation_method( registry: Rc>>, depth: i64, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, service_item: Rc, ) -> String { @@ -18180,15 +18846,17 @@ pub fn emit_operation_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -18196,6 +18864,7 @@ pub fn emit_operation_method( let ret_type = render_rust_type( resolved_type(op_node.clone()), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), ); let eff_transport = effective_operation_transport(op_node.clone(), transport); @@ -18210,6 +18879,7 @@ pub fn emit_operation_method( op_node.clone(), env.source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), ); let mock_props = Rc::new({ @@ -18233,6 +18903,7 @@ pub fn emit_operation_method( op_node.clone(), env.clone(), shared_types.clone(), + corpus_repr.clone(), ); let body = v1_rt::concat( v1_rt::concat( @@ -18314,6 +18985,7 @@ pub fn emit_dry_run_branch_from_props( op_node: Rc, env: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, ) -> String { { let log_line = v1_rt::concat( @@ -18351,7 +19023,7 @@ let prelude = match wire_opt.clone() { 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, source_indices.clone())), " = serde_json::from_str(r#\"".to_string()), mock_json), "\"#)?;\n".to_string()) +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()) } }, None => v1_rt::concat(v1_rt::concat("let json_body: serde_json::Value = serde_json::from_str(r#\"".to_string(), mock_json), "\"#)?;\n".to_string()), @@ -18370,7 +19042,7 @@ let raw = match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed dry-run: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for mock field: ".to_string()), ch_name.clone()), "\");".to_string()), }; @@ -18393,13 +19065,6 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con } } } else { - // HAND-APPLIED-REGEN-MIRROR-SYNC of src/v1/05_emit_rust.dag (the single - // authority): compile_error! -> panic! in the dry-run missing-fixture branch. - // Applied by hand because regen-fixpoint is temporarily broken (§7 hole). - // DISSOLUTION lane: bright-stag's adhoc-1bdd0259-2e3 (re-repair the hole + add a - // regen-equals-committed CI drift-gate). When it lands, a clean regen reproduces - // this line from the .dag — delete this hand-patch; the dissolution check is - // regen-output == this mirror modulo HAND-APPLIED-REGEN-MIRROR-SYNC comment blocks. v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -18424,6 +19089,7 @@ pub fn emit_transport_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { if is_rest_transport(transport.clone(), source_indices.clone()) { @@ -18436,6 +19102,7 @@ pub fn emit_transport_call( op_node, source_indices.clone(), shared_types, + corpus_repr, env, ) } else { @@ -18447,6 +19114,7 @@ pub fn emit_transport_call( depth, inferred, op_node, + corpus_repr, source_indices.clone(), ) } else { @@ -18468,6 +19136,7 @@ pub fn emit_rest_call( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -18482,7 +19151,11 @@ pub fn emit_rest_call( http_method, source_indices.clone(), ); - let query_line = emit_rest_query_line(transport.clone(), source_indices.clone()); + let query_line = emit_rest_query_line( + transport.clone(), + corpus_repr.clone(), + source_indices.clone(), + ); let body_line = emit_rest_body_line(transport.clone(), source_indices.clone()); let headers = transport_headers(transport.clone(), source_indices.clone()); let header_lines = Rc::new({ @@ -18515,6 +19188,7 @@ pub fn emit_rest_call( transport.clone(), source_indices.clone(), shared_types, + corpus_repr.clone(), env, ); let all_lines = Rc::new({ @@ -18529,7 +19203,7 @@ pub fn emit_rest_call( .iter() .cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -18774,6 +19448,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_rest_query_line( transport: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match transport_query(transport, source_indices.clone()) { @@ -18796,7 +19471,7 @@ pub fn emit_rest_query_line( RenderTarget::Rust, source_indices.clone(), ), - source_indices.clone(), + corpus_repr.clone(), ), ), ")".to_string(), @@ -18859,7 +19534,7 @@ pub fn has_response_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 9) { false } else { - (v1_rt::substring(&name, 0, 9).as_str() == "response_".to_string().as_str()) + (v1_rt::substring(&name, 0, 9) == "response_".to_string()) } } @@ -18870,8 +19545,8 @@ pub fn child_from_key( match Rc::new({ let mut __result = Vec::new(); for p in ch.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "from_key".to_string()) { __result.push(p); } @@ -18925,8 +19600,8 @@ pub fn has_response_200_property( { let mut __found = false; for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "response_200".to_string()) { __found = true; break; @@ -18944,8 +19619,8 @@ pub fn operation_response_200_resolved_type( match Rc::new({ let mut __result = Vec::new(); for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "response_200".to_string()) { __result.push(p); } @@ -18964,7 +19639,7 @@ pub fn operation_response_200_resolved_type( source_indices.clone(), normalize_access_type_node(v.clone()), ); - if (type_name.clone().as_str() == "".to_string().as_str()) { + if (type_name.clone() == "".to_string()) { None } else { lookup_type_by_name(env, type_name.clone()) @@ -18982,7 +19657,7 @@ pub fn is_json_wire_declaration_type( ) -> bool { { let n = authored_name_at(source_indices, normalize_access_type_node(t)); - if (n.clone().as_str() == "Json".to_string().as_str()) { + if (n.clone() == "Json".to_string()) { true } else { { @@ -18993,7 +19668,7 @@ pub fn is_json_wire_declaration_type( .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone().as_str() == "Json".to_string().as_str()), + Some(last) => (last.clone() == "Json".to_string()), None => false, } } @@ -19044,7 +19719,7 @@ pub fn wire_child_for_segment( Some(k) => k.clone(), None => authored.clone(), }; - (wire_key.clone().as_str() == seg.clone().as_str()) + (wire_key.clone() == seg.clone()) } { __result.push(ch); } @@ -19160,7 +19835,7 @@ pub fn emit_wire_struct_path_chain( .iter() .cloned() { - if (s.clone().as_str() != "".to_string().as_str()) { + if (s.clone() != "".to_string()) { __result.push(s); } } @@ -19226,6 +19901,7 @@ pub fn emit_json_value_extract( var_name: String, from_path: String, dag_type_name: String, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19247,9 +19923,8 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); - let is_dag_string = dag_type_name.as_str() == "String"; - let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); - let accessor = if is_dag_string { + let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name.clone()); + let accessor = if (dag_type_name.clone() == "String".to_string()) { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19257,7 +19932,7 @@ pub fn emit_json_value_extract( ".and_then(|v| v.as_str()).map(|s| ".to_string(), emit_rust_host_to_dag_string_via_seam( "s.to_string()".to_string(), - source_indices.clone(), + corpus_repr, ), ), ").ok_or(\"missing field: ".to_string(), @@ -19267,7 +19942,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "i64".to_string().as_str()) { + if (rust_type.clone() == "i64".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_i64()).ok_or(\"missing field: ".to_string(), @@ -19276,7 +19951,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "f64".to_string().as_str()) { + if (rust_type.clone() == "f64".to_string()) { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_f64()).ok_or(\"missing field: ".to_string(), @@ -19285,7 +19960,7 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "bool".to_string().as_str()) { + 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(), @@ -19322,6 +19997,7 @@ pub fn emit_from_key_extraction( op_node: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19359,6 +20035,7 @@ pub fn emit_from_key_extraction( render_rust_type( wire_ty, shared_types, + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19388,7 +20065,7 @@ match ch.inferred.clone().as_deref().cloned() { None => v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"REST typed response: response_200 wire type missing despite typed projection; illegal state\");\n".to_string()), } } else { - emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), source_indices.clone()) + emit_json_value_extract(field_name.clone(), from_path.clone(), authored_name_at(source_indices.clone(), tn.clone()), corpus_repr.clone(), source_indices.clone()) }, _ => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), field_name.clone()), " = compile_error!(\"unresolved type for output field: ".to_string()), ch_name.clone()), "\");".to_string()), } @@ -19443,8 +20120,7 @@ pub fn emit_plain_response_body( { let is_text = match transport_response_format(transport, source_indices.clone()) { Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()).as_str() - == "Text".to_string().as_str()) + (authored_name_at(source_indices.clone(), fmt.clone()) == "Text".to_string()) } None => false, }; @@ -19461,6 +20137,7 @@ pub fn emit_response_code_handling( transport: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -19480,6 +20157,7 @@ pub fn emit_response_code_handling( op_node.clone(), source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), ) } else { @@ -19497,6 +20175,7 @@ pub fn emit_response_code_handling( transport.clone(), source_indices.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), )); } @@ -19528,21 +20207,22 @@ pub fn emit_response_arm( transport: Rc, source_indices: Rc>>, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 9, v1_rt::string_length(&name)); let is_success = if (v1_rt::string_length(&code_str) >= 1) { - (v1_rt::substring(&code_str, 0, 1).as_str() == "2".to_string().as_str()) + (v1_rt::substring(&code_str, 0, 1) == "2".to_string()) } else { false }; - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (code_str.clone() == "nonzero".to_string()) { "_".to_string() } else { if ((v1_rt::string_length(&code_str) == 3) - && (v1_rt::substring(&code_str, 1, 3).as_str() == "xx".to_string().as_str())) + && (v1_rt::substring(&code_str, 1, 3) == "xx".to_string())) { { let prefix = v1_rt::substring(&code_str, 0, 1); @@ -19570,6 +20250,7 @@ pub fn emit_response_arm( op_node, source_indices.clone(), shared_types, + corpus_repr, env, ), ), @@ -19597,13 +20278,14 @@ pub fn has_exit_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5).as_str() == "exit_".to_string().as_str()) + (v1_rt::substring(&name, 0, 5) == "exit_".to_string()) } } pub fn emit_exit_code_handling( op_node: Rc, inferred: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19623,8 +20305,8 @@ pub fn emit_exit_code_handling( let has_nonzero = { let mut __found = false; for p in exit_props.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "exit_nonzero".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "exit_nonzero".to_string()) { __found = true; break; @@ -19638,6 +20320,7 @@ pub fn emit_exit_code_handling( __result.push(emit_exit_arm( p.clone(), inferred.clone(), + corpus_repr.clone(), source_indices.clone(), )); } @@ -19646,16 +20329,7 @@ pub fn emit_exit_code_handling( let default_arm = if has_nonzero { "".to_string() } else { - v1_rt::concat( - v1_rt::concat( - "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), - emit_rust_host_to_dag_string_via_seam( - "stderr".to_string(), - source_indices.clone(), - ), - ), - ") },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr.clone())), ") },".to_string()) }; v1_rt::concat( v1_rt::concat( @@ -19678,17 +20352,18 @@ pub fn emit_exit_code_handling( pub fn emit_exit_arm( prop: Rc, inferred: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 5, v1_rt::string_length(&name)); - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (code_str.clone() == "nonzero".to_string()) { "_".to_string() } else { code_str.clone() }; - let is_success = (code_str.clone().as_str() == "0".to_string().as_str()); + let is_success = (code_str.clone() == "0".to_string()); if is_success { v1_rt::concat( v1_rt::concat( @@ -19701,22 +20376,7 @@ pub fn emit_exit_arm( " },".to_string(), ) } else { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(" ".to_string(), pattern), - " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string(), - ), - emit_rust_host_to_dag_string_via_seam( - "stderr".to_string(), - source_indices.clone(), - ), - ), - ") },".to_string(), - ), - "".to_string(), - ) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(".to_string()), emit_rust_host_to_dag_string_via_seam("stderr".to_string(), corpus_repr)), ") },".to_string()) } } } @@ -19728,6 +20388,7 @@ pub fn emit_shell_call( depth: i64, inferred: Rc, op_node: Rc, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { { @@ -19772,6 +20433,7 @@ pub fn emit_shell_call( emit_shell_argv_element( first_arg.clone(), optional_params.clone(), + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19813,6 +20475,7 @@ pub fn emit_shell_call( emit_shell_argv_element( arg.clone(), optional_params.clone(), + corpus_repr.clone(), source_indices.clone(), ), ), @@ -19873,8 +20536,12 @@ pub fn emit_shell_call( let wait_line = "let output = output.wait_with_output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = - emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); + let return_line = emit_exit_code_handling( + op_node.clone(), + inferred, + corpus_repr.clone(), + source_indices.clone(), + ); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![ @@ -19894,8 +20561,12 @@ pub fn emit_shell_call( let output_line = " .output()?;".to_string(); let check_line = "let stdout = String::from_utf8_lossy(&output.stdout).to_string();".to_string(); - let return_line = - emit_exit_code_handling(op_node.clone(), inferred, source_indices.clone()); + let return_line = emit_exit_code_handling( + op_node.clone(), + inferred, + corpus_repr.clone(), + source_indices.clone(), + ); let all_lines = v1_rt::concat( v1_rt::concat(v1_rt::concat(Rc::new(vec![cmd_line]), arg_lines), env_lines), Rc::new(vec![wd_line, output_line, check_line, return_line]), @@ -19909,6 +20580,7 @@ pub fn emit_shell_call( pub fn emit_shell_argv_element( arg: Rc, optional_params: Rc>, + corpus_repr: RustCorpusRepr, source_indices: Rc>>, ) -> String { match (*arg.expr_data.clone()).clone() { @@ -20007,10 +20679,10 @@ pub fn emit_shell_argv_element( if is_opt.clone() { emit_rust_dag_string_to_host_via_seam( v1_rt::concat(var_name.clone(), ".as_deref().unwrap_or(\"\")".to_string()), - source_indices.clone(), + corpus_repr, ) } else { - emit_rust_dag_string_to_host_via_seam(var_name.clone(), source_indices.clone()) + emit_rust_dag_string_to_host_via_seam(var_name.clone(), corpus_repr) } } _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), @@ -20077,7 +20749,7 @@ pub fn emit_shell_return( } __result }); - let lines = if (stderr_line.clone().as_str() != "".to_string().as_str()) { + let lines = if (stderr_line.clone() != "".to_string()) { v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() @@ -20104,13 +20776,13 @@ pub fn emit_shell_return( pub fn emit_shell_channel_expr(channel: String, is_optional: bool) -> String { { - let base = if (channel.clone().as_str() == "exit_success".to_string().as_str()) { + let base = if (channel.clone() == "exit_success".to_string()) { "output.status.success()".to_string() } else { - if (channel.clone().as_str() == "stderr".to_string().as_str()) { + if (channel.clone() == "stderr".to_string()) { "stderr.clone()".to_string() } else { - if (channel.clone().as_str() == "stdout_lines".to_string().as_str()) { + if (channel.clone() == "stdout_lines".to_string()) { "Rc::new(stdout.lines().filter(|l| !l.is_empty()).map(|l| l.trim().to_string()).collect())".to_string() } else { "stdout.clone()".to_string() @@ -20182,6 +20854,7 @@ pub fn emit_local_call(op_name: String) -> String { pub fn emit_resource_def( item: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20204,6 +20877,7 @@ pub fn emit_resource_def( __result.push(emit_capability_method( c.clone(), shared_types.clone(), + corpus_repr.clone(), env.clone(), )); } @@ -20234,6 +20908,7 @@ pub fn emit_resource_def( pub fn emit_capability_method( cap_node: Rc, shared_types: Rc>, + corpus_repr: RustCorpusRepr, env: Rc, ) -> String { { @@ -20252,15 +20927,17 @@ pub fn emit_capability_method( param_node_type_expr(p.clone()), Rc::new(vec![]), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (params_str.clone() == "".to_string()) { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -20268,6 +20945,7 @@ pub fn emit_capability_method( let ret = render_rust_type( resolved_type(cap_node.clone()), shared_types.clone(), + corpus_repr.clone(), env.source_indices.clone(), ); let items = rust_items(); @@ -20356,10 +21034,11 @@ pub fn emit_data_def( let raw_ty_str = render_rust_type_with_applied_binding( render_type_node, shared_types.clone(), + emit_info.corpus_repr.clone(), scope.type_env.clone().source_indices.clone(), ); - let ty_str = if ((raw_ty_str.clone().as_str() == "BoundedLattice".to_string().as_str()) - || (raw_ty_str.clone().as_str() == "Rc".to_string().as_str())) + let ty_str = if ((raw_ty_str.clone() == "BoundedLattice".to_string()) + || (raw_ty_str.clone() == "Rc".to_string())) { match field_value_by_name( value.clone(), @@ -20371,12 +21050,10 @@ pub fn emit_data_def( scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); - if (top_type_name.clone().as_str() == "".to_string().as_str()) { + if (top_type_name.clone() == "".to_string()) { raw_ty_str.clone() } else { - if (raw_ty_str.clone().as_str() - == "Rc".to_string().as_str()) - { + if (raw_ty_str.clone() == "Rc".to_string()) { v1_rt::concat( v1_rt::concat( "Rc { let lattice_value = field_value_by_name( @@ -20678,38 +21356,31 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( + v1_rt::concat( + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + v1_rt::concat( + "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), ), + "\"".to_string(), ), - "\"".to_string(), + emit_info.corpus_repr.clone(), ), - scope - .type_env - .clone() - .source_indices - .clone(), - ), - ), - v1_rt::concat( - v1_rt::concat( - ", ".to_string(), - val_str.clone(), ), - ");".to_string(), + ", ".to_string(), ), + val_str.clone(), ), - "".to_string(), + ");".to_string(), ) }); } @@ -20785,13 +21456,18 @@ pub fn emit_data_def_body( pub fn emit_test_file( module_name: String, projections: Rc>>, + corpus_repr: RustCorpusRepr, ) -> Rc { { let depth = 0; let test_fns = Rc::new({ let mut __result = Vec::new(); for p in projections.iter().cloned() { - __result.push(emit_operation_test(p.clone(), (depth.clone() + 1))); + __result.push(emit_operation_test( + p.clone(), + (depth.clone() + 1), + corpus_repr.clone(), + )); } __result }); @@ -20842,13 +21518,16 @@ pub fn emit_test_file( } } -pub fn rust_test_signature_comment(projection: Rc) -> String { +pub fn rust_test_signature_comment( + projection: Rc, + corpus_repr: RustCorpusRepr, +) -> String { { let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), + bindings: v1_rt::rc_empty_map::>(), recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::>>>(), source_indices: projection.source_indices.clone(), intern_table: empty_intern_table(), }); @@ -20864,7 +21543,9 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { param_node_type_expr(p.clone()), Rc::new(vec![]), v1_rt::rc_empty_set::(), + corpus_repr.clone(), projection.source_indices.clone(), + v1_rt::rc_empty_map::(), stub_env.clone(), ), )); @@ -20901,7 +21582,11 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { } } -pub fn emit_operation_test(projection: Rc, depth: i64) -> String { +pub fn emit_operation_test( + projection: Rc, + depth: i64, + corpus_repr: RustCorpusRepr, +) -> String { { let test_name = rust_test_name(projection.clone()); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -20918,12 +21603,12 @@ pub fn emit_operation_test(projection: Rc, depth: i64) -> String __result }); let args_str = param_args.join(&", ".to_string()); - let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { + let call_args = if (args_str.clone() == "".to_string()) { "".to_string() } else { 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())), "\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.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()) } } @@ -21019,6 +21704,9 @@ pub fn emit_cargo_dep(name: String, version: String, features: Rc>) pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { { + // HAND-SYNCED MIRROR drift fix: inline the [package] header instead of + // importing render_cargo_package_header_prefix from the deliberately- + // unwired extdeps_cargo_version orphan (byte-identical to committed emit). let header = v1_rt::concat( v1_rt::concat("[package]\nname = \"".to_string(), crate_name), "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n".to_string(), @@ -21121,8 +21809,8 @@ pub fn resolve_param_default( ItemKind::DataItem => match Rc::new({ let mut __result = Vec::new(); for i in module_items.iter().cloned() { - if (authored_name_at(source_indices.clone(), i.clone()).as_str() - == authored_name_at(source_indices.clone(), dv.clone()).as_str()) + if (authored_name_at(source_indices.clone(), i.clone()) + == authored_name_at(source_indices.clone(), dv.clone())) { __result.push(i); } @@ -21332,9 +22020,7 @@ pub fn find_resource_module(resource_name: String, modules: Rc String { { - let about_attr = if (about.clone().as_str() != "".to_string().as_str()) { + let about_attr = if (about.clone() != "".to_string()) { v1_rt::concat( v1_rt::concat(", about = \"".to_string(), about.clone()), "\"".to_string(), @@ -21907,11 +22592,18 @@ pub fn emit_cli_param_type_node( if ((n.children.clone().len() as i64) == 0) { { let nname = authored_name_at(source_indices, n.clone()); - let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone().as_str() != nname.clone().as_str()) { - mapped.clone() - } else { + if (nname.clone() == "String".to_string()) { "String".to_string() + } else { + { + let mapped = + coerce_primitive_type(RenderTarget::Rust, nname.clone()); + if (mapped.clone() != nname.clone()) { + mapped.clone() + } else { + "String".to_string() + } + } } } } else { @@ -21982,7 +22674,7 @@ pub fn emit_main_fn( ";".to_string(), ) }; - let body_lines = if (dry_run_line.clone().as_str() == "".to_string().as_str()) { + let body_lines = if (dry_run_line.clone() == "".to_string()) { v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) } else { v1_rt::concat( @@ -22017,15 +22709,7 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat( - v1_rt::concat( - "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" - .to_string(), - " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" - .to_string(), - ), - " },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index a0c3dd4540f..51c0e2cdd2b 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -1,5 +1,25 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.infer +// +// HAND-SYNCED MIRROR (class-3 splice) -- this committed seed is a HAND-SYNCED +// MIRROR of the .dag authority, NOT a regen fixpoint. One of three class-3 +// files (with v1_compiler_emit_rust.rs, v1_compiler_infer_emit_info.rs) spliced +// from a faithful regen of the class-3 .dag onto the committed seed. +// LANE (deferred): regen-fixpoint emitter-self-host (~150-gap) -- wire-all-emitted- +// modules so a clean regen reproduces this committed seed bit-identically (the +// §7 reproduce-fixpoint that licenses deleting src/v1). +// SCOPE: a faithful full regen wires the deliberately-unwired orphan std modules +// (std_measure / std_algebra / std_realization_schedule / std_machine_constraints +// / std_integer / extdeps_version_semver / extdeps_cargo_version) and surfaces +// ~150 latent emitter-completeness gaps (std numeric/measure-tower generic +// emission). They stay UNWIRED here exactly as on main. +// PROVENANCE (#5514 verbatim deferral): "regen-write still emits a non-building +// seed from ~150 emitter-completeness gaps, the clean green regen fixpoint is +// deferred, converges with the Route-A emitter self-host". +// DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host +// -- when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh +// work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// Full detail: carrier mark in v1_compiler_emit_rust.rs. use self::SizeExpr::*; pub use crate::std_algebra::CollectionSizeEffect; @@ -35,13 +55,14 @@ pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_access::AccessCheckResultNode; pub use crate::v1_compiler_infer_access::{check_index_access_node, check_slice_access_node}; pub use crate::v1_compiler_infer_cycle::detect_type_cycles_kahn; +use crate::v1_compiler_infer_emit_info::RustCorpusRepr::{FaithfulFreeMonoid, HostNative}; use crate::v1_compiler_infer_emit_info::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ add_emit_item_summary, build_enum_field_summaries, build_struct_field_summaries, derive_variant_to_enum, empty_emit_graph_info, lookup_emit_type_summary, }; pub use crate::v1_compiler_infer_emit_info::{ - EmitGraphInfo, EmitInfoBuildState, TypeRepr, TypeSummary, + EmitGraphInfo, EmitInfoBuildState, RustCorpusRepr, TypeRepr, TypeSummary, }; pub use crate::v1_compiler_infer_env::{ inductive_fields_for, inductive_fields_list_to_map, is_recursive_type, @@ -163,8 +184,7 @@ use std::collections::HashMap; use std::rc::Rc; pub fn is_witness_type_name(name: String) -> bool { - ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) + ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -547,7 +567,7 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { + if (field_type_name.clone() == parent_name.clone()) { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -575,17 +595,15 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = ((value_type.clone().as_str() - == parent_name.clone().as_str()) + let is_recursive_element = ((value_type.clone() == parent_name.clone()) || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = - if (value_type.clone().as_str() == parent_name.clone().as_str()) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = if (value_type.clone() == parent_name.clone()) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -753,8 +771,8 @@ pub fn namespace_root_from_properties( match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "namespace_root".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "namespace_root".to_string()) { __result.push(p); } @@ -884,8 +902,7 @@ pub fn rejects_string_for_optional_coproduct_field( let expected_is_optional_coproduct = ((expected.return_cardinality.clone() == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); - let got_is_string = - (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); + let got_is_string = (authored_name_at(source_indices, got) == "String".to_string()); (expected_is_optional_coproduct && got_is_string) } } @@ -906,9 +923,7 @@ pub fn record_lit_expected_fields( if (authored_name_at( scope.type_env.clone().source_indices.clone(), v.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { __result.push(v); } @@ -942,9 +957,7 @@ pub fn record_lit_expanded_from_expected( if (((authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -955,9 +968,7 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), expanded.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { Some(expanded.clone()) } else { @@ -969,9 +980,7 @@ pub fn record_lit_expanded_from_expected( if (authored_name_at( scope.type_env.clone().source_indices.clone(), rt.clone(), - ) - .as_str() - == tn.clone().as_str()) + ) == tn.clone()) { Some(rt.clone()) } else { @@ -1015,8 +1024,7 @@ pub fn record_lit_instantiated_fields( Some(tn) => match expected { Some(exp) => { if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - .as_str() - != tn.clone().as_str()) + != tn.clone()) { None } else { @@ -1186,10 +1194,9 @@ pub fn type_node_is_callable(n: Rc) -> bool { pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); + && (v1_rt::substring(&module_name, 0, 3) == "v2.".to_string())); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (v1_rt::substring(&module_name, 0, 13).as_str() - == "v1.compiler.".to_string().as_str())); + && (v1_rt::substring(&module_name, 0, 13) == "v1.compiler.".to_string())); (is_v4 || is_compiler_substrate) } } @@ -1204,13 +1211,11 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (formal_name.clone().as_str() != "".to_string().as_str())) - && (actual_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() != actual_name.clone().as_str())) + && (formal_name.clone() != "".to_string())) + && (actual_name.clone() != "".to_string())) + && (formal_name.clone() != actual_name.clone())) && (structural_carrier_template_name(formal.clone(), source_indices.clone()) - .as_str() - == structural_carrier_template_name(actual.clone(), source_indices.clone()) - .as_str())) + == 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())) } @@ -1225,8 +1230,8 @@ pub fn container_element_nominal_brand_mismatch( ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), formal.clone()).as_str() - == authored_name_at(source_indices.clone(), actual.clone()).as_str())) + && (authored_name_at(source_indices.clone(), formal.clone()) + == authored_name_at(source_indices.clone(), actual.clone()))) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1357,8 +1362,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( scope: Rc, span: Rc, ) -> Rc { - if ((func_name.clone().as_str() == "lookup".to_string().as_str()) - || (func_name.clone().as_str() == "map_get".to_string().as_str())) + if ((func_name.clone() == "lookup".to_string()) || (func_name.clone() == "map_get".to_string())) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1374,7 +1378,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (func_name.clone().as_str() == "lookup".to_string().as_str()) { + if (func_name.clone() == "lookup".to_string()) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1390,7 +1394,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { + if (func_name.clone() == "map_keys".to_string()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1427,7 +1431,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (func_name.clone().as_str() == "map_values".to_string().as_str()) { + if (func_name.clone() == "map_values".to_string()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1465,14 +1469,13 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_union".to_string().as_str())) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + if (((func_name.clone() == "set_insert".to_string()) + || (func_name.clone() == "set_union".to_string())) + || (func_name.clone() == "set_contains".to_string())) { { - let operand_elem = if ((func_name.clone().as_str() - == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + let operand_elem = if ((func_name.clone() == "set_insert".to_string()) + || (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()) @@ -1516,18 +1519,17 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - let union_other_bad = - if (func_name.clone().as_str() == "set_union".to_string().as_str()) { - match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg.clone(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + 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(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1590,9 +1592,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let result_bt = if (func_name.clone() == "set_contains".to_string()) { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1635,9 +1635,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let build_diags = if (func_name.clone() == "set_contains".to_string()) { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1689,7 +1687,7 @@ pub fn method_pipe_map_keys_values_fallback( scope: Rc, span: Rc, ) -> Rc { - if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { + 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.clone()); @@ -1704,7 +1702,7 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (method_name.clone().as_str() == "map_values".to_string().as_str()) { + 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.clone()); @@ -1752,7 +1750,7 @@ pub fn validate_cast( match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (source_name.clone().as_str() == target_name.clone().as_str()) { + if (source_name.clone() == target_name.clone()) { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1880,23 +1878,18 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (scrutinee_name.clone().as_str() - != "Optional".to_string().as_str())); - let optional_coproduct_subject = ((scrutinee_name.clone().as_str() - == "Optional".to_string().as_str()) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))); + && (scrutinee_name.clone() != "Optional".to_string())); + let optional_coproduct_subject = ((scrutinee_name.clone() + == "Optional".to_string()) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((variant_name.clone().as_str() - == "Holds".to_string().as_str()) - || (variant_name.clone().as_str() - == "Violates".to_string().as_str()))); + && ((variant_name.clone() == "Holds".to_string()) + || (variant_name.clone() == "Violates".to_string()))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))) { Some("Optional".to_string()) } else { @@ -2141,7 +2134,7 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { + if (scrut_type_name.clone() == "".to_string()) { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2150,8 +2143,8 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) - && (f.field_name.clone().as_str() == field_name.clone().as_str())) + if ((f.variant_name.clone() == variant_name.clone()) + && (f.field_name.clone() == field_name.clone())) { __result.push(f); } @@ -2279,7 +2272,7 @@ pub fn method_name_is(opt: Option, expected: String) -> bool { if (opt.clone() == None) { false } else { - (opt.clone().unwrap().as_str() == expected.as_str()) + (opt.clone().unwrap() == expected) } } @@ -2293,7 +2286,7 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (n.clone().unwrap().as_str() == name.as_str()) + (n.clone().unwrap() == name) } } } @@ -2367,9 +2360,7 @@ pub fn derive_element_provenance( if (authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - ) - .as_str() - == "".to_string().as_str()) + ) == "".to_string()) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2777,11 +2768,18 @@ pub fn infer_expr( ); match field_type_lookup { Some(field_type) => { - let field_summary = field_summary_for_type( + let field_summary = match field_summary_for_type( base_rt.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(), + field_name.clone(), + ), + }; let fa_texpr = make_named_expr_node( field_name.clone(), Rc::new(ExprData::ExprFieldAccess { @@ -3425,7 +3423,7 @@ pub fn infer_expr( }) } } else { - if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { + if (func_name.clone() == "empty_map".to_string()) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3489,8 +3487,7 @@ match bare_m { } } } else { - if (func_name.clone().as_str() == "empty_set".to_string().as_str()) - { + if (func_name.clone() == "empty_set".to_string()) { { let bare_s = bare_set_node(); match expected.clone() { @@ -3563,13 +3560,12 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = if (func_name.clone().as_str() - == "lookup".to_string().as_str()) - { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = + if (func_name.clone() == "lookup".to_string()) { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4300,9 +4296,7 @@ match bare_s { (authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - ) - .as_str() - == let_name.clone().as_str()) + ) == let_name.clone()) } _ => false, }, @@ -5306,7 +5300,7 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (pn.clone().as_str() == fname.clone().as_str()) { + if (pn.clone() == fname.clone()) { __found = true; break; } @@ -5380,7 +5374,7 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) + let stop = ((is_optional || (next_name.clone() == "".to_string())) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5508,8 +5502,8 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((type_name.clone().unwrap().as_str() - == "Present".to_string().as_str()) + let is_present_ctor = ((type_name.clone().unwrap() == "Present".to_string()) && (local_variant_parent.clone().as_deref() == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { @@ -5848,9 +5838,7 @@ pub fn infer_record_lit( if (field_init_node_name_at( fir.typed_field.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "value".to_string().as_str()) + ) == "value".to_string()) { __result.push(fir); } @@ -5942,7 +5930,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()); - if (mname.as_str() == "count".to_string().as_str()) { + if (mname == "count".to_string()) { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6039,7 +6027,7 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone().as_str() == param_name.clone().as_str()) { + 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 { @@ -6095,9 +6083,7 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "take".to_string().as_str()) - || (mname.clone().as_str() == "skip".to_string().as_str())) - { + if ((mname.clone() == "take".to_string()) || (mname.clone() == "skip".to_string())) { { let receiver = method_receiver(arg_expr.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6108,7 +6094,7 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (rname.as_str() == param_name.clone().as_str()) { + if (rname == param_name.clone()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { @@ -6122,8 +6108,7 @@ pub fn classify_collection_shrink( unreachable!() }; if ((k.clone() > 0) - && (mname.clone().as_str() - == "skip".to_string().as_str())) + && (mname.clone() == "skip".to_string())) { match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { @@ -6166,9 +6151,7 @@ Rc::new(SubValueRelation::StrictSubValue { divisor: d, .. }) => { - if (p.clone().as_str() - == param_name.clone().as_str()) - { + 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 { @@ -6199,8 +6182,7 @@ Rc::new(SubValueRelation::StrictSubValue { ExprData::ExprBinOp { op, .. } => { match op.clone() { BinOp::Add => { - if (mname.clone().as_str() - == "skip".to_string().as_str()) + if (mname.clone() == "skip".to_string()) { { let left = @@ -6321,16 +6303,15 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (lookup_type.clone().as_str() != "".to_string().as_str()) { + if (lookup_type.clone() != "".to_string()) { { 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() { - if ((f.field_name.clone().as_str() == field_label.clone().as_str()) - && ((f.variant_name.clone().as_str() == vname.clone().as_str()) - || (f.variant_name.clone().as_str() - == "".to_string().as_str()))) + if ((f.field_name.clone() == field_label.clone()) + && ((f.variant_name.clone() == vname.clone()) + || (f.variant_name.clone() == "".to_string()))) { __result.push(f); } @@ -6522,7 +6503,7 @@ pub fn resolve_collection_field( } } }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6534,8 +6515,7 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (f.field_name.clone().as_str() == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -6606,12 +6586,12 @@ pub fn resolve_collection_field( } => { let inner_mname = expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); - let is_collection_preserving = (((((inner_mname.clone().as_str() - == "enumerate".to_string().as_str()) - || (inner_mname.clone().as_str() == "skip".to_string().as_str())) - || (inner_mname.clone().as_str() == "take".to_string().as_str())) - || (inner_mname.clone().as_str() == "filter".to_string().as_str())) - || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); + 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 { { let __tco_0 = method_receiver(expr); @@ -6665,7 +6645,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (type_name.clone().as_str() != "".to_string().as_str()) { + if (type_name.clone() != "".to_string()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6745,9 +6725,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option "".to_string(), }, }; - if (inner_type.clone().as_str() - != "".to_string().as_str()) - { + if (inner_type.clone() != "".to_string()) { { let fields = inductive_fields_for( ctx.type_env.clone(), @@ -6892,7 +6868,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if ((elem.clone().as_str() != "".to_string().as_str()) + if ((elem.clone() != "".to_string()) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -7037,7 +7013,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if (left_name.clone().as_str() != "".to_string().as_str()) { + if (left_name.clone() != "".to_string()) { match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -7079,12 +7055,12 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option { - if (mname.clone().as_str() == "skip".to_string().as_str()) { + if (mname.clone() == "skip".to_string()) { { let skip_args = method_arg_nodes(val.clone()); let skip_amount = match skip_args.first().cloned() { @@ -7297,7 +7273,7 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (vname.clone() == param_name.clone()) { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7343,7 +7319,7 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -7487,9 +7463,7 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7533,9 +7507,7 @@ pub fn classify_argument( ((expr_var_name_at( left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7553,9 +7525,7 @@ pub fn classify_argument( ((expr_var_name_at( inner_left.clone(), ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) + ) == param_name.clone()) || (v1_rt::map_get( &ctx.sub_value_vars.clone(), expr_var_name_at( @@ -7697,8 +7667,7 @@ pub fn read_arg_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) - { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -7838,7 +7807,7 @@ pub fn build_call_evidence( } pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { - if (found.clone().as_str() != "".to_string().as_str()) { + if (found.clone() != "".to_string()) { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -7885,7 +7854,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let arg_val = arg_value(child.clone()); match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLambda => { - if (source_type.clone().as_str() != "".to_string().as_str()) { + if (source_type.clone() != "".to_string()) { { let lparams = lambda_param_names_at( arg_val.clone(), @@ -7902,9 +7871,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }; let lambda_ctx = Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (p2.clone().as_str() - != "".to_string().as_str()) - { + param_names: if (p2.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.param_names.clone(), @@ -7915,9 +7882,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { source_type.clone(), ) } else { - if (p1.clone().as_str() - != "".to_string().as_str()) - { + if (p1.clone() != "".to_string()) { v1_rt::rc_map_insert( ctx.param_names.clone(), p1.clone(), @@ -7929,9 +7894,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }, param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: if (p1.clone().as_str() - != "".to_string().as_str()) - { + sub_value_vars: if (p1.clone() != "".to_string()) { { let source_fields = inductive_fields_for( ctx.type_env.clone(), @@ -7959,9 +7922,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { }), None => Rc::new(SubValueRelation::PreservedValue), }; - if (p2.clone().as_str() - != "".to_string().as_str()) - { + if (p2.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_map_insert( ctx.sub_value_vars.clone(), @@ -8100,7 +8061,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Some(t) => t.clone(), None => "".to_string(), }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), @@ -8109,9 +8070,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -8135,8 +8094,8 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "first".to_string().as_str()) - || (mname.clone().as_str() == "last".to_string().as_str())) + if ((mname.clone() == "first".to_string()) + || (mname.clone() == "last".to_string())) { { let receiver = method_receiver(scrut.clone()); @@ -8148,8 +8107,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } _ => None, }; - let scrut_has_inductive = (((scrut_type.clone().as_str() - != "".to_string().as_str()) + let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() as i64) > 0)) @@ -8190,7 +8148,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { + Some(ind_field) => if (vname.clone() == "Present".to_string()) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8214,9 +8172,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == inner_vname.clone()) && (f.field_name.clone() == inner_field_name.clone())) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { + Some(inner_ind_field) => if (inner_bind_name.clone() != "".to_string()) { Rc::new(DescentContext { 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()), @@ -8251,9 +8209,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone() == vname.clone()) && (f.field_name.clone() == field_name.clone())) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { + Some(ind_field) => if (bind_name.clone() != "".to_string()) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8276,7 +8234,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { + MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone() != "".to_string()) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8369,7 +8327,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { + param_names: if (sub_type.clone() != "".to_string()) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8486,9 +8444,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (sub_type.clone().as_str() - != "".to_string().as_str()) - { + param_names: if (sub_type.clone() != "".to_string()) { v1_rt::rc_map_insert( acc.ctx.clone().param_names.clone(), bname.clone(), @@ -8592,7 +8548,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (inner_mname.as_str() == "enumerate".to_string().as_str()) { + if (inner_mname == "enumerate".to_string()) { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8638,7 +8594,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota None => "".to_string(), }, }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (base_type.clone() != "".to_string()) { Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for( @@ -8648,9 +8604,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota .iter() .cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { + if (f.field_name.clone() == fname.clone()) { __result.push(f); } } @@ -8954,9 +8908,7 @@ pub fn infer_output_provenance( |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) - { + if ((pname.clone() != "".to_string()) && (ptype.clone() != "".to_string())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { acc.clone() @@ -9022,7 +8974,7 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (pn.clone().as_str() == vname.clone().as_str()) { + if (pn.clone() == vname.clone()) { __found = true; break; } @@ -9071,7 +9023,7 @@ pub fn classify_body_provenance( } _ => "".to_string(), }; - if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { + if (type_for_lookup.clone() != "".to_string()) { { let fields = inductive_fields_for( type_env.clone(), @@ -9080,9 +9032,7 @@ pub fn classify_body_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == field.clone().as_str()) - { + if (f.field_name.clone() == field.clone()) { __result.push(f); } } @@ -9238,7 +9188,7 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { +if ((bind_name.clone() != "".to_string()) && (field_label.clone() != "".to_string())) { { let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) @@ -9426,7 +9376,7 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (first_pname.clone().as_str() != "".to_string().as_str()) { + if (first_pname.clone() != "".to_string()) { v1_rt::rc_map_insert( v1_rt::rc_empty_map::>(), first_pname.clone(), @@ -9838,8 +9788,8 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((bind_name.clone().as_str() == "".to_string().as_str()) - || (field_label.clone().as_str() == "".to_string().as_str())) + if ((bind_name.clone() == "".to_string()) + || (field_label.clone() == "".to_string())) { c.clone() } else { @@ -9997,8 +9947,8 @@ pub fn compute_variant_provenance( param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) + if ((pname.clone() != "".to_string()) + && (ptype.clone() != "".to_string())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -10049,7 +9999,7 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { + if (enum_name.clone() == parent_enum.clone()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( @@ -10073,7 +10023,7 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (fname.clone().as_str() != "".to_string().as_str()) { + if (fname.clone() != "".to_string()) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -10110,9 +10060,7 @@ pub fn collect_variant_constructors( if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) - .as_str() - == parent_enum.clone().as_str()) + ) == parent_enum.clone()) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() as i64) > 0)) @@ -10396,8 +10344,8 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((ptype.clone().as_str() != "".to_string().as_str()) - && (pname.clone().as_str() != "".to_string().as_str())) + if ((ptype.clone() != "".to_string()) + && (pname.clone() != "".to_string())) { { let fields = inductive_fields_for( @@ -10689,9 +10637,7 @@ pub fn infer_auth_source_properties( if (field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "svc_auth_source".to_string().as_str()) + ) == "svc_auth_source".to_string()) { { let val = field_init_node_value(p.clone()); @@ -11115,11 +11061,10 @@ pub fn infer_items( } pub fn is_type_variable_name(name: String) -> bool { - (((((name.clone().as_str() == "T".to_string().as_str()) - || (name.clone().as_str() == "K".to_string().as_str())) - || (name.clone().as_str() == "V".to_string().as_str())) - || (name.clone().as_str() == "MappedElement".to_string().as_str())) - || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) + (((((name.clone() == "T".to_string()) || (name.clone() == "K".to_string())) + || (name.clone() == "V".to_string())) + || (name.clone() == "MappedElement".to_string())) + || (name.clone() == "FoldAccumulator".to_string())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -11134,7 +11079,7 @@ pub fn type_node_label( ) -> String { { let authored = authored_name_at(source_indices, n.clone()); - if (authored.clone().as_str() != "".to_string().as_str()) { + if (authored.clone() != "".to_string()) { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11159,9 +11104,9 @@ pub fn param_is_generic_decl( }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) - && (pname.clone().as_str() != "".to_string().as_str())) - && ((pname.clone().as_str() == tname.as_str()) - || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) + && (pname.clone() != "".to_string())) + && ((pname.clone() == tname) + || (type_expr_is_var && (pname.clone() == pt.name.clone())))) } } @@ -11184,7 +11129,7 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == bind_name.clone().as_str()) { + if (g.clone() == bind_name.clone()) { __found = true; break; } @@ -11243,9 +11188,9 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); - (((formal_name.clone().as_str() != "".to_string().as_str()) - && (record_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() == record_name.clone().as_str())) + (((formal_name.clone() != "".to_string()) + && (record_name.clone() != "".to_string())) + && (formal_name.clone() == record_name.clone())) } } } @@ -11270,9 +11215,7 @@ pub fn unify_record_lit_field_walk( if (field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == field_name.clone().as_str()) + ) == field_name.clone()) { __result.push(fi); } @@ -11327,7 +11270,7 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == formal_name.clone().as_str()) { + if (g.clone() == formal_name.clone()) { __found = true; break; } @@ -11349,8 +11292,8 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((record_type_name.clone().as_str() != "".to_string().as_str()) - && (formal_name.clone().as_str() == record_type_name.clone().as_str())) + if ((record_type_name.clone() != "".to_string()) + && (formal_name.clone() == record_type_name.clone())) { unify_record_lit_field_walk( record_lit_expected_fields( @@ -11823,9 +11766,6 @@ pub fn build_type_env( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - // §3 single-authority: no implicit std.types base-injection. Resolution - // flows through each module's explicit import graph only (mirrors - // v1.compiler.infer build_type_env in src/v1/04_infer.dag). let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); @@ -11848,7 +11788,7 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12420,8 +12360,7 @@ pub fn build_type_env_unresolved( source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); - // §3 single-authority: no implicit std.types base-injection (mirrors - // build_type_env_unresolved in src/v1/04_infer.dag). + let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); let parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12443,7 +12382,7 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -13357,8 +13296,8 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (dep.clone().as_str() == "None".to_string().as_str())) - || (dep.clone().as_str() == "".to_string().as_str())) + || (dep.clone() == "None".to_string())) + || (dep.clone() == "".to_string())) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13571,9 +13510,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).as_str() == "0".to_string().as_str()) - } + Some(f) => (field_node_name_at(f.clone(), source_indices) == "0".to_string()), None => false, }) } @@ -13700,6 +13637,40 @@ pub fn build_positional_payload_variants( ) } +pub fn rust_corpus_repr(modules: Rc>>) -> RustCorpusRepr { + { + let has_seed = { + let mut __found = false; + 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() + { + if (v1_rt::contains(k.clone(), "/v1/".to_string()) + || v1_rt::contains(k.clone(), "src/v1".to_string())) + { + __found = true; + break; + } + } + __found + } { + __found = true; + break; + } + } + __found + }; + if has_seed { + RustCorpusRepr::HostNative + } else { + RustCorpusRepr::FaithfulFreeMonoid + } + } +} + pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { @@ -13756,6 +13727,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), + corpus_repr: rust_corpus_repr(modules.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 98745ada53b..de4cca9b482 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -1,6 +1,27 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.infer_emit_info +// +// HAND-SYNCED MIRROR (class-3 splice) -- this committed seed is a HAND-SYNCED +// MIRROR of the .dag authority, NOT a regen fixpoint. One of three class-3 +// files (with v1_compiler_emit_rust.rs, v1_compiler_infer.rs) spliced from a +// faithful regen of the class-3 .dag onto the committed seed. +// LANE (deferred): regen-fixpoint emitter-self-host (~150-gap) -- wire-all-emitted- +// modules so a clean regen reproduces this committed seed bit-identically (the +// §7 reproduce-fixpoint that licenses deleting src/v1). +// SCOPE: a faithful full regen wires the deliberately-unwired orphan std modules +// (std_measure / std_algebra / std_realization_schedule / std_machine_constraints +// / std_integer / extdeps_version_semver / extdeps_cargo_version) and surfaces +// ~150 latent emitter-completeness gaps (std numeric/measure-tower generic +// emission). They stay UNWIRED here exactly as on main. +// PROVENANCE (#5514 verbatim deferral): "regen-write still emits a non-building +// seed from ~150 emitter-completeness gaps, the clean green regen fixpoint is +// deferred, converges with the Route-A emitter self-host". +// DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host +// -- when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh +// work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// Full detail: carrier mark in v1_compiler_emit_rust.rs. +use self::RustCorpusRepr::*; use self::TypeRepr::*; pub use crate::v1_compiler_infer_types::{ child_type_node, emit_map_has, node_type_equals, normalize_access_type_node, @@ -62,6 +83,15 @@ pub struct TypeSummary { pub has_fn_fields: bool, } +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum RustCorpusRepr { + HostNative, + FaithfulFreeMonoid, +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EmitGraphInfo { pub type_summaries: Rc>>, @@ -75,6 +105,7 @@ pub struct EmitGraphInfo { pub owned_bindings: Rc>, pub read_only_params_index: Rc>>>, pub read_only_params: Rc>, + pub corpus_repr: RustCorpusRepr, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -96,6 +127,7 @@ pub fn empty_emit_graph_info() -> Rc { read_only_params_index: v1_rt::rc_empty_map::>>( ), read_only_params: v1_rt::rc_empty_set::(), + corpus_repr: RustCorpusRepr::FaithfulFreeMonoid, }) } @@ -453,9 +485,8 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((resolved_name.clone().as_str() != "".to_string().as_str()) - && !ft_is_type_var.clone()) - && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) + if (((resolved_name.clone() != "".to_string()) && !ft_is_type_var.clone()) + && (resolved_name.clone() != "Dynamic".to_string())) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -621,3 +652,6 @@ pub fn add_emit_item_summary( None => state, } } + +pub struct HostNative; +pub struct FaithfulFreeMonoid; diff --git a/src/v1/stage0/src/wire_value_serialize.rs b/src/v1/stage0/src/wire_value_serialize.rs index e5e228ad024..24c49a1de93 100644 --- a/src/v1/stage0/src/wire_value_serialize.rs +++ b/src/v1/stage0/src/wire_value_serialize.rs @@ -149,17 +149,20 @@ fn serialize_variant_to_wire_json( .unwrap_or_else(|| format!("wire policy error for coproduct {type_name}"))); } - if policy_is_untagged(&policy) { + // HAND-SYNCED MIRROR drift fix: the class-3 emit_rust splice takes the wire + // policy by value (Rc), so pass policy.clone() (cheap Rc + // clone) instead of &policy. See the carrier mark in v1_compiler_emit_rust.rs. + if policy_is_untagged(policy.clone()) { return serialize_untagged_variant(fields, ctx); } - if policy_is_string_variant(&policy) { + if policy_is_string_variant(policy.clone()) { let tag = wire_variant_tag_for_policy(variant_name.to_string(), policy.clone()) .ok_or_else(|| format!("no wire tag for string variant {type_name}::{variant_name}"))?; return Ok(serde_json::Value::String(tag)); } - if let Some(tag_field) = policy_serde_tag_field(&policy) { + if let Some(tag_field) = policy_serde_tag_field(policy.clone()) { let wire_tag = wire_variant_tag_for_policy(variant_name.to_string(), policy.clone()) .ok_or_else(|| { format!("no wire tag for internally-tagged variant {type_name}::{variant_name}") @@ -176,7 +179,7 @@ fn serialize_variant_to_wire_json( } // TaggedVariant default: {"_variant": "Name", ...fields} - let tag_key = policy_serde_tag_field(&policy).unwrap_or_else(|| "_variant".to_string()); + let tag_key = policy_serde_tag_field(policy.clone()).unwrap_or_else(|| "_variant".to_string()); let default_tag = if policy.enum_attr == rust_serde_tag_attr() { variant_name.to_string() } else { From 1ca2ab8b662cec2a73eb49bd4f3cd7e832b72962 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Mon, 22 Jun 2026 07:14:46 +0000 Subject: [PATCH 41/61] PATH A carrier-mark: append quick-seal's representation-invariance caveat Comment-only. Append quick-seal's verbatim invariance line to all four carrier marks (regen_stage0.rs registry + the 3 spliced file headers): the class-3 host-vs-faithful selection is representation-invariant on the v1-bundled host seed at this tip (CONTROL B gate-isolated revert builds green; CONTROL A errors are the wire policy confound, not representation), so the selection's behavioral discriminating-proof is OWED by the deferred faithful target where the selection actually fires. Keeps the HAND-SYNCED-MIRROR / not-regen-fixpoint / deferred-~150-lane mark intact. Still cargo-green (0 errors/0 warnings, all 5 bins; fmt --all --check clean). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/v1/stage0/src/bin/regen_stage0.rs | 6 ++++++ src/v1/stage0/src/v1_compiler_emit_rust.rs | 5 +++++ src/v1/stage0/src/v1_compiler_infer.rs | 5 +++++ src/v1/stage0/src/v1_compiler_infer_emit_info.rs | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 98b4dd55282..05ce0786d80 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -137,6 +137,12 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ // DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host -- // when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh // work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// +// INVARIANCE CAVEAT (quick-seal, verbatim): class-3 host-vs-faithful SELECTION is +// representation-invariant on the v1-bundled HOST seed at this tip -- CONTROL B +// (gate-isolated revert) builds green, CONTROL A errors are the wire policy confound +// not representation; the selection's behavioral discriminating-proof is OWED by the +// deferred faithful target, where the selection actually fires. // ========================================================================= const HAND_MAINTAINED_STAGE0_FILES: &[&str] = &[ "cache_purity_oracle.rs", diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index a440313ddf5..0ce63b591f2 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -23,6 +23,11 @@ // DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host // -- when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh // work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// INVARIANCE CAVEAT (quick-seal, verbatim): class-3 host-vs-faithful SELECTION is +// representation-invariant on the v1-bundled HOST seed at this tip -- CONTROL B +// (gate-isolated revert) builds green, CONTROL A errors are the wire policy +// confound not representation; the selection's behavioral discriminating-proof is +// OWED by the deferred faithful target, where the selection actually fires. pub use crate::extdeps_languages_rust_emit::HigherOrderMethodSpec; pub use crate::extdeps_languages_rust_emit::{ diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 51c0e2cdd2b..c93bcd5e7a8 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -19,6 +19,11 @@ // DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host // -- when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh // work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// INVARIANCE CAVEAT (quick-seal, verbatim): class-3 host-vs-faithful SELECTION is +// representation-invariant on the v1-bundled HOST seed at this tip -- CONTROL B +// (gate-isolated revert) builds green, CONTROL A errors are the wire policy +// confound not representation; the selection's behavioral discriminating-proof is +// OWED by the deferred faithful target, where the selection actually fires. // Full detail: carrier mark in v1_compiler_emit_rust.rs. use self::SizeExpr::*; 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 de4cca9b482..315a71c5dae 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -19,6 +19,11 @@ // DISSOLUTION TRIGGER: §7 fixpoint convergence with the Route-A emitter self-host // -- when wire-all-emitted-modules -> regen-equals-committed is in reach; a fresh // work-item gets dispatched THEN. (breadcrumb: node://adhoc-80af9ff8-40f) +// INVARIANCE CAVEAT (quick-seal, verbatim): class-3 host-vs-faithful SELECTION is +// representation-invariant on the v1-bundled HOST seed at this tip -- CONTROL B +// (gate-isolated revert) builds green, CONTROL A errors are the wire policy +// confound not representation; the selection's behavioral discriminating-proof is +// OWED by the deferred faithful target, where the selection actually fires. // Full detail: carrier mark in v1_compiler_emit_rust.rs. use self::RustCorpusRepr::*; From ab174e1af553b8309e02145d9f0615fdf6629255 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 02:40:04 +0000 Subject: [PATCH 42/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/stage0/src/bin/regen_stage0.rs | 45 +++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 05ce0786d80..443f9db35be 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -221,14 +221,29 @@ fn main() -> ExitCode { fn run() -> Result<(), String> { let run_started = Instant::now(); let args: Vec = env::args().skip(1).collect(); + // `--emit-fresh ` runs the assembly phases (emit closure + copy hand- + // maintained periphery + patches + rustfmt) into a STABLE, caller-named dir and + // STOPS -- no copy-back into the committed seed, no temp cleanup. It is the + // non-destructive re-baseline harness for the deferred regen-fixpoint lane + // (carrier mark above): a faithful full regen WIRES every emitted module + // (including the std-tower modules unwired in the committed lib.rs), so the + // assembled crate is the "REAL" emitted seed whose emitter-completeness gaps + // surface as cargo errors. Build it to measure them; the committed seed is + // never touched. + let mut emit_fresh: Option = None; let verify_only = match args.as_slice() { [] => false, [flag] if flag == "--verify" => true, + [flag, dir] if flag == "--emit-fresh" => { + emit_fresh = Some(PathBuf::from(dir)); + false + } unexpected => { return Err(format!( "regen_stage0: unexpected arguments: {unexpected:?}\n\ - Usage: regen_stage0 [--verify]\n\ - Omit flags to write stage0; pass exactly `--verify` to check without writing." + Usage: regen_stage0 [--verify | --emit-fresh ]\n\ + Omit flags to write stage0; pass exactly `--verify` to check without writing;\n\ + pass `--emit-fresh ` to assemble the faithful emitted crate into and stop." )); } }; @@ -238,7 +253,10 @@ fn run() -> Result<(), String> { let workspace = workspace_root(&manifest_dir)?; let receipt_path = bootstrap_timing_receipt_path(&workspace); let stage0_src = manifest_dir.join("src"); - let fresh_dir = temp_dir("v2-regen-stage0-fresh"); + let fresh_dir = match &emit_fresh { + Some(dir) => dir.clone(), + None => temp_dir("v2-regen-stage0-fresh"), + }; let _ = fs::remove_dir_all(&fresh_dir); fs::create_dir_all(fresh_dir.join("src")) .map_err(|e| format!("create {}: {e}", fresh_dir.display()))?; @@ -270,6 +288,27 @@ fn run() -> Result<(), String> { assert_output_set_matches_registry(&stage0_src, &fresh_dir.join("src")) })?; + if emit_fresh.is_some() { + // Non-destructive: leave the assembled crate in place for cargo build. + write_bootstrap_timing_receipt(BootstrapTimingReceiptInput { + path: &receipt_path, + workspace: &workspace, + manifest_dir: &manifest_dir, + verify_only, + status: "completed_emit_fresh", + generated_file_count: GENERATED_STAGE0_FILES.len(), + emitted_file_count: emitted.len(), + phases, + elapsed_ms: elapsed_ms(run_started), + changed_generated_files: Vec::new(), + })?; + println!( + "regen_stage0 --emit-fresh: assembled faithful emitted crate at {}", + fresh_dir.display() + ); + return Ok(()); + } + if verify_only { let verify_result = time_phase(&mut phases, "verify_stage0_matches", || { verify_stage0_matches(&stage0_src, &fresh_dir.join("src")) From 4e4929b04525e9e8ff739cab6c96804db8b610eb Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 03:24:04 +0000 Subject: [PATCH 43/61] Lane A E0308 re-baseline: faithful emitted-seed crate, categorized count Assemble the REAL Route-A crate (emitted seed closure + 22 hand-written periphery modules) via a new non-destructive `regen_stage0 --emit-fresh ` mode and cargo-build it to measure the latent emitter-completeness gaps the committed hand-synced seed hides (std-tower modules unwired in lib.rs). Result: 73 total errors, 38 E0308 -- the carrier-mark "~150 gaps" estimate was stale by ~4x. The 38 E0308 reduce to two emitter root causes (89%): A (24+1) map-literal `&str` keys not coerced to String -> HashMap<&str,V> B (10) missing Box/Rc/Option auto-wrap coercion C (3) scalar &str/String Non-E0308 residue (measure-tower E0560, unwired-periphery E0433) categorized separately with an honest masking caveat. Baseline + reproducer in docs/plans/e0308-rebaseline-route-a.md. Also: --emit-fresh adds im-rc to the assembled Cargo.toml (mirrors committed stage0 deps) so the hand-written v1_interpreter resolves -- removes a spurious E0432 confound from the measurement. Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/plans/e0308-rebaseline-route-a.md | 114 +++++++++++++++++++++++++ src/v1/stage0/src/bin/regen_stage0.rs | 5 +- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 docs/plans/e0308-rebaseline-route-a.md diff --git a/docs/plans/e0308-rebaseline-route-a.md b/docs/plans/e0308-rebaseline-route-a.md new file mode 100644 index 00000000000..aebf8cc99f8 --- /dev/null +++ b/docs/plans/e0308-rebaseline-route-a.md @@ -0,0 +1,114 @@ +# E0308 re-baseline — Route-A last mile (faithful emitted seed) + +Re-baselines the type-mismatch (`E0308`) gap between the **faithful full regen** of the +stage0 seed and `cargo`-green. The carrier mark in `regen_stage0.rs` estimated *"~150 +latent emitter-completeness gaps"* from wiring the std-tower modules; this measures the +real number and **categorizes it by variety** so the deferred regen-fixpoint lane +(`node://adhoc-80af9ff8-40f`) can be scoped from data, not an estimate. + +## What "the REAL crate" is + +The committed stage0 seed is a **hand-synced mirror**, not a regen fixpoint: it +deliberately leaves several std-tower modules **unwired** in `lib.rs` +(`std_measure` / `std_integer` / `std_machine_constraints` / +`std_realization_schedule` / `extdeps_version_semver` / `extdeps_cargo_version`). A +*faithful* full regen — emitting from the `.dag` authorities and wiring **every** +emitted module — is what surfaces the latent gaps. + +The REAL crate = the **emitted seed closure** (108 modules from `compile_stage0` +over `src/v1` + `dsl`) **+ the 22 hand-written periphery modules** copied verbatim +(`v1_interpreter` / `cli_run` / `v1_rt` / lens-kernel project modules / `wire_value_serialize` +/ `v1_compiler_dag_collect{,_support}`). + +## Reproduce + +A non-destructive harness mode assembles that crate without touching the committed +seed (`src/v1/stage0/src/bin/regen_stage0.rs`): + +``` +cargo build -p v1-compiler --bin regen_stage0 +./target/debug/regen_stage0 --emit-fresh # ~20 min: full v1-seed self-compile +cd +RUSTC_WRAPPER="" cargo build --message-format=json --lib > build.json 2>&1 + +# error-code histogram (total + E0308 share): +grep -oE '"code":"E[0-9]{4}"' build.json | sort | uniq -c | sort -rn + +# E0308 categorized by expected -> found type pair (one pair per diagnostic; sums to 38). +# `scan(...)[0]` takes the first occurrence so the per-diagnostic note doesn't double-count; +# the lone "" is a HashMap<&str> case whose label wraps across lines (family A). +jq -r 'select(.reason=="compiler-message") | .message | select(.code.code=="E0308") + | ([.rendered | scan("expected `[^`]+`, found `[^`]+`")][0]) // ""' build.json \ + | sort | uniq -c | sort -rn +``` + +`--emit-fresh` runs the same assembly phases as a normal regen (emit closure → copy +periphery → patches → rustfmt) into a caller-named dir and **stops** — no copy-back, no +temp cleanup. The committed seed is never mutated. (`RUSTC_WRAPPER=""` bypasses the +`sccache` wrapper, which is unrelated infra and flaked on a dep compile during this +measurement.) + +## Baseline (faithful emitted seed @ this branch tip) + +`cargo build --lib` on the assembled crate: **73 total errors**, of which **38 are +`E0308`**. (The "~150" estimate was stale by ~4×.) + +### E0308 by root cause — 2 emitter causes cover 89% + +| n | family | root cause | fix locus | +|---|--------|-----------|-----------| +| **24** (+1 multi-line-label variant = **25**) | **A — map-literal `&str` key** | emitter writes map **keys** as bare `&str` literals (`__m.insert("true", …)`) without `.to_string()`; the values *do* get `.to_string()`, so the map infers `HashMap<&str, V>` against the declared `HashMap` | map-literal emission (one fix → −25 E0308, 66%) | +| **10** | **B — Box/Rc/Option wrap** | auto-wrap/unwrap coercion not inserted: `Box`↔`String` (5+2), `Rc` vs `Option>` missing `Some()` (3) | coercion-insertion at call/construct sites | +| **3** | **C — scalar `&str`/`String`** | string literal not `.to_string()` in scalar position | same coercion path as A, scalar arm | + +The dominant lever is **family A** — a single emitter change (coerce map-literal keys to +`String`) clears ~two-thirds of all `E0308`. Worst files: `v1_compiler_stage0_crates.rs` +(6), `std_types.rs` (5), `extdeps_languages_dag_syntax.rs` (4). + +### Raw categorizer output (expected → found, top pairs) + +``` + 10 HashMap => HashMap<&str, String> + 7 HashMap => HashMap<&str, bool> + 5 Box => String + 3 &str => String + 2 HashMap> => HashMap<&str, Rc> + 3 Rc => Option> (SemVerIdentifier/ScheduleWitnessEntry/Runnable) + 1 i64 => Box + 1 String => Box + + 5 further HashMap => HashMap<&str,V> singletons (AlgebraProfile, TokenShape, NodeFieldRole, FunctionSizeEffect, i64) +``` + +## Non-E0308 context (the other 35 errors) — distinct classes, separate owners + +These do **not** count as E0308 but block green, and two classes **mask** an unknown +number of additional E0308 (see caveat): + +| n | code | class | where | +|---|------|-------|-------| +| 12 | E0560 | **measure-tower field emission** — `Rc> has no field count` | all `std_measure.rs` | +| 8 | E0433 | **unwired periphery** — `inert_carrier_project` / `non_fold_residue_project` not declared in emitted `lib.rs` (regen patch-list is stale vs the 3 newest `HAND_MAINTAINED` modules) | `v1_interpreter.rs` | +| 5 | E0425 | unresolved fn/type (`v1_rt::utf8_decode_bytes`, `SemVerConstraint`) | `extdeps_cargo.rs`, `v1_interpreter.rs`, `v1_probe_emit_interp.rs` | +| 2 | E0573 | `Time` variant used as type | `std_realization_schedule.rs` | +| 2 | E0599 | `clone` on unconstrained type param | `std_measure.rs`, `std_types.rs` | +| 2 | E0091 | unused type param (`Algebra` / `MachineConstraint`) | `std_machine_constraints.rs` | +| 1 each | E0277 / E0252 / E0107 / E0063 | std-tower generic-emission residue | `std_types` / `std_realization_schedule` / `std_termination` | + +### Honesty caveat (masking) + +The **38 is a lower bound**. `E0433` (8, in `v1_interpreter`) and `E0425` (5) are +*resolution* failures — `rustc` aborts type-checking in those regions, so any `E0308` +they would surface is hidden today. The map-key (A) and Box/Rc (B) families are +independent of these regions and are the trustworthy, actionable core. One confound was +already removed for this measurement: the emitted `Cargo.toml` omitted `im-rc` (used by +the hand-written `v1_interpreter`), which produced 2 spurious `E0432`; the harness now +adds it (mirrors the committed stage0 `Cargo.toml`). + +## Implication for the regen-fixpoint lane + +`E0308`-to-green is **not** 150 independent gaps — it is **two emitter root causes** +(map-literal key coercion; Box/Rc/Option auto-wrap) covering 34/38, plus a small scalar +arm. The remaining green work splits cleanly into separately-owned classes: the +**measure-tower** generic emission (12 `E0560` + the `std_measure`/`std_machine_constraints` +residue) and **regen-harness wiring** (the 8 `E0433`). This re-baseline is the input the +carrier-mark dissolution trigger was waiting on. diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index e1c002dacb7..bc71c235be7 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -989,9 +989,12 @@ fn patch_cargo_toml_for_generated_crate(dir: &Path) -> Result<(), String> { if contents.contains("ureq") { return Ok(()); } + // `im-rc` backs the hand-maintained periphery (v1_interpreter persistent value + // carriers); the emitted Cargo.toml omits it, so the assembled crate would not + // resolve `im_rc::*` without this. Mirrors the committed stage0 Cargo.toml dep. let patched = contents.replace( "\n[dependencies]\n", - "\n[dependencies]\nureq = { version = \"2\", features = [\"json\"] }\n", + "\n[dependencies]\nureq = { version = \"2\", features = [\"json\"] }\nim-rc = \"15.1\"\n", ); fs::write(&cargo_toml, patched).map_err(|e| format!("write {}: {e}", cargo_toml.display())) } From f2949b3324f68be43954c7f9ef024a4dcee045d2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 03:30:22 +0000 Subject: [PATCH 44/61] Move E0308 re-baseline out of docs/ into the PR body (fix doc-reachability orphan gate) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The categorized baseline as a standalone docs/plans/*.md file is an orphan doc (nothing in the roadmap_authority/design_document doc graph links it), which reds both the .dag doc_reachability witness and the rust live_tree_has_no_orphan_docs test -- the 2 failing CI checks. Per DESIGN §6 (no parallel-ledger docs), the measurement findings + verified reproducer now live in the PR body / lane node; the committed change is just the reusable apparatus (--emit-fresh harness mode + im-rc Cargo patch). Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/plans/e0308-rebaseline-route-a.md | 114 ------------------------- 1 file changed, 114 deletions(-) delete mode 100644 docs/plans/e0308-rebaseline-route-a.md diff --git a/docs/plans/e0308-rebaseline-route-a.md b/docs/plans/e0308-rebaseline-route-a.md deleted file mode 100644 index aebf8cc99f8..00000000000 --- a/docs/plans/e0308-rebaseline-route-a.md +++ /dev/null @@ -1,114 +0,0 @@ -# E0308 re-baseline — Route-A last mile (faithful emitted seed) - -Re-baselines the type-mismatch (`E0308`) gap between the **faithful full regen** of the -stage0 seed and `cargo`-green. The carrier mark in `regen_stage0.rs` estimated *"~150 -latent emitter-completeness gaps"* from wiring the std-tower modules; this measures the -real number and **categorizes it by variety** so the deferred regen-fixpoint lane -(`node://adhoc-80af9ff8-40f`) can be scoped from data, not an estimate. - -## What "the REAL crate" is - -The committed stage0 seed is a **hand-synced mirror**, not a regen fixpoint: it -deliberately leaves several std-tower modules **unwired** in `lib.rs` -(`std_measure` / `std_integer` / `std_machine_constraints` / -`std_realization_schedule` / `extdeps_version_semver` / `extdeps_cargo_version`). A -*faithful* full regen — emitting from the `.dag` authorities and wiring **every** -emitted module — is what surfaces the latent gaps. - -The REAL crate = the **emitted seed closure** (108 modules from `compile_stage0` -over `src/v1` + `dsl`) **+ the 22 hand-written periphery modules** copied verbatim -(`v1_interpreter` / `cli_run` / `v1_rt` / lens-kernel project modules / `wire_value_serialize` -/ `v1_compiler_dag_collect{,_support}`). - -## Reproduce - -A non-destructive harness mode assembles that crate without touching the committed -seed (`src/v1/stage0/src/bin/regen_stage0.rs`): - -``` -cargo build -p v1-compiler --bin regen_stage0 -./target/debug/regen_stage0 --emit-fresh # ~20 min: full v1-seed self-compile -cd -RUSTC_WRAPPER="" cargo build --message-format=json --lib > build.json 2>&1 - -# error-code histogram (total + E0308 share): -grep -oE '"code":"E[0-9]{4}"' build.json | sort | uniq -c | sort -rn - -# E0308 categorized by expected -> found type pair (one pair per diagnostic; sums to 38). -# `scan(...)[0]` takes the first occurrence so the per-diagnostic note doesn't double-count; -# the lone "" is a HashMap<&str> case whose label wraps across lines (family A). -jq -r 'select(.reason=="compiler-message") | .message | select(.code.code=="E0308") - | ([.rendered | scan("expected `[^`]+`, found `[^`]+`")][0]) // ""' build.json \ - | sort | uniq -c | sort -rn -``` - -`--emit-fresh` runs the same assembly phases as a normal regen (emit closure → copy -periphery → patches → rustfmt) into a caller-named dir and **stops** — no copy-back, no -temp cleanup. The committed seed is never mutated. (`RUSTC_WRAPPER=""` bypasses the -`sccache` wrapper, which is unrelated infra and flaked on a dep compile during this -measurement.) - -## Baseline (faithful emitted seed @ this branch tip) - -`cargo build --lib` on the assembled crate: **73 total errors**, of which **38 are -`E0308`**. (The "~150" estimate was stale by ~4×.) - -### E0308 by root cause — 2 emitter causes cover 89% - -| n | family | root cause | fix locus | -|---|--------|-----------|-----------| -| **24** (+1 multi-line-label variant = **25**) | **A — map-literal `&str` key** | emitter writes map **keys** as bare `&str` literals (`__m.insert("true", …)`) without `.to_string()`; the values *do* get `.to_string()`, so the map infers `HashMap<&str, V>` against the declared `HashMap` | map-literal emission (one fix → −25 E0308, 66%) | -| **10** | **B — Box/Rc/Option wrap** | auto-wrap/unwrap coercion not inserted: `Box`↔`String` (5+2), `Rc` vs `Option>` missing `Some()` (3) | coercion-insertion at call/construct sites | -| **3** | **C — scalar `&str`/`String`** | string literal not `.to_string()` in scalar position | same coercion path as A, scalar arm | - -The dominant lever is **family A** — a single emitter change (coerce map-literal keys to -`String`) clears ~two-thirds of all `E0308`. Worst files: `v1_compiler_stage0_crates.rs` -(6), `std_types.rs` (5), `extdeps_languages_dag_syntax.rs` (4). - -### Raw categorizer output (expected → found, top pairs) - -``` - 10 HashMap => HashMap<&str, String> - 7 HashMap => HashMap<&str, bool> - 5 Box => String - 3 &str => String - 2 HashMap> => HashMap<&str, Rc> - 3 Rc => Option> (SemVerIdentifier/ScheduleWitnessEntry/Runnable) - 1 i64 => Box - 1 String => Box - + 5 further HashMap => HashMap<&str,V> singletons (AlgebraProfile, TokenShape, NodeFieldRole, FunctionSizeEffect, i64) -``` - -## Non-E0308 context (the other 35 errors) — distinct classes, separate owners - -These do **not** count as E0308 but block green, and two classes **mask** an unknown -number of additional E0308 (see caveat): - -| n | code | class | where | -|---|------|-------|-------| -| 12 | E0560 | **measure-tower field emission** — `Rc> has no field count` | all `std_measure.rs` | -| 8 | E0433 | **unwired periphery** — `inert_carrier_project` / `non_fold_residue_project` not declared in emitted `lib.rs` (regen patch-list is stale vs the 3 newest `HAND_MAINTAINED` modules) | `v1_interpreter.rs` | -| 5 | E0425 | unresolved fn/type (`v1_rt::utf8_decode_bytes`, `SemVerConstraint`) | `extdeps_cargo.rs`, `v1_interpreter.rs`, `v1_probe_emit_interp.rs` | -| 2 | E0573 | `Time` variant used as type | `std_realization_schedule.rs` | -| 2 | E0599 | `clone` on unconstrained type param | `std_measure.rs`, `std_types.rs` | -| 2 | E0091 | unused type param (`Algebra` / `MachineConstraint`) | `std_machine_constraints.rs` | -| 1 each | E0277 / E0252 / E0107 / E0063 | std-tower generic-emission residue | `std_types` / `std_realization_schedule` / `std_termination` | - -### Honesty caveat (masking) - -The **38 is a lower bound**. `E0433` (8, in `v1_interpreter`) and `E0425` (5) are -*resolution* failures — `rustc` aborts type-checking in those regions, so any `E0308` -they would surface is hidden today. The map-key (A) and Box/Rc (B) families are -independent of these regions and are the trustworthy, actionable core. One confound was -already removed for this measurement: the emitted `Cargo.toml` omitted `im-rc` (used by -the hand-written `v1_interpreter`), which produced 2 spurious `E0432`; the harness now -adds it (mirrors the committed stage0 `Cargo.toml`). - -## Implication for the regen-fixpoint lane - -`E0308`-to-green is **not** 150 independent gaps — it is **two emitter root causes** -(map-literal key coercion; Box/Rc/Option auto-wrap) covering 34/38, plus a small scalar -arm. The remaining green work splits cleanly into separately-owned classes: the -**measure-tower** generic emission (12 `E0560` + the `std_measure`/`std_machine_constraints` -residue) and **regen-harness wiring** (the 8 `E0433`). This re-baseline is the input the -carrier-mark dissolution trigger was waiting on. From e673061cb69b025bb7915161a9b224da9c036020 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 03:54:25 +0000 Subject: [PATCH 45/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 3e37fae02e2..a5df1fc44a8 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -219,6 +219,23 @@ fn emit_rust_host_to_dag_string_via_seam(host_expr: String, corpus_repr: RustCor } } +// A map-literal's KEY must receive the SAME type-driven String coercion the VALUE +// gets via emit_typed_expr. The value slot is type-coerced; the key slot used to +// emit a bare "name" &str literal, so a Map data literal inferred +// HashMap<&str,V> and mismatched the declared HashMap (the Family-A +// E0308 cluster). The coercion is DERIVED from the declared key type, not blanket: +// a String-like key gets .to_string(); a non-String declared key emits the literal +// unchanged (fail-closed -- the two slots now consult the same type authority). +fn emit_rust_map_literal_key(field_name: String, key_type_node: Node, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { + let key_literal = concat("\"", field_name, "\"") + let host_expr = if is_rust_string_like(n: key_type_node, source_indices: source_indices) { + concat(key_literal, ".to_string()") + } else { + key_literal + } + emit_rust_host_to_dag_string_via_seam(host_expr: host_expr, corpus_repr: corpus_repr) +} + fn emit_rust_dag_string_to_host_via_seam(dag_expr: String, corpus_repr: RustCorpusRepr) -> String { if corpus_repr_is_faithful(corpus_repr: corpus_repr) { concat("crate::v2_std_text::host_string_text_to_rust_host(", dag_expr, ")") @@ -7849,9 +7866,13 @@ fn emit_data_def_body(type_node: Node, value: Node, registry: Map + let key_type_node = match type_node.children |> first { + Present { value: key_child } => child_type_node(ch: key_child) + Absent => type_node + } let inserts = value.children |> map(f => let val_str = emit_typed_expr(texpr: field_init_node_value(n: f), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) - concat(" __m.insert(", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), "\""), corpus_repr: emit_info.corpus_repr), ", ", val_str, ");") + concat(" __m.insert(", emit_rust_map_literal_key(field_name: field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), key_type_node: key_type_node, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices), ", ", val_str, ");") ) let inserts_str = inserts |> join(separator: "\n") concat(" let mut __m = HashMap::new();\n", From 6c6b94f013458499457e9f0c615179badbf958b3 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 03:58:01 +0000 Subject: [PATCH 46/61] Family-A: type-derived map-literal key coercion (.dag authority) emit_rust_map_literal_key applies .to_string() to a map-literal key iff the declared key type is String-like (key_is_string, derived at the call site from is_rust_string_like over the map's declared key type). Fixes the coercion asymmetry where the value slot was type-coerced but the key slot emitted a bare &str literal -> HashMap<&str,V> vs declared HashMap (Family-A E0308). Authority edit only; emitted-seed splice + witnesses follow. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/v1/05_emit_rust.dag | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index a5df1fc44a8..b125567db94 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -224,11 +224,15 @@ fn emit_rust_host_to_dag_string_via_seam(host_expr: String, corpus_repr: RustCor // emit a bare "name" &str literal, so a Map data literal inferred // HashMap<&str,V> and mismatched the declared HashMap (the Family-A // E0308 cluster). The coercion is DERIVED from the declared key type, not blanket: -// a String-like key gets .to_string(); a non-String declared key emits the literal -// unchanged (fail-closed -- the two slots now consult the same type authority). -fn emit_rust_map_literal_key(field_name: String, key_type_node: Node, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { +// `key_is_string` is computed at the call site from `is_rust_string_like` over the +// map's declared key type, so a String-like key gets `.to_string()` while a +// non-String declared key emits the literal unchanged (fail-closed -- both slots +// now consult the same type authority). The Bool seam keeps each branch directly +// witnessable (a non-String record-literal key is not source-expressible, since +// record keys are field-name identifiers). +fn emit_rust_map_literal_key(field_name: String, key_is_string: Bool, corpus_repr: RustCorpusRepr) -> String { let key_literal = concat("\"", field_name, "\"") - let host_expr = if is_rust_string_like(n: key_type_node, source_indices: source_indices) { + let host_expr = if key_is_string { concat(key_literal, ".to_string()") } else { key_literal From dbc66d18ff14e93f3e5f03cd320b8596e0a8d2e6 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 04:18:07 +0000 Subject: [PATCH 47/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 25 +++--- src/v1/tests/src/lib.rs | 2 + .../tests/src/map_literal_string_key_test.rs | 76 +++++++++++++++++++ 3 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 src/v1/tests/src/map_literal_string_key_test.rs diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b125567db94..c758bf6ae34 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -219,17 +219,6 @@ fn emit_rust_host_to_dag_string_via_seam(host_expr: String, corpus_repr: RustCor } } -// A map-literal's KEY must receive the SAME type-driven String coercion the VALUE -// gets via emit_typed_expr. The value slot is type-coerced; the key slot used to -// emit a bare "name" &str literal, so a Map data literal inferred -// HashMap<&str,V> and mismatched the declared HashMap (the Family-A -// E0308 cluster). The coercion is DERIVED from the declared key type, not blanket: -// `key_is_string` is computed at the call site from `is_rust_string_like` over the -// map's declared key type, so a String-like key gets `.to_string()` while a -// non-String declared key emits the literal unchanged (fail-closed -- both slots -// now consult the same type authority). The Bool seam keeps each branch directly -// witnessable (a non-String record-literal key is not source-expressible, since -// record keys are field-name identifiers). fn emit_rust_map_literal_key(field_name: String, key_is_string: Bool, corpus_repr: RustCorpusRepr) -> String { let key_literal = concat("\"", field_name, "\"") let host_expr = if key_is_string { @@ -240,6 +229,13 @@ fn emit_rust_map_literal_key(field_name: String, key_is_string: Bool, corpus_rep emit_rust_host_to_dag_string_via_seam(host_expr: host_expr, corpus_repr: corpus_repr) } +fn map_literal_key_is_string(map_type_node: Node, source_indices: Map) -> Bool { + match map_type_node.children |> first { + Present { value: key_child } => is_rust_string_like(n: child_type_node(ch: key_child), source_indices: source_indices) + Absent => false + } +} + fn emit_rust_dag_string_to_host_via_seam(dag_expr: String, corpus_repr: RustCorpusRepr) -> String { if corpus_repr_is_faithful(corpus_repr: corpus_repr) { concat("crate::v2_std_text::host_string_text_to_rust_host(", dag_expr, ")") @@ -7870,13 +7866,10 @@ fn emit_data_def_body(type_node: Node, value: Node, registry: Map - let key_type_node = match type_node.children |> first { - Present { value: key_child } => child_type_node(ch: key_child) - Absent => type_node - } + let key_is_string = map_literal_key_is_string(map_type_node: type_node, source_indices: scope.type_env.source_indices) let inserts = value.children |> map(f => let val_str = emit_typed_expr(texpr: field_init_node_value(n: f), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) - concat(" __m.insert(", emit_rust_map_literal_key(field_name: field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), key_type_node: key_type_node, corpus_repr: emit_info.corpus_repr, source_indices: scope.type_env.source_indices), ", ", val_str, ");") + concat(" __m.insert(", emit_rust_map_literal_key(field_name: field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), key_is_string: key_is_string, corpus_repr: emit_info.corpus_repr), ", ", val_str, ");") ) let inserts_str = inserts |> join(separator: "\n") concat(" let mut __m = HashMap::new();\n", diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index d34fe11631a..b506b9539ed 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -81,6 +81,8 @@ mod languages_consumer_census_lens_test; #[cfg(test)] 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_field_access_test; diff --git a/src/v1/tests/src/map_literal_string_key_test.rs b/src/v1/tests/src/map_literal_string_key_test.rs new file mode 100644 index 00000000000..7ef126f0fe4 --- /dev/null +++ b/src/v1/tests/src/map_literal_string_key_test.rs @@ -0,0 +1,76 @@ +//! Family-A regression: a map-literal's KEY must receive the same type-driven +//! String coercion the VALUE already gets, so a `Map` data literal emits +//! `HashMap` and not `HashMap<&str, V>` (the E0308 cluster). +//! +//! The coercion is DERIVED from the declared key type (`is_rust_string_like` over +//! the map's key type, computed at the emit call site). These witnesses pin both +//! directions of the derived decision plus the real-source emission shape. + +use v1_compiler::v1_compiler_artifact::RenderTarget; +use v1_compiler::v1_compiler_emit_rust::emit_rust_map_literal_key; +use v1_compiler::v1_compiler_infer_emit_info::RustCorpusRepr; + +// --- Discriminating control: the decision is type-DERIVED, not a blanket +// "always .to_string() the key". A non-String declared key is not expressible as a +// record-literal map (record keys are field-name identifiers), so the false branch +// is exercised directly here. --- + +#[test] +fn string_key_is_coerced_to_owned_string() { + // HostNative repr: the host->dag seam is identity, so the coercion is the only + // transform and is directly observable. + let out = emit_rust_map_literal_key("alpha".to_string(), true, RustCorpusRepr::HostNative); + assert_eq!( + out, "\"alpha\".to_string()", + "a String-keyed map literal must own its key" + ); +} + +#[test] +fn non_string_key_is_left_as_literal() { + // The wall: a NON-String declared key must NOT be `.to_string()`'d. If this ever + // emits `.to_string()`, the coercion has degenerated to blanket (a §5 fail-open + // that mis-coerces non-String key maps). + let out = emit_rust_map_literal_key("alpha".to_string(), false, RustCorpusRepr::HostNative); + assert_eq!( + out, "\"alpha\"", + "a non-String declared key must stay an unowned literal" + ); +} + +#[test] +fn faithful_repr_routes_owned_key_through_the_text_seam() { + // Under the faithful FreeMonoid repr the key still becomes an owned String first, + // then crosses the host->dag text seam (which consumes a `String`). + let out = + emit_rust_map_literal_key("alpha".to_string(), true, RustCorpusRepr::FaithfulFreeMonoid); + assert_eq!( + out, + "crate::v2_std_text::host_string_text_from_rust_host(\"alpha\".to_string())", + "faithful repr must hand the seam an owned String" + ); +} + +// --- Source-fixture proof: a real `Map` data literal emits owned +// String keys (so the inferred map matches the declared `HashMap`), +// while the Int value is left uncoerced (the slots are independently type-driven). --- + +#[test] +fn map_string_int_literal_emits_owned_keys_only() { + let source = "module mapkey.fixture\n\ndata lookup: Map = { alpha: 1, beta: 2 }\n"; + let result = crate::helpers::compile_dag_target(source, RenderTarget::Rust); + let emitted: String = result + .files + .iter() + .map(|f| f.content.clone()) + .collect::>() + .join("\n"); + assert!( + emitted.contains("__m.insert(\"alpha\".to_string()"), + "expected owned String key in emitted map literal, got:\n{emitted}" + ); + assert!( + !emitted.contains("1.to_string()"), + "the Int value must not be coerced to String (per-slot type derivation):\n{emitted}" + ); +} From 0cc25d7a61b7a9f33f87a72d3f1350018efc56dc Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 04:31:51 +0000 Subject: [PATCH 48/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 12 ++++- src/v1/stage0/src/v1_compiler_emit_rust.rs | 56 ++++++++++++++++------ 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index c758bf6ae34..b47514db97d 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -231,8 +231,16 @@ fn emit_rust_map_literal_key(field_name: String, key_is_string: Bool, corpus_rep fn map_literal_key_is_string(map_type_node: Node, source_indices: Map) -> Bool { match map_type_node.children |> first { - Present { value: key_child } => is_rust_string_like(n: child_type_node(ch: key_child), source_indices: source_indices) - Absent => false + Present { value: key_child } => is_rust_string_like(n: key_child, source_indices: source_indices) + Absent => + match find_property(props: map_type_node.properties, prop_name: "__applied_type_args", source_indices: source_indices) { + Present { value: applied } => + match applied.children |> first { + Present { value: akey } => is_rust_string_like(n: akey, source_indices: source_indices) + Absent => false + } + Absent => false + } } } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index da463d1ac1f..66d4c5e0ee5 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -341,6 +341,35 @@ pub fn emit_rust_host_to_dag_string_via_seam( } } +pub fn emit_rust_map_literal_key( + field_name: String, + key_is_string: bool, + corpus_repr: RustCorpusRepr, +) -> String { + { + let key_literal = v1_rt::concat( + v1_rt::concat("\"".to_string(), field_name), + "\"".to_string(), + ); + let host_expr = if key_is_string { + v1_rt::concat(key_literal, ".to_string()".to_string()) + } else { + key_literal + }; + emit_rust_host_to_dag_string_via_seam(host_expr, corpus_repr) + } +} + +pub fn map_literal_key_is_string( + map_type_node: Rc, + source_indices: Rc>>, +) -> bool { + match map_type_node.children.clone().first().cloned() { + Some(key_child) => is_rust_string_like(child_type_node(key_child.clone()), source_indices), + None => false, + } +} + pub fn emit_rust_dag_string_to_host_via_seam( dag_expr: String, corpus_repr: RustCorpusRepr, @@ -22229,6 +22258,10 @@ pub fn emit_data_def_body( 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(), + ); let inserts = Rc::new({ let mut __result = Vec::new(); for f in value.children.clone().iter().cloned() { @@ -22247,21 +22280,16 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( - v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), - ), - ), - "\"".to_string(), + emit_rust_map_literal_key( + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), ), + key_is_string.clone(), emit_info.corpus_repr.clone(), ), ), From cc0628974db95d19f8319dfb2233d0ab4b6b5d1f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 04:42:29 +0000 Subject: [PATCH 49/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 66d4c5e0ee5..b000d7b6894 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -365,8 +365,18 @@ 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(child_type_node(key_child.clone()), source_indices), - None => false, + 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.clone(), source_indices.clone()), + None => false, + }, + None => false, + }, } } From e7d837f00708883ec28911b783b73ce445bb9764 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 04:47:15 +0000 Subject: [PATCH 50/61] Relax map_string_int fixture assertion to faithful-repr seam output Co-Authored-By: Claude Opus 4.8 --- src/v1/tests/src/map_literal_string_key_test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v1/tests/src/map_literal_string_key_test.rs b/src/v1/tests/src/map_literal_string_key_test.rs index 7ef126f0fe4..be293ebd603 100644 --- a/src/v1/tests/src/map_literal_string_key_test.rs +++ b/src/v1/tests/src/map_literal_string_key_test.rs @@ -66,8 +66,8 @@ fn map_string_int_literal_emits_owned_keys_only() { .collect::>() .join("\n"); assert!( - emitted.contains("__m.insert(\"alpha\".to_string()"), - "expected owned String key in emitted map literal, got:\n{emitted}" + emitted.contains("\"alpha\".to_string()"), + "expected owned String key (coerced via .to_string()) in emitted map literal, got:\n{emitted}" ); assert!( !emitted.contains("1.to_string()"), From c6dce7897e1a853dc9acc00f3eb93eaf1c4f7abd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 05:00:19 +0000 Subject: [PATCH 51/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b47514db97d..fc5e37564ad 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -482,7 +482,7 @@ fn render_rust_applied_type_shared(n: Node, generic_param_names: List, s } fn render_rust_decl_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } let applied_prop = find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) let applied_overlay = match applied_prop { Present { value: applied } => @@ -497,7 +497,7 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { - render_rust_text_carrier(shared_types: shared_types) + rust_carrier_optional_wrap(n: n, rendered: render_rust_text_carrier(shared_types: shared_types)) } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && set_contains(shared_types, name) { let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) render_rust_shared_type_if_needed(type_name: name, rendered: rendered, shared_types: shared_types) @@ -540,11 +540,19 @@ fn rust_fn_sig_peel_closed_alias(env: TypeEnv, n: Node) -> Bool { (binding.params |> count) == 0 } +fn rust_carrier_optional_wrap(n: Node, rendered: String) -> String { + if n.return_cardinality == CardOptional { + concat("Option<", rendered, ">") + } else { + rendered + } +} + fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } let name = authored_name_at(source_indices: source_indices, node: n) if n.connective == NoConnective && n.children |> count == 0 && name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { - render_rust_text_carrier(shared_types: shared_types) + rust_carrier_optional_wrap(n: n, rendered: render_rust_text_carrier(shared_types: shared_types)) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) } else if generic_param_names |> count > 0 { From e9d963d3d4b8f9a831e0984243ca748c8dcd0a2b Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 05:07:34 +0000 Subject: [PATCH 52/61] WIP: first-Option carrier-sig renderer fix (lane branch) Co-Authored-By: Claude Opus 4.8 --- src/v1/05_emit_rust.dag | 6 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 22 ++++--- src/v1/tests/src/lib.rs | 2 + .../src/optional_carrier_signature_test.rs | 62 +++++++++++++++++++ 4 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 src/v1/tests/src/optional_carrier_signature_test.rs diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index fc5e37564ad..627590a31c2 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -162,7 +162,7 @@ fn render_rust_type(n: Node, shared_types: Set, corpus_repr: RustCorpusR } fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } else if node_is_set_collection(n: n, source_indices: source_indices) { @@ -183,7 +183,7 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, } else { let tn = authored_name_at(source_indices: source_indices, node: n) if tn == "String" && n.children |> count == 0 && corpus_repr_is_faithful(corpus_repr: corpus_repr) { - render_rust_text_carrier(shared_types: shared_types) + rust_carrier_optional_wrap(n: n, rendered: render_rust_text_carrier(shared_types: shared_types)) } else { render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) } @@ -3226,7 +3226,7 @@ fn emit_struct_from_children(name: String, type_params: String, generic_param_na } fn render_rust_type_with_applied_binding(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { Present { value: applied } => if applied.children |> count > 0 { diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index b000d7b6894..501c00c750d 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -206,7 +206,7 @@ pub fn render_rust_type_without_applied_binding( source_indices: Rc>>, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) @@ -271,7 +271,7 @@ pub fn render_rust_type_without_applied_binding( if (((tn == "String".to_string()) && ((n.children.clone().len() as i64) == 0)) && corpus_repr_is_faithful(corpus_repr)) { - render_rust_text_carrier(shared_types) + rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types)) } else { render_node_type( n.clone(), @@ -820,7 +820,7 @@ pub fn render_rust_decl_type( env: Rc, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -871,7 +871,7 @@ pub fn render_rust_decl_type( && (name.clone() == "String".to_string())) && corpus_repr_is_faithful(corpus_repr.clone())) { - render_rust_text_carrier(shared_types.clone()) + rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types.clone())) } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -990,6 +990,14 @@ pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { } } +pub fn rust_carrier_optional_wrap(n: Rc, rendered: String) -> String { + if (n.return_cardinality.clone() == Cardinality::CardOptional) { + v1_rt::concat(v1_rt::concat("Option<".to_string(), rendered), ">".to_string()) + } else { + rendered + } +} + pub fn render_rust_fn_sig_type( n: Rc, generic_param_names: Rc>, @@ -1000,7 +1008,7 @@ pub fn render_rust_fn_sig_type( env: Rc, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -1009,7 +1017,7 @@ pub fn render_rust_fn_sig_type( && (name.clone() == "String".to_string())) && corpus_repr_is_faithful(corpus_repr.clone())) { - render_rust_text_carrier(shared_types) + rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types)) } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) @@ -7838,7 +7846,7 @@ pub fn render_rust_type_with_applied_binding( source_indices: Rc>>, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } match find_property( n.properties.clone(), diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index b506b9539ed..0621347f2f8 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -93,6 +93,8 @@ mod money_carrier_cost_witness_test; #[cfg(test)] mod nodefold_generic_instantiation_test; #[cfg(test)] +mod optional_carrier_signature_test; +#[cfg(test)] mod parse; #[cfg(test)] mod parse_table_memo_amortization_test; diff --git a/src/v1/tests/src/optional_carrier_signature_test.rs b/src/v1/tests/src/optional_carrier_signature_test.rs new file mode 100644 index 00000000000..177eab13263 --- /dev/null +++ b/src/v1/tests/src/optional_carrier_signature_test.rs @@ -0,0 +1,62 @@ +//! first-Option family (Route-A): a function declared `-> String?` must render its +//! Rust signature as `-> Option`, not a bare `-> String`. The emitter +//! previously dropped the Optional wrapper for the String text-carrier: its +//! `is_host_text_carrier_type`/faithful-String early-returns short-circuited the +//! renderer that applies the Optional template, so every `String?`-returning function +//! (and `String?` field/param) emitted a bare `String`. That is the dominant E0308 +//! cluster in the faithful Route-A seed (`expected String, found Option`): +//! the body already emits `Some(..)/None`, so only the signature was wrong. +//! +//! The fix wraps the carrier rendering in `Option<..>` when (and only when) the +//! declared return cardinality is `CardOptional` (`rust_carrier_optional_wrap`). It is +//! cardinality-DERIVED construction, not a blanket "always wrap String": the control +//! below pins that a non-optional `String` return stays bare. + +use crate::helpers::compile_dag_target; +use v1_compiler::v1_compiler_artifact::RenderTarget; + +fn emit(source: &str) -> String { + compile_dag_target(source, RenderTarget::Rust) + .files + .iter() + .map(|f| f.content.clone()) + .collect::>() + .join("\n") +} + +// The signature slice for `fn_name`: from `fn ` up to the body-opening ` {`. +// Scoped this way so the runtime's own `Option<..>` types do not pollute the assertion. +fn return_sig(emitted: &str, fn_name: &str) -> String { + let needle = format!("fn {fn_name}"); + let start = emitted + .find(&needle) + .unwrap_or_else(|| panic!("fixture fn `{fn_name}` was not emitted:\n{emitted}")); + let rest = &emitted[start..]; + let body_open = rest + .find(" {") + .unwrap_or_else(|| panic!("no body opener for `{fn_name}`:\n{emitted}")); + rest[..body_open].to_string() +} + +#[test] +fn optional_string_return_renders_option_signature() { + let source = "module optsig.fixture\n\nfn maybe_label(flag: Bool) -> String? {\n if flag { Present { value: \"x\" } } else { none }\n}\n"; + let emitted = emit(source); + let sig = return_sig(&emitted, "maybe_label"); + assert!( + sig.contains("Option<"), + "a `-> String?` return must render an `Option<..>` signature, got:\n{sig}" + ); +} + +#[test] +fn non_optional_string_return_stays_bare() { + // Discriminating control: the wrap is cardinality-DERIVED, not blanket-on-String. + let source = "module optsig.fixture\n\nfn always_label(flag: Bool) -> String {\n \"x\"\n}\n"; + let emitted = emit(source); + let sig = return_sig(&emitted, "always_label"); + assert!( + !sig.contains("Option<"), + "a non-optional `-> String` must NOT be wrapped in Option, got:\n{sig}" + ); +} From acf51754483194581e4ceff9fc7e28ca76a4e647 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 05:17:00 +0000 Subject: [PATCH 53/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 3 ++- src/v1/tests/src/lib.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 627590a31c2..343cbbb8160 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -541,7 +541,8 @@ fn rust_fn_sig_peel_closed_alias(env: TypeEnv, n: Node) -> Bool { } fn rust_carrier_optional_wrap(n: Node, rendered: String) -> String { - if n.return_cardinality == CardOptional { + let is_optional = n.return_cardinality == CardOptional + if is_optional { concat("Option<", rendered, ">") } else { rendered diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index 0621347f2f8..1a8e886dfc2 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -95,6 +95,7 @@ mod nodefold_generic_instantiation_test; #[cfg(test)] mod optional_carrier_signature_test; #[cfg(test)] +#[cfg(test)] mod parse; #[cfg(test)] mod parse_table_memo_amortization_test; From ed294cc2b36b585f99113084dc159578f36aee33 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 05:46:10 +0000 Subject: [PATCH 54/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 8 ++++---- src/v1/stage0/src/v1_compiler_emit_rust.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 343cbbb8160..c5615a06b0c 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -145,7 +145,7 @@ import v1.compiler.emit_core_support { } fn render_rust_type(n: Node, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } match n.inferred { Present { value: TypeVariable { id: tv } } => tv _ => @@ -443,7 +443,7 @@ fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shar } fn render_rust_applied_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } let base_name = authored_name_at(source_indices: source_indices, node: n) if n.children |> count == 0 { @@ -581,7 +581,7 @@ fn render_rust_fn_sig_type_applied_binding(n: Node, shared_types: Set, c } fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared_types: Set, corpus_repr: RustCorpusRepr, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { - if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return "String" } + if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") } let name = authored_name_at(source_indices: source_indices, node: n) if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name @@ -590,7 +590,7 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared Present { value: host } => host Absent => if name == "String" && corpus_repr_is_faithful(corpus_repr: corpus_repr) { - render_rust_text_carrier(shared_types: shared_types) + rust_carrier_optional_wrap(n: n, rendered: render_rust_text_carrier(shared_types: shared_types)) } else { match rust_opaque_kernel_alias_carrier(name: name) { Present { value: carrier } => carrier diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 501c00c750d..b621aace017 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -150,7 +150,7 @@ pub fn render_rust_type( source_indices: Rc>>, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), @@ -719,7 +719,7 @@ pub fn render_rust_applied_type( env: Rc, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } { let base_name = authored_name_at(source_indices.clone(), n.clone()); @@ -1119,7 +1119,7 @@ pub fn render_rust_alias_rhs_type( variant_to_enum: Rc>, ) -> String { if is_host_text_carrier_type(n.clone(), source_indices.clone(), corpus_repr) { - return "String".to_string(); + return rust_carrier_optional_wrap(n.clone(), "String".to_string()); } stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -1147,7 +1147,7 @@ pub fn render_rust_alias_rhs_type( if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr.clone())) { - render_rust_text_carrier(shared_types.clone()) + rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types.clone())) } else { match rust_opaque_kernel_alias_carrier(name.clone()) { Some(carrier) => carrier.clone(), From d3394a187bbc4d026d3ed9353d078d2b5d7ec14b Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 06:00:40 +0000 Subject: [PATCH 55/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 15 ++++++++++++--- src/v1/tests/src/lib.rs | 1 - src/v1/tests/src/map_literal_string_key_test.rs | 10 ++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 6a22fe084d3..ac5b4173014 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -871,7 +871,10 @@ pub fn render_rust_decl_type( && (name.clone() == "String".to_string())) && corpus_repr_is_faithful(corpus_repr.clone())) { - rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types.clone())) + rust_carrier_optional_wrap( + n.clone(), + render_rust_text_carrier(shared_types.clone()), + ) } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -992,7 +995,10 @@ pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { pub fn rust_carrier_optional_wrap(n: Rc, rendered: String) -> String { if (n.return_cardinality.clone() == Cardinality::CardOptional) { - v1_rt::concat(v1_rt::concat("Option<".to_string(), rendered), ">".to_string()) + v1_rt::concat( + v1_rt::concat("Option<".to_string(), rendered), + ">".to_string(), + ) } else { rendered } @@ -1147,7 +1153,10 @@ pub fn render_rust_alias_rhs_type( if ((name.clone() == "String".to_string()) && corpus_repr_is_faithful(corpus_repr.clone())) { - rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types.clone())) + rust_carrier_optional_wrap( + n.clone(), + render_rust_text_carrier(shared_types.clone()), + ) } else { match rust_opaque_kernel_alias_carrier(name.clone()) { Some(carrier) => carrier.clone(), diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index db010bc8cc0..b0d494678cc 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -99,7 +99,6 @@ mod nodefold_generic_instantiation_test; #[cfg(test)] mod optional_carrier_signature_test; #[cfg(test)] -#[cfg(test)] mod parse; #[cfg(test)] mod parse_table_memo_amortization_test; diff --git a/src/v1/tests/src/map_literal_string_key_test.rs b/src/v1/tests/src/map_literal_string_key_test.rs index be293ebd603..85955ec0574 100644 --- a/src/v1/tests/src/map_literal_string_key_test.rs +++ b/src/v1/tests/src/map_literal_string_key_test.rs @@ -42,11 +42,13 @@ fn non_string_key_is_left_as_literal() { fn faithful_repr_routes_owned_key_through_the_text_seam() { // Under the faithful FreeMonoid repr the key still becomes an owned String first, // then crosses the host->dag text seam (which consumes a `String`). - let out = - emit_rust_map_literal_key("alpha".to_string(), true, RustCorpusRepr::FaithfulFreeMonoid); + let out = emit_rust_map_literal_key( + "alpha".to_string(), + true, + RustCorpusRepr::FaithfulFreeMonoid, + ); assert_eq!( - out, - "crate::v2_std_text::host_string_text_from_rust_host(\"alpha\".to_string())", + out, "crate::v2_std_text::host_string_text_from_rust_host(\"alpha\".to_string())", "faithful repr must hand the seam an owned String" ); } From 3625b00fada81f397f0a0985fd4af7028aec6acc Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 06:11:40 +0000 Subject: [PATCH 56/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/05_emit_rust.dag | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index e9ab0f59256..4b4a56d6078 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -5078,6 +5078,24 @@ fn emit_typed_call_expr(func: String, args: List, inferred: InferredNode?, } else { call_str } } +fn rust_call_arg_fail_closed_unwrap(arg_str: String, arg: Node, callee: ItemInfo?, idx: Int, func: String) -> String { + match callee { + Present { value: info } => + match info.params |> skip(idx) |> first { + Present { value: param } => + let param_required = param_node_type_expr(n: param).return_cardinality != CardOptional + let arg_optional = resolved_type(n: arg).return_cardinality == CardOptional + if param_required && arg_optional { + concat(arg_str, ".expect(\"fail-closed: an optional value flowed into non-optional parameter ", to_string(value: idx), " of ", func, " (empty Optional at runtime)\")") + } else { + arg_str + } + Absent => arg_str + } + Absent => arg_str + } +} + fn emit_typed_call(func: String, args: List, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { if func == "get" { let get_args = order_typed_call_args(args: args, func: func, scope: scope) @@ -5182,7 +5200,8 @@ fn emit_typed_call(func: String, args: List, registry: Map Date: Wed, 24 Jun 2026 06:21:53 +0000 Subject: [PATCH 57/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- .../src/optional_consumer_fail_closed_test.rs | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/v1/tests/src/optional_consumer_fail_closed_test.rs diff --git a/src/v1/tests/src/optional_consumer_fail_closed_test.rs b/src/v1/tests/src/optional_consumer_fail_closed_test.rs new file mode 100644 index 00000000000..2880cf2c60e --- /dev/null +++ b/src/v1/tests/src/optional_consumer_fail_closed_test.rs @@ -0,0 +1,98 @@ +//! Residual first-Option family (Route-A): a genuinely OPTIONAL value (`-> T?`, e.g. +//! the modeled `first` which returns `OptionalOf`) flowing into a NON-optional +//! consumer parameter is the model hole the renderer fix could not absorb (the +//! signature now renders `Option` faithfully, so the mismatch `expected Rc, +//! found Option>` is exposed at the call site, not hidden). +//! +//! The emitter resolves this by construction at exactly those sites — and ONLY those +//! sites — with a §5 FAIL-CLOSED unwrap: a located `.expect("fail-closed: ...")` that +//! names the consumer (param index + callee) so an empty Optional at runtime aborts +//! loudly with a diagnostic, rather than fabricating a value. It is explicitly NOT +//! `unwrap_or_default` / `unwrap_or_else()` (that would be a §5 fail-OPEN: +//! a silent wrong answer). The unwrap is type-DERIVED: emitted iff the declared +//! parameter is required AND the argument's resolved type is optional. +//! +//! Two teeth: +//! - Part A (emit construction): a required-param consumer fed an optional arg emits +//! the located `.expect("fail-closed:`; a control whose arg is non-optional does not. +//! - Part B (discriminating EXECUTION): the empty case actually fails closed — the +//! emitted unwrap shape, run on `None`, PANICS, whereas the rejected fail-open shape +//! (`unwrap_or_default`) silently returns a fabricated default. This is the §5 +//! distinction made executable, not asserted. + +use crate::helpers::compile_dag_target; +use v1_compiler::v1_compiler_artifact::RenderTarget; + +fn emit(source: &str) -> String { + compile_dag_target(source, RenderTarget::Rust) + .files + .iter() + .map(|f| f.content.clone()) + .collect::>() + .join("\n") +} + +// === Part B: the empty case actually FAILS CLOSED (execution) === +// Mirrors the emitted unwrap shape exactly: an optional produced by `first` over an +// empty collection, unwrapped at a required consumer slot. The emitted code uses +// `.expect("fail-closed: ...")`; on `None` that PANICS. The §5-WRONG alternative we +// reject (`unwrap_or_default`) would instead fabricate a default and NOT panic — the +// control below proves the two diverge precisely on the empty input. +#[test] +fn empty_optional_unwrap_panics_not_fabricates() { + let empty: Vec = vec![]; + + // The fail-CLOSED shape the emitter produces: located `.expect` on the optional. + let panicked = std::panic::catch_unwind(|| { + let optional: Option = empty.first().cloned(); + optional.expect( + "fail-closed: an optional value flowed into non-optional parameter 0 of consume (empty Optional at runtime)", + ) + }) + .is_err(); + assert!( + panicked, + "an empty Optional at a required slot must FAIL CLOSED (panic), not fabricate a value" + ); + + // The fail-OPEN shape we explicitly reject: unwrap_or_default fabricates 0 silently. + let fabricated: i64 = empty.first().cloned().unwrap_or_default(); + assert_eq!( + fabricated, 0, + "control: unwrap_or_default would silently fabricate 0 on empty — the §5 fail-OPEN path the emitter must NOT take" + ); +} + +// === Part A: the emitter emits the located fail-closed unwrap, type-derived === +// PLACEHOLDER fixtures — validated/adjusted against the rebuilt seed (the synthetic +// fixture must actually route an optional arg into a required param through +// emit_typed_call). Filled in post-rebuild once the emitted shape is confirmed. +#[test] +fn required_param_optional_arg_emits_located_fail_closed_unwrap() { + let source = "module failclosed.fixture\n\nfn consume(x: Int) -> Int {\n x\n}\n\nfn drive(xs: List) -> Int {\n consume(x: xs |> first)\n}\n"; + let emitted = emit(source); + assert!( + emitted.contains(".expect(\"fail-closed:"), + "an optional arg into a required param must emit a located fail-closed `.expect`, got:\n{emitted}" + ); + assert!( + !emitted.contains("unwrap_or_default"), + "the fail-closed unwrap must NOT be unwrap_or_default (that fabricates):\n{emitted}" + ); +} + +#[test] +fn required_param_nonoptional_arg_stays_bare() { + // Discriminating control: a non-optional arg into the same required param must NOT + // get the unwrap — the construction is type-derived, not blanket. + let source = "module failclosed.fixture\n\nfn consume(x: Int) -> Int {\n x\n}\n\nfn drive(y: Int) -> Int {\n consume(x: y)\n}\n"; + let emitted = emit(source); + let drive_body = emitted + .split_once("fn drive") + .map(|(_, r)| r.to_string()) + .unwrap_or_default(); + assert!( + !drive_body.contains(".expect(\"fail-closed:"), + "a non-optional arg must NOT receive a fail-closed unwrap, got:\n{drive_body}" + ); +} From 4e97994970cecd1cb4fb8038e3b3e8f67c4b4380 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 06:32:36 +0000 Subject: [PATCH 58/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 53 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index ac5b4173014..ace01458e31 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -13532,6 +13532,34 @@ pub fn emit_typed_call_expr( } } +pub fn rust_call_arg_fail_closed_unwrap( + arg_str: String, + arg: Rc, + callee: Option>, + idx: i64, + func: String, +) -> String { + 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() + != Cardinality::CardOptional); + let arg_optional = + (resolved_type(arg).return_cardinality.clone() == Cardinality::CardOptional); + if (param_required && arg_optional) { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(arg_str, ".expect(\"fail-closed: an optional value flowed into non-optional parameter ".to_string()), (idx.clone()).to_string()), " of ".to_string()), func), " (empty Optional at runtime)\")".to_string()) + } else { + arg_str + } + } + None => arg_str, + }, + None => arg_str, + } +} + pub fn emit_typed_call( func: String, args: Rc>>, @@ -13843,14 +13871,23 @@ pub fn emit_typed_call( ) } } else { - emit_cloned_arg( - arg_value(a.clone()), - registry.clone(), - collection_scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) + { + let base = emit_cloned_arg( + arg_value(a.clone()), + registry.clone(), + collection_scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ); + rust_call_arg_fail_closed_unwrap( + base.clone(), + arg_value(a.clone()), + callee.clone(), + idx.clone(), + func.clone(), + ) + } } } }); From 3c5f3af2c4a36f888aee2577dfc6d6ce03650199 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 06:42:56 +0000 Subject: [PATCH 59/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- src/v1/tests/src/lib.rs | 2 ++ .../src/optional_consumer_fail_closed_test.rs | 23 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index b0d494678cc..d1729d62a49 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -99,6 +99,8 @@ mod nodefold_generic_instantiation_test; #[cfg(test)] mod optional_carrier_signature_test; #[cfg(test)] +mod optional_consumer_fail_closed_test; +#[cfg(test)] mod parse; #[cfg(test)] mod parse_table_memo_amortization_test; diff --git a/src/v1/tests/src/optional_consumer_fail_closed_test.rs b/src/v1/tests/src/optional_consumer_fail_closed_test.rs index 2880cf2c60e..7c7ae94eea7 100644 --- a/src/v1/tests/src/optional_consumer_fail_closed_test.rs +++ b/src/v1/tests/src/optional_consumer_fail_closed_test.rs @@ -64,16 +64,21 @@ fn empty_optional_unwrap_panics_not_fabricates() { } // === Part A: the emitter emits the located fail-closed unwrap, type-derived === -// PLACEHOLDER fixtures — validated/adjusted against the rebuilt seed (the synthetic -// fixture must actually route an optional arg into a required param through -// emit_typed_call). Filled in post-rebuild once the emitted shape is confirmed. +// `maybe` returns `Int?` (declared `CardOptional`); fed into `consume`'s required +// `x: Int` slot it is exactly the optional-into-required model hole. The control feeds +// the same required slot a non-optional literal, proving the unwrap is type-DERIVED +// (param required AND arg resolved-type optional), not blanket. +const CONSUME_AND_MAYBE: &str = "module failclosed.fixture\n\nfn maybe(flag: Bool) -> Int? {\n if flag { Present { value: 1 } } else { none }\n}\n\nfn consume(x: Int) -> Int {\n x\n}\n"; + #[test] fn required_param_optional_arg_emits_located_fail_closed_unwrap() { - let source = "module failclosed.fixture\n\nfn consume(x: Int) -> Int {\n x\n}\n\nfn drive(xs: List) -> Int {\n consume(x: xs |> first)\n}\n"; - let emitted = emit(source); + let source = format!( + "{CONSUME_AND_MAYBE}\nfn drive(flag: Bool) -> Int {{\n consume(x: maybe(flag: flag))\n}}\n" + ); + let emitted = emit(&source); assert!( emitted.contains(".expect(\"fail-closed:"), - "an optional arg into a required param must emit a located fail-closed `.expect`, got:\n{emitted}" + "an optional arg (`maybe(..) -> Int?`) into a required param (`consume(x: Int)`) must emit a located fail-closed `.expect`, got:\n{emitted}" ); assert!( !emitted.contains("unwrap_or_default"), @@ -85,8 +90,10 @@ fn required_param_optional_arg_emits_located_fail_closed_unwrap() { fn required_param_nonoptional_arg_stays_bare() { // Discriminating control: a non-optional arg into the same required param must NOT // get the unwrap — the construction is type-derived, not blanket. - let source = "module failclosed.fixture\n\nfn consume(x: Int) -> Int {\n x\n}\n\nfn drive(y: Int) -> Int {\n consume(x: y)\n}\n"; - let emitted = emit(source); + let source = format!( + "{CONSUME_AND_MAYBE}\nfn drive(y: Int) -> Int {{\n consume(x: y)\n}}\n" + ); + let emitted = emit(&source); let drive_body = emitted .split_once("fn drive") .map(|(_, r)| r.to_string()) From 8f6bd72c50028df49fd28e914876bd5d8e849cec Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 06:45:06 +0000 Subject: [PATCH 60/61] WIP: Lane A E0308 re-baseline (Route-A last mile): CONTINUE emitter/seed-gree --- .../src/optional_consumer_fail_closed_test.rs | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/v1/tests/src/optional_consumer_fail_closed_test.rs b/src/v1/tests/src/optional_consumer_fail_closed_test.rs index 7c7ae94eea7..84406213a60 100644 --- a/src/v1/tests/src/optional_consumer_fail_closed_test.rs +++ b/src/v1/tests/src/optional_consumer_fail_closed_test.rs @@ -70,19 +70,35 @@ fn empty_optional_unwrap_panics_not_fabricates() { // (param required AND arg resolved-type optional), not blanket. const CONSUME_AND_MAYBE: &str = "module failclosed.fixture\n\nfn maybe(flag: Bool) -> Int? {\n if flag { Present { value: 1 } } else { none }\n}\n\nfn consume(x: Int) -> Int {\n x\n}\n"; +// The emitted `drive` fn body (from `fn drive` to the next top-level `pub fn`), so the +// assertions see only the call site under test, not unrelated runtime modules (which +// legitimately use `unwrap_or_default` for their own reasons). +fn drive_fn(emitted: &str) -> String { + let start = emitted + .find("fn drive") + .unwrap_or_else(|| panic!("`drive` was not emitted:\n{emitted}")); + let rest = &emitted[start..]; + let end = rest[8..] + .find("\npub fn ") + .map(|i| i + 8) + .unwrap_or(rest.len()); + rest[..end].to_string() +} + #[test] fn required_param_optional_arg_emits_located_fail_closed_unwrap() { let source = format!( "{CONSUME_AND_MAYBE}\nfn drive(flag: Bool) -> Int {{\n consume(x: maybe(flag: flag))\n}}\n" ); let emitted = emit(&source); + let drive = drive_fn(&emitted); assert!( - emitted.contains(".expect(\"fail-closed:"), - "an optional arg (`maybe(..) -> Int?`) into a required param (`consume(x: Int)`) must emit a located fail-closed `.expect`, got:\n{emitted}" + drive.contains(".expect(\"fail-closed:"), + "an optional arg (`maybe(..) -> Int?`) into a required param (`consume(x: Int)`) must emit a located fail-closed `.expect`, got:\n{drive}" ); assert!( - !emitted.contains("unwrap_or_default"), - "the fail-closed unwrap must NOT be unwrap_or_default (that fabricates):\n{emitted}" + !drive.contains("unwrap_or_default") && !drive.contains("unwrap_or_else"), + "the fail-closed unwrap must NOT fabricate (no unwrap_or_default/unwrap_or_else):\n{drive}" ); } @@ -90,16 +106,11 @@ fn required_param_optional_arg_emits_located_fail_closed_unwrap() { fn required_param_nonoptional_arg_stays_bare() { // Discriminating control: a non-optional arg into the same required param must NOT // get the unwrap — the construction is type-derived, not blanket. - let source = format!( - "{CONSUME_AND_MAYBE}\nfn drive(y: Int) -> Int {{\n consume(x: y)\n}}\n" - ); + let source = format!("{CONSUME_AND_MAYBE}\nfn drive(y: Int) -> Int {{\n consume(x: y)\n}}\n"); let emitted = emit(&source); - let drive_body = emitted - .split_once("fn drive") - .map(|(_, r)| r.to_string()) - .unwrap_or_default(); + let drive = drive_fn(&emitted); assert!( - !drive_body.contains(".expect(\"fail-closed:"), - "a non-optional arg must NOT receive a fail-closed unwrap, got:\n{drive_body}" + !drive.contains(".expect(\"fail-closed:"), + "a non-optional arg must NOT receive a fail-closed unwrap, got:\n{drive}" ); } From e0bbe841ecf967b8dc107468bf8f883d8375fd8e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 24 Jun 2026 15:14:37 +0000 Subject: [PATCH 61/61] Restore unrelated-lane files clobbered by merge resolution (#5716) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #5716's first-option-carrier work already landed in main; the only remaining diff was a stale merge reverting other lanes (#5715 TS, ci_humming / realization_measurement_loop / resolver plans). Restore each to origin/main so this branch carries zero reversions. PR diff is now empty — flag for closure. Co-Authored-By: Claude Opus 4.8 --- docs/plans/ci-humming.md | 4 + .../plans/edge-b-rust-dag-provenance-brief.md | 105 ++--- docs/plans/realization-measurement-loop.md | 383 ++++------------- .../resolver-type-name-collision-wall.md | 201 +++------ dsl/gunbc/plan_registry.dag | 4 +- dsl/gunbc/plan_registry_batch_g.dag | 14 + dsl/gunbc/plans/ci_humming.dag | 67 +++ .../edge_b_rust_dag_provenance_brief.dag | 63 +++ .../plans/realization_measurement_loop.dag | 187 +++++++++ .../resolver_type_name_collision_wall.dag | 125 ++++++ .../typescript_bind_let_iife_emit_test.dag | 168 ++++++++ src/v2/extdeps/languages/dag.dag | 57 ++- src/v2/extdeps/languages/typescript.dag | 81 +++- src/v2/std/compilers/target_model.dag | 387 ++++++++++++++++-- 14 files changed, 1239 insertions(+), 607 deletions(-) create mode 100644 dsl/gunbc/plan_registry_batch_g.dag create mode 100644 dsl/gunbc/plans/ci_humming.dag create mode 100644 dsl/gunbc/plans/edge_b_rust_dag_provenance_brief.dag create mode 100644 dsl/gunbc/plans/realization_measurement_loop.dag create mode 100644 dsl/gunbc/plans/resolver_type_name_collision_wall.dag create mode 100644 src/v2/compiler/manual/typescript_bind_let_iife_emit_test.dag diff --git a/docs/plans/ci-humming.md b/docs/plans/ci-humming.md index 668ff2ed3fe..1b4de86a4c7 100644 --- a/docs/plans/ci-humming.md +++ b/docs/plans/ci-humming.md @@ -62,3 +62,7 @@ The hosts co-host the agent-session fleet AND the CI runners. Full safe-by-const ## Critical path to capacity (do first, both hosts ASAP) T0 (un-zero the runner slice) → model derives sane N + per-slot caps → T1+T2 verified-effective apply on srv1+srv2, **with the session slice either capped (5) or oomd-backstopped** → safe by construction (Σ caps + overhead + baselines ≤ physical). T4 (peak → 8GiB) multiplies N afterward. oomd is not required on the critical path. + +## Dissolution trigger (DESIGN §6) + +Delete this doc when CI throughput, wall-clock, and reliability all fall out of the single modeled fleet budget consumed by a verified-effective apply (T0 un-zeroes the runner slice, T1/T2 caps are verified-effective on srv1+srv2, and the session slice is capped or oomd-backstopped) — so capacity is safe by construction rather than hand-managed. diff --git a/docs/plans/edge-b-rust-dag-provenance-brief.md b/docs/plans/edge-b-rust-dag-provenance-brief.md index 9bdbcca28e9..43748303992 100644 --- a/docs/plans/edge-b-rust-dag-provenance-brief.md +++ b/docs/plans/edge-b-rust-dag-provenance-brief.md @@ -1,115 +1,60 @@ # Edge-(b) scoped dispatch brief — rust-test ↔ consumed-.dag provenance (the coverage keystone) -**Status: SCOPING ONLY.** The multi-day build holds for the operator's explicit greenlight. -This document is the decision artifact for that greenlight call. +**Status: SCOPING ONLY.** The multi-day build holds for the operator's explicit greenlight. This document is the decision artifact for that greenlight call. ## Goal -Make the rust↔.dag dependency a **declared structural fact**, recorded once and read in two -directions. It is the single fact under three consumers (DESIGN §4, one grammar both directions), -which is why this is the §1 *coverage keystone*, not a cost follow-up. +Make the rust↔.dag dependency a **declared structural fact**, recorded once and read in two directions. It is the single fact under three consumers (DESIGN §4, one grammar both directions), which is why this is the §1 *coverage keystone*, not a cost follow-up. ## Why — one fact, three consumers -1. **Coverage wall (soundness, fail-closed).** Today a pure-.dag PR fires *no* rust gate: - `any_rust_monolith` (`dsl/tools/rust_stage0_gates.dag`) matches only `.rs`/Cargo/toolchain - suffixes. But rust tests *read* `.dag` via opaque `filesystem_read`/`ws.join`, so a `.dag` - change that breaks a rust test ships **silently green** — a §5 fail-OPEN. That file's own - COMPLETENESS CLAIM ("every change that can alter a rust gate's verdict carries a `.rs`/Cargo - suffix") is *false* for .dag-consuming tests, and its header names per-file rust→.dag - dependence as the deliberately-skipped proper model. Edge-(b) FIRES the rust gate when a - changed `.dag` is in a rust test's declared closure → makes the claim true. This is the - operator's "lock fail-closed before you expand" priority. +1. **Coverage wall (soundness, fail-closed).** Today a pure-.dag PR fires *no* rust gate: `any_rust_monolith` (`dsl/tools/rust_stage0_gates.dag`) matches only `.rs`/Cargo/toolchain suffixes. But rust tests *read* `.dag` via opaque `filesystem_read`/`ws.join`, so a `.dag` change that breaks a rust test ships **silently green** — a §5 fail-OPEN. That file's own COMPLETENESS CLAIM ("every change that can alter a rust gate's verdict carries a `.rs`/Cargo suffix") is *false* for .dag-consuming tests, and its header names per-file rust→.dag dependence as the deliberately-skipped proper model. Edge-(b) FIRES the rust gate when a changed `.dag` is in a rust test's declared closure → makes the claim true. This is the operator's "lock fail-closed before you expand" priority. +2. **Affordability selector.** The *same* declared closure read the other way — skip rust tests whose closure the diff doesn't touch — is the affected-set shrink (the ROADMAP end-state: run-all baseline SHRUNK to affected). cargo has *zero* affected-test selection (every `#[test]` every run; nextest too) and can't see `.dag` deps, so a declared closure is the *only* path to it. +3. **Testgen reflection.** The rust-test→.dag closure is the same provenance testgen needs to regenerate the right tests when a `.dag` node changes. -2. **Affordability selector.** The *same* declared closure read the other way — skip rust tests - whose closure the diff doesn't touch — is the affected-set shrink (the ROADMAP end-state: - run-all baseline SHRUNK to affected). cargo has *zero* affected-test selection (every `#[test]` - every run; nextest too) and can't see `.dag` deps, so a declared closure is the *only* path to it. - -3. **Testgen reflection.** The rust-test→.dag closure is the same provenance testgen needs to - regenerate the right tests when a `.dag` node changes. - -FIRE-when-consumed and SKIP-when-unaffected are the single fact read in opposite directions — -that unification is the moat (one carrier, three consumers). +FIRE-when-consumed and SKIP-when-unaffected are the single fact read in opposite directions — that unification is the moat (one carrier, three consumers). ## The asymmetry that decides what the build buys (construction, not validation) -The two directions have **asymmetric robustness to an incomplete declaration**, and this is the -construction-vs-validation lesson made concrete: +The two directions have **asymmetric robustness to an incomplete declaration**, and this is the construction-vs-validation lesson made concrete: -- **Affordability (skip-unaffected) is fail-SAFE to over-declaration.** Declare too much → you just - run more → never unsound. Robust to a sloppy/partial closure. -- **Coverage (fire-on-change) is fail-OPEN to UNDER-declaration.** If a test reads `.dag` A and B but - its closure declares only A, a change to B does NOT fire the gate → the exact `.dag`→rust fail-open - we are closing, silently re-introduced as **declaration drift**. The coverage wall is only as sound - as the declaration is COMPLETE: **closure ⊇ actual-.dag-reads**. +- **Affordability (skip-unaffected) is fail-SAFE to over-declaration.** Declare too much → you just run more → never unsound. Robust to a sloppy/partial closure. +- **Coverage (fire-on-change) is fail-OPEN to UNDER-declaration.** If a test reads `.dag` A and B but its closure declares only A, a change to B does NOT fire the gate → the exact `.dag`→rust fail-open we are closing, silently re-introduced as **declaration drift**. The coverage wall is only as sound as the declaration is COMPLETE: **closure ⊇ actual-.dag-reads**. -Consequence: the coverage wall's soundness lives entirely in the *completeness* of the closure, which -means a **hand-authored closure is the §3/§5 fork** — for the coverage consumer it silently re-opens -the hole. So the closure MUST be structurally derived (drift-proof); any hand-authored interim must be -marked **NON-SOUND** (delivers affordability only, not the coverage wall). The "shared blocker" below -is therefore not the tail of the work — it is *where the soundness lives*. +Consequence: the coverage wall's soundness lives entirely in the *completeness* of the closure, which means a **hand-authored closure is the §3/§5 fork** — for the coverage consumer it silently re-opens the hole. So the closure MUST be structurally derived (drift-proof); any hand-authored interim must be marked **NON-SOUND** (delivers affordability only, not the coverage wall). The "shared blocker" below is therefore not the tail of the work — it is *where the soundness lives*. ## Bounded core -1. **Declare rust-test → consumed-.dag-paths on the EXISTING `NodeArtifactProvenance` / - `EditLocusBinding` carrier** — no parallel mint (§3 single authority). Implementer must first - verify the carrier shape fits `rust-test-identity → .dag-path list`; if not, add a *sibling - entry on the same authority*, never a new module. -2. **Gate integration is small and precise:** extend `should_run_gates` / `any_rust_monolith` - (`dsl/tools/rust_stage0_gates.dag`) so a changed `.dag` path in the union of declared rust-test - closures ALSO returns true. -3. **Fail-closed default AT THE CONSUMER:** a rust test with no declared closure → *must-run*, - never skip. Absent provenance = run. This keeps the soundness direction safe while declarations - are added incrementally. -4. **Completeness-lens gated — on CORRECTNESS, not presence.** A lens that merely asserts "every - rust test HAS a closure declaration" checks *presence*, which is exactly the §5 trap: it is - satisfiable by editing the declaration while the realization diverges (the faked-cache-key / - dead-field pattern). The lens must check **closure ⊇ actual-.dag-reads** — otherwise a partial or - stale declaration passes the lens AND leaks coverage. Presence-only is not enough; correctness - (the superset relation) is the soundness condition. +1. **Declare rust-test → consumed-.dag-paths on the EXISTING `NodeArtifactProvenance` / `EditLocusBinding` carrier** — no parallel mint (§3 single authority). Implementer must first verify the carrier shape fits `rust-test-identity → .dag-path list`; if not, add a *sibling entry on the same authority*, never a new module. +2. **Gate integration is small and precise:** extend `should_run_gates` / `any_rust_monolith` (`dsl/tools/rust_stage0_gates.dag`) so a changed `.dag` path in the union of declared rust-test closures ALSO returns true. +3. **Fail-closed default AT THE CONSUMER:** a rust test with no declared closure → *must-run*, never skip. Absent provenance = run. This keeps the soundness direction safe while declarations are added incrementally. +4. **Completeness-lens gated — on CORRECTNESS, not presence.** A lens that merely asserts "every rust test HAS a closure declaration" checks *presence*, which is exactly the §5 trap: it is satisfiable by editing the declaration while the realization diverges (the faked-cache-key / dead-field pattern). The lens must check **closure ⊇ actual-.dag-reads** — otherwise a partial or stale declaration passes the lens AND leaks coverage. Presence-only is not enough; correctness (the superset relation) is the soundness condition. ## Shared blocker (testgen-reflection) — this IS the soundness, not optional polish -Per the asymmetry above: the `.dag`-closure must be DISCOVERED structurally, not hand-listed -(hand-listing is the §3/§5 fork that rots, and for the coverage consumer it *silently re-opens the -hole*). The reflection infra exists *partially* — `v2.std.node_query` + `dependency_lens` + the -`affected_set` node-frontier (compile-time, structural over Node/DependencyView). The missing piece: -rust tests reach `.dag` through *opaque host paths* (`ws.join`/`filesystem_read`), so the closure -isn't visible to the Node-tree lens. Surfacing each rust test's `.dag` reads as a declared, -lens-visible dependency is the shared blocker all three consumers wait on — and because the coverage -wall is only sound when `closure ⊇ actual-reads`, this structural discovery is the **load-bearing -core**, not the tail. It is the hard part and the multi-day driver precisely because it is where the -soundness is bought. +Per the asymmetry above: the `.dag`-closure must be DISCOVERED structurally, not hand-listed (hand-listing is the §3/§5 fork that rots, and for the coverage consumer it *silently re-opens the hole*). The reflection infra exists *partially* — `v2.std.node_query` + `dependency_lens` + the `affected_set` node-frontier (compile-time, structural over Node/DependencyView). The missing piece: rust tests reach `.dag` through *opaque host paths* (`ws.join`/`filesystem_read`), so the closure isn't visible to the Node-tree lens. Surfacing each rust test's `.dag` reads as a declared, lens-visible dependency is the shared blocker all three consumers wait on — and because the coverage wall is only sound when `closure ⊇ actual-reads`, this structural discovery is the **load-bearing core**, not the tail. It is the hard part and the multi-day driver precisely because it is where the soundness is bought. ## First vertical slice (smallest end-to-end, green-by-execution) -- Pick ONE rust test with a clear `.dag` closure — `coproduct_reflection_conformance_test` - (inputs entirely `.dag`) is the natural first. +- Pick ONE rust test with a clear `.dag` closure — `coproduct_reflection_conformance_test` (inputs entirely `.dag`) is the natural first. - Declare its consumed-.dag closure on the carrier. - Wire `should_run_gates` to fire when a changed path is in THAT test's declared closure. -- Prove by execution with a discriminating control: a diff to a `.dag` IN the closure FIRES the - gate; a diff to a `.dag` OUTSIDE the closure does NOT. Green = both directions observed. +- Prove by execution with a discriminating control: a diff to a `.dag` IN the closure FIRES the gate; a diff to a `.dag` OUTSIDE the closure does NOT. Green = both directions observed. - This proves the structural fact end-to-end on one test before any corpus fan-out. -- **State explicitly which the slice proves.** For the slice to prove the *coverage direction - soundly*, `coproduct_reflection_conformance_test`'s closure must be **structurally derived** (so a - newly-added `.dag` read is captured automatically). If slice-1 hand-lists the closure as an interim, - it proves the *wiring* (fire/skip plumbing) but NOT the *wall* (drift-proof completeness) — and must - be labelled accordingly. The keystone's value is the wall, so the slice should target the derived - closure, not the hand-listed one. +- **State explicitly which the slice proves.** For the slice to prove the *coverage direction soundly*, `coproduct_reflection_conformance_test`'s closure must be **structurally derived** (so a newly-added `.dag` read is captured automatically). If slice-1 hand-lists the closure as an interim, it proves the *wiring* (fire/skip plumbing) but NOT the *wall* (drift-proof completeness) — and must be labelled accordingly. The keystone's value is the wall, so the slice should target the derived closure, not the hand-listed one. ## Honest estimate Multi-day. + - Slice 1 (one test: declare + gate-fire + discriminating control): ~1 day. -- Shared blocker (structural .dag-closure discovery through opaque host reads, lens-visible): - the bulk — ~2–4 days, depending on whether the host-read seam can surface declarations cheaply - or needs the reflection layer deepened. +- Shared blocker (structural .dag-closure discovery through opaque host reads, lens-visible): the bulk — ~2–4 days, depending on whether the host-read seam can surface declarations cheaply or needs the reflection layer deepened. - Corpus fan-out + completeness lens: after. ## Decoupling -Independent of #5427. #5427 is the cheap `.rs`-hole-closer (widen the rust gate's test command on -`.rs`-touching PRs) — lands now, behind the two operator levers. Edge-(b) is the structural -keystone that later makes the rust gate BOTH sound on `.dag` changes AND affordable by selection. -Neither blocks the other. +Independent of #5427. #5427 is the cheap `.rs`-hole-closer (widen the rust gate's test command on `.rs`-touching PRs) — lands now, behind the two operator levers. Edge-(b) is the structural keystone that later makes the rust gate BOTH sound on `.dag` changes AND affordable by selection. Neither blocks the other. + +## Dissolution trigger (DESIGN §6) + +Delete this brief once edge-(b) is built and merged — the rust-test→consumed-.dag closure is a structurally-derived (drift-proof) declared fact on the NodeArtifactProvenance carrier, the coverage wall fires the rust gate on an in-closure .dag change (closure ⊇ actual-reads, lens-checked on correctness not presence), and the affordability selector skips unaffected rust tests — so the scoping decision this doc records is realized. diff --git a/docs/plans/realization-measurement-loop.md b/docs/plans/realization-measurement-loop.md index e93862462a6..1ba45fb1a6e 100644 --- a/docs/plans/realization-measurement-loop.md +++ b/docs/plans/realization-measurement-loop.md @@ -1,25 +1,16 @@ # Plan — Realization & Measurement: closing the cost → schedule loop (+ infra onto `.dag`) -**Status:** stable coordination plan · dispatch workers per phase · **DESIGN.md + the carriers remain the -authority** — this doc is a worker-dispatch tracker, not a fact ledger, and each phase dissolves into a -mark on its carrier when it lands (DESIGN §6 "no parallel-ledger docs"). A phase's real state is its -branch/PR, not this file (mirrors `ROADMAP.md`). +**Status:** stable coordination plan · dispatch workers per phase · **DESIGN.md + the carriers remain the authority** — this doc is a worker-dispatch tracker, not a fact ledger, and each phase dissolves into a mark on its carrier when it lands (DESIGN §6 "no parallel-ledger docs"). A phase's real state is its branch/PR, not this file (mirrors `ROADMAP.md`). -**Owner:** unowned (original coordinator `zesty-deer-479` archived 2026-06-21) — operator-coordinated; -consolidates the formerly-separate quick-ant-298 dependency-ordered roadmap (single authority, no fork). -Linked from `ROADMAP.md` §2 *Minimal work — caching by realization*. +**Owner:** unowned (original coordinator `zesty-deer-479` archived 2026-06-21) — operator-coordinated; consolidates the formerly-separate quick-ant-298 dependency-ordered roadmap (single authority, no fork). Linked from `ROADMAP.md` §2 *Minimal work — caching by realization*. --- ## 0. Thesis — the substrate is shape-complete but input-starved -The realization layer is *fully modeled and almost entirely inert*: every carrier that should drive -"minimal work, as parallel as possible, guaranteed" exists with the right type and is read by **no -scheduler, fed by **no measurement, consulted by **no router. This is DESIGN §6's failure mode — *"the -tier where the machinery exists but nothing gates on it"* — landed squarely on §1's **cost axis**. +The realization layer is *fully modeled and almost entirely inert*: every carrier that should drive "minimal work, as parallel as possible, guaranteed" exists with the right type and is read by **no scheduler, fed by **no measurement, consulted by **no router. This is DESIGN §6's failure mode — *"the tier where the machinery exists but nothing gates on it"* — landed squarely on §1's **cost axis**. -The fix is **one control loop**, not a pile of local patches (this is why §4 "evaluate the whole -pipeline" is load-bearing, not a footnote): +The fix is **one control loop**, not a pile of local patches (this is why §4 "evaluate the whole pipeline" is load-bearing, not a footnote): ``` measure (Phase 0) ← the keystone; makes cost a real fact @@ -30,103 +21,50 @@ pipeline" is load-bearing, not a footnote): → total rolled up along the CRITICAL PATH, not the node sum (Phase 1.5) ``` -The three notes from the operator are **not peers — they are a dependency chain rooted at measurement**: -`minimal work` = §2 (cache planner) and `as parallel as possible` = §1 (width) can only be *optimized -against a measured cost*, and `guaranteed` = §5 (measured, not predicted). Cost must become a measured -fact before anything can plan against it. The independent CI audit reached the same conclusion ("add the -two-clock timing first"); the dependency structure above is *why*. +The three notes from the operator are **not peers — they are a dependency chain rooted at measurement**: `minimal work` = §2 (cache planner) and `as parallel as possible` = §1 (width) can only be *optimized against a measured cost*, and `guaranteed` = §5 (measured, not predicted). Cost must become a measured fact before anything can plan against it. The independent CI audit reached the same conclusion ("add the two-clock timing first"); the dependency structure above is *why*. ### The end-state acceptance gate (what the whole plan builds to) -> For every pure transform `T` (resolve, parse, typecheck, *and* derived analyses like -> complexity-synthesis / affected-set — see `ROADMAP.md` §3 *Complexity / synthesis lens* and §4 *Testgen*), `realize(T)` returns a result -> content-addressed by `hash(inputs ⊕ content(T))`, materialized at the **minimal `Placement` spanning -> T's consumers (its reach)**. A transform that is **non-redundant** (shared across a layer boundary, or -> recompute-cost > cache-cost) with **no cache supplier at its reach layer** is a located, typed -> **ERROR** that emits a *request to provision a supplier there*. No silent `Recompute`; no under-keyed -> hit. +> For every pure transform `T` (resolve, parse, typecheck, *and* derived analyses like complexity-synthesis / affected-set — see `ROADMAP.md` §3 *Complexity / synthesis lens* and §4 *Testgen*), `realize(T)` returns a result content-addressed by `hash(inputs ⊕ content(T))`, materialized at the **minimal `Placement` spanning T's consumers (its reach)**. A transform that is **non-redundant** (shared across a layer boundary, or recompute-cost > cache-cost) with **no cache supplier at its reach layer** is a located, typed **ERROR** that emits a *request to provision a supplier there*. No silent `Recompute`; no under-keyed hit. -This is §5 (fail-closed) turned on the cost axis: uncached non-redundant work is not "slow", it is an -*error*. The earliest truthful point to assert it is the **redundancy-only** cut (shared-across-boundary -— needs reach, not measurement); the cost-based "non-redundant" half waits on measured cost (Phase 0 / -§4). The phases below are the path to this gate; the dependency-ordered spine that maps work items onto -it is in **§ Dependency-ordered spine** (before Sequencing). +This is §5 (fail-closed) turned on the cost axis: uncached non-redundant work is not "slow", it is an *error*. The earliest truthful point to assert it is the **redundancy-only** cut (shared-across-boundary — needs reach, not measurement); the cost-based "non-redundant" half waits on measured cost (Phase 0 / §4). The phases below are the path to this gate; the dependency-ordered spine that maps work items onto it is in **§ Dependency-ordered spine** (before Sequencing). ### The invariant that governs every phase (DESIGN §3 / §4) -> **Pure schedule TOPOLOGY stays central and deterministic; every measurement-fed decision is a -> PERIPHERAL realization.** - -The schedule (`Schedule = List>`) is a deterministic partial order — it expresses what -*can* run in parallel, hardware-free, and is pinned by the `schedule_eq` / -`schedule_generates_identical_schedule` witnesses (`realization_schedule.dag:222-236`; -`src/v2/test/claim/realization_schedule_witness.dag:35-48`). A schedule whose *width or membership* -depended on a measured per-machine `HardwareThreadCount` would break that equality across hosts. So: -**measured ⇒ peripheral, by construction.** Width, shard balance, cache-layer choice, and the timing tap -all live in the periphery (`extdeps/realization`, the host realizer), checked by *"given these -DeploymentFacts + these measured costs, the realizer picks X"* witnesses — deterministic *given their -inputs*. This is exactly what the `CostAccount` dissolve-on comment anticipates -(`realization_schedule.dag:25-26`). Most `.dag` programs are stateless/short-lived: they declare -dependency structure and never mention hardware; the width-fold degenerates to "just run it." +> **Pure schedule TOPOLOGY stays central and deterministic; every measurement-fed decision is a PERIPHERAL realization.** + +The schedule (`Schedule = List>`) is a deterministic partial order — it expresses what *can* run in parallel, hardware-free, and is pinned by the `schedule_eq` / `schedule_generates_identical_schedule` witnesses (`realization_schedule.dag:222-236`; `src/v2/test/claim/realization_schedule_witness.dag:35-48`). A schedule whose *width or membership* depended on a measured per-machine `HardwareThreadCount` would break that equality across hosts. So: **measured ⇒ peripheral, by construction.** Width, shard balance, cache-layer choice, and the timing tap all live in the periphery (`extdeps/realization`, the host realizer), checked by *"given these DeploymentFacts + these measured costs, the realizer picks X"* witnesses — deterministic *given their inputs*. This is exactly what the `CostAccount` dissolve-on comment anticipates (`realization_schedule.dag:25-26`). Most `.dag` programs are stateless/short-lived: they declare dependency structure and never mention hardware; the width-fold degenerates to "just run it." ### Realization has THREE dimensions (schedule · cache · compute-fabric) -"Realization" is one concept with three orthogonal-but-composed dimensions, **all keyed on the same -content-addressed `ExecutionReceipt`**, all **peripheral** (§3), all governed by the **same measured cost -+ Pareto objective**: +"Realization" is one concept with three orthogonal-but-composed dimensions, **all keyed on the same content-addressed `ExecutionReceipt`**, all **peripheral** (§3), all governed by the **same measured cost + Pareto objective**: | Dimension | Carrier | Asks | §1 axis | -|---|---|---|---| +| --- | --- | --- | --- | | **schedule** | `std.realization_schedule` | *when / how parallel* | parallel | | **cache** | `std.cache_interface` | *whether it needs to run at all* | §2 minimal work | | **compute fabric** | `product.compute_fabric` | *where / on what it runs* (provision) | placement / $ | -The proof they are dimensions of *one* concept rather than three separate models is **structural and -already in the tree**: cache `MUST NOT import compute_fabric` (`cache_interface.dag:4`) and compute_fabric -`MUST NOT import cache_interface` (`compute_fabric.dag:9`); **both compose only over `ExecutionReceipt`**. -They meet *only* at the content-addressed receipt — never by direct coupling (§3/§4). - -**The `compute_fabric()` zero-arg interface is the same §3 move as the whole plan.** `compute_fabric` is a -**demand → placement → supply** market: an execution emits a `WorkDemand` (isolation, memory, GPU) and -`satisfies(offer, demand)` (`compute_fabric.dag:377`) places it on a satisfying `ComputeOffer`. "Provision -compute for this execution" with **empty args** = the `WorkDemand` is *inferred from the .dag-modeled -execution*, and placement is *resolved from the deployment's offers* — **neither is a caller argument**. -Identical to the cache planner auto-wiring and the scheduler's hardware-budget fold: *caller declares -intent; the realization is resolved from modeled deployment facts.* All three dimensions share this. - -**Layering discipline (§3):** `compute_fabric` and `placement_supply` are **product**; schedule/cache are **std** (imports point -toward std). Split: product owns the *placement projection carrier* (`product.placement_supply` ✓) and std owns the `{time,space,power}` -cost-axis measure carriers it composes; product `compute_fabric` owns the **$/billing axis** (`CostClass`, `MoneyMicros`) and *projects* -fleet rows into that carrier (`placement_supply_row`, `compute_fabric.dag:220`); the **peripheral host -realizer** bridges product→std and runs the Pareto pick. std stays product-free. +The proof they are dimensions of *one* concept rather than three separate models is **structural and already in the tree**: cache `MUST NOT import compute_fabric` (`cache_interface.dag:4`) and compute_fabric `MUST NOT import cache_interface` (`compute_fabric.dag:9`); **both compose only over `ExecutionReceipt`**. They meet *only* at the content-addressed receipt — never by direct coupling (§3/§4). + +**The `compute_fabric()` zero-arg interface is the same §3 move as the whole plan.** `compute_fabric` is a **demand → placement → supply** market: an execution emits a `WorkDemand` (isolation, memory, GPU) and `satisfies(offer, demand)` (`compute_fabric.dag:377`) places it on a satisfying `ComputeOffer`. "Provision compute for this execution" with **empty args** = the `WorkDemand` is *inferred from the .dag-modeled execution*, and placement is *resolved from the deployment's offers* — **neither is a caller argument**. Identical to the cache planner auto-wiring and the scheduler's hardware-budget fold: *caller declares intent; the realization is resolved from modeled deployment facts.* All three dimensions share this. + +**Layering discipline (§3):** `compute_fabric` and `placement_supply` are **product**; schedule/cache are **std** (imports point toward std). Split: product owns the *placement projection carrier* (`product.placement_supply` ✓) and std owns the `{time,space,power}` cost-axis measure carriers it composes; product `compute_fabric` owns the **$/billing axis** (`CostClass`, `MoneyMicros`) and *projects* fleet rows into that carrier (`placement_supply_row`, `compute_fabric.dag:220`); the **peripheral host realizer** bridges product→std and runs the Pareto pick. std stays product-free. ### v2 is the target; v1 is the proving ground (DESIGN §7) -v1 (the Rust seed) is shrinking to zero; v2 (the self-hosted `.dag` compiler) is what must benefit. -**Every phase's durable artifact is `.dag` that v2 inherits; the Rust seed is only the proving *handler* -— where a host-effect attaches today, while v2 is mid-bootstrap and the v1 interpreter is still the only -evaluator that actually runs.** You MAY edit v1 (it's a proving ground), but: - -> **The v2-benefit test:** if a phase's deliverable is a Rust patch with *no `.dag` model*, it failed. -> The carrier / lens / kernel / effect-shape is the artifact; the Rust code is one handler of it -> (§2 one-shape-N-handlers; §3 measured⇒peripheral; §7 Rust→zero). - -This is *why* the keystone's measurement is modeled as an **effect-shape + `PerformanceReceipt` carrier + -a roll-up lens over the Node fold** (the same `fold_node` v2's own evaluator uses) — so when v2 self-hosts, -the instrumentation, the cache kernel, the scheduler, and the fabric all come along for free. The Rust tap -in `v1_interpreter.rs` *proves* the model green-by-execution today; it is the realization, not the -authority. Per-phase split: **Phase 0** durable = the `.dag` measure model/lens, proving = the Rust eval -tap; **Phase 1** durable = the `.dag` width-fold (`scheduler.dag` is already v2), proving = the -`claim_executor` spawn cap; **Phase 1.5a/2/3** are already `.dag`-native (`v2.lens.affected_set`, the -cache catalog/kernel, `compute_fabric`/`ci_yaml_emit`) — v2-inheriting by construction; only the cache -*backends* (`resolved_graph_cache.rs`, `ParseTableMemo`) stay v1 handlers of the one `.dag` kernel. +v1 (the Rust seed) is shrinking to zero; v2 (the self-hosted `.dag` compiler) is what must benefit. **Every phase's durable artifact is `.dag` that v2 inherits; the Rust seed is only the proving *handler* — where a host-effect attaches today, while v2 is mid-bootstrap and the v1 interpreter is still the only evaluator that actually runs.** You MAY edit v1 (it's a proving ground), but: + +> **The v2-benefit test:** if a phase's deliverable is a Rust patch with *no `.dag` model*, it failed. The carrier / lens / kernel / effect-shape is the artifact; the Rust code is one handler of it (§2 one-shape-N-handlers; §3 measured⇒peripheral; §7 Rust→zero). + +This is *why* the keystone's measurement is modeled as an **effect-shape + `PerformanceReceipt` carrier + a roll-up lens over the Node fold** (the same `fold_node` v2's own evaluator uses) — so when v2 self-hosts, the instrumentation, the cache kernel, the scheduler, and the fabric all come along for free. The Rust tap in `v1_interpreter.rs` *proves* the model green-by-execution today; it is the realization, not the authority. Per-phase split: **Phase 0** durable = the `.dag` measure model/lens, proving = the Rust eval tap; **Phase 1** durable = the `.dag` width-fold (`scheduler.dag` is already v2), proving = the `claim_executor` spawn cap; **Phase 1.5a/2/3** are already `.dag`-native (`v2.lens.affected_set`, the cache catalog/kernel, `compute_fabric`/`ci_yaml_emit`) — v2-inheriting by construction; only the cache *backends* (`resolved_graph_cache.rs`, `ParseTableMemo`) stay v1 handlers of the one `.dag` kernel. --- ## Verified ground truth (file:line — do not re-derive) | Fact | Evidence | -|---|---| +| --- | --- | | Schedule width = full dependency frontier, **no capacity bound** | `ReadinessLayer.ready: List` `src/v2/workflow/scheduler.dag:29`; `runnable_frontier_from_dependencies` `scheduler.dag:147-154` | | Thread-spawn **unbounded by hardware** (one OS thread per runnable-in-batch) | `thread::spawn(... run_one_runnable ...)` `src/v1/stage0/src/bin/claim_executor.rs:403-410` | | Corpus = **one** `RunnableDiscoveryBatch` node → serial `for` loop (293 witnesses invisible) | `ci_floor_plan.dag:107`; `run_discovery_corpus` serial loop `cli_run.rs:2148-2171` | @@ -149,46 +87,16 @@ cache catalog/kernel, `compute_fabric`/`ci_yaml_emit`) — v2-inheriting by cons ## Phase 0 — Measured cost (THE KEYSTONE) -**Goal:** flip `CostAccount.time` from `predicted_zero` to `Measured`. Everything quantitative depends on -this. NB: the timing *primitives already exist* — this is **"wire the existing tap to a content-hash key -+ CostAccount,"** not "build timing from scratch." - -- **Grain decision (settled this session): key on the content-hash of the cache SUBJECT, not per-AST-node, - not per-variant.** Rationale: the `Node` is an `Rc` with **no ambient content-hash** (today the - profiler keys by `expr_variant_index`), so per-node hashing at `eval_expr` is *not free* and would - perturb the measurement (§5 observer effect). The cache-subject frame is exactly where a content-hash - *is already computed*, and it is the grain the scheduler (per-Runnable) and the cache router - (per-subject recompute cost) both consume — so per-subject is the §2 "model once, derive every use" - point: per-Runnable is its aggregate, per-variant its `group-by`, full per-node an **opt-in deep - projection** over the same seam. Per-variant counters are a *dead end* (a variant is not a cacheable - identity → can't feed Phase 2). -- **Instrumentation = the dual of the cache.** Both wrap the same fold boundary keyed by the same - content-hash: the cache stores node→value, the instrument stores node→duration. The *analysis* is a pure - lens; the measurement itself is a §1 host-effect. Use the existing gross−children self-time decomposition - (`v1_interpreter.rs:1466-1476`). -- **The measurement output is a `PerformanceReceipt`, NOT a new struct (§3 — do not coin a 4th).** The - observation carrier already exists: `compute_fabric.PerformanceReceipt{ wall_duration, sample_count, - confidence }` (`compute_fabric.dag:414-423`), and `ExecutionReceipt.performance` (`:453`) already hangs it - on the receipt. So Phase 0 emits a `PerformanceReceipt` keyed by the cache-subject hash → it rolls up into - `CostAccount.time` (the aggregate). This is what *fuses the keystone to the compute-fabric deliverable*: - the thing Phase 0 measures **is** the fabric's execution receipt, and `MeasurementConfidence` - (SingleSample/Range/DistributionSummary) is exactly the per-witness-distribution honesty the audit's - observability gap needs. -- **Feed `CostAccount`.** Add `CostBasis = Measured | Predicted` (the `:25-26` dissolve-on); aggregate - PerformanceReceipts → `RealizationPlan.total`. -- **Converge the time authorities — there are THREE, not two (§3).** `NanosecondDuration` (`measure.dag:258`) - is the authority. `TestNodeCostDimension.measured_ms` (Milliseconds, `verification.dag`) **dissolves** - into a budget-*predicate* over the measured `CostAccount.time` (a ns threshold), not a parallel measured - field (ms truncates a 5 ns step to 0 — DESIGN §6). And `PerformanceReceipt.wall_duration` is the - *observation* feeding the roll-up — observation vs roll-up, not a fork. Net: one observation carrier - (`PerformanceReceipt`), one roll-up (`CostAccount.time`), `measured_ms` deleted. -- **Persist the dropped timing.** Carry per-witness/per-entry timing through `DiscoverySummary` and the - floor path (`claim_executor`), closing the audit's observability gap (the "two-clock" per-entry-resolve - vs aggregate-per-witness split) — which is *itself* the profiling the operator was about to do by hand, - made first-class. +**Goal:** flip `CostAccount.time` from `predicted_zero` to `Measured`. Everything quantitative depends on this. NB: the timing *primitives already exist* — this is **"wire the existing tap to a content-hash key + CostAccount,"** not "build timing from scratch." + +- **Grain decision (settled this session): key on the content-hash of the cache SUBJECT, not per-AST-node, not per-variant.** Rationale: the `Node` is an `Rc` with **no ambient content-hash** (today the profiler keys by `expr_variant_index`), so per-node hashing at `eval_expr` is *not free* and would perturb the measurement (§5 observer effect). The cache-subject frame is exactly where a content-hash *is already computed*, and it is the grain the scheduler (per-Runnable) and the cache router (per-subject recompute cost) both consume — so per-subject is the §2 "model once, derive every use" point: per-Runnable is its aggregate, per-variant its `group-by`, full per-node an **opt-in deep projection** over the same seam. Per-variant counters are a *dead end* (a variant is not a cacheable identity → can't feed Phase 2). +- **Instrumentation = the dual of the cache.** Both wrap the same fold boundary keyed by the same content-hash: the cache stores node→value, the instrument stores node→duration. The *analysis* is a pure lens; the measurement itself is a §1 host-effect. Use the existing gross−children self-time decomposition (`v1_interpreter.rs:1466-1476`). +- **The measurement output is a `PerformanceReceipt`, NOT a new struct (§3 — do not coin a 4th).** The observation carrier already exists: `compute_fabric.PerformanceReceipt{ wall_duration, sample_count, confidence }` (`compute_fabric.dag:414-423`), and `ExecutionReceipt.performance` (`:453`) already hangs it on the receipt. So Phase 0 emits a `PerformanceReceipt` keyed by the cache-subject hash → it rolls up into `CostAccount.time` (the aggregate). This is what *fuses the keystone to the compute-fabric deliverable*: the thing Phase 0 measures **is** the fabric's execution receipt, and `MeasurementConfidence` (SingleSample/Range/DistributionSummary) is exactly the per-witness-distribution honesty the audit's observability gap needs. +- **Feed `CostAccount`.** Add `CostBasis = Measured | Predicted` (the `:25-26` dissolve-on); aggregate PerformanceReceipts → `RealizationPlan.total`. +- **Converge the time authorities — there are THREE, not two (§3).** `NanosecondDuration` (`measure.dag:258`) is the authority. `TestNodeCostDimension.measured_ms` (Milliseconds, `verification.dag`) **dissolves** into a budget-*predicate* over the measured `CostAccount.time` (a ns threshold), not a parallel measured field (ms truncates a 5 ns step to 0 — DESIGN §6). And `PerformanceReceipt.wall_duration` is the *observation* feeding the roll-up — observation vs roll-up, not a fork. Net: one observation carrier (`PerformanceReceipt`), one roll-up (`CostAccount.time`), `measured_ms` deleted. +- **Persist the dropped timing.** Carry per-witness/per-entry timing through `DiscoverySummary` and the floor path (`claim_executor`), closing the audit's observability gap (the "two-clock" per-entry-resolve vs aggregate-per-witness split) — which is *itself* the profiling the operator was about to do by hand, made first-class. - **§5 gate:** purity oracle — witness verdicts byte-identical instrumented vs not. -- **Dissolution trigger:** `cost_account_predicted_zero()` has no callers on the floor path; `measured_ms` - deleted. +- **Dissolution trigger:** `cost_account_predicted_zero()` has no callers on the floor path; `measured_ms` deleted. --- @@ -196,43 +104,20 @@ this. NB: the timing *primitives already exist* — this is **"wire the existing **Depends on:** Phase 0 (shard balance needs measured per-shard cost). -- **Explode the corpus node** (`ci_floor_plan.dag:107`) into per-entry-group `Runnable`s — **rows, not - Rust**. Express it as a `WorkDemand` whose `parallelism = IndependentShards{shard_count}` - (`compute_fabric.dag:282`) — the corpus is today a *degenerate (unsharded) projection* of exactly that, - so this reuses the carrier rather than minting a scheduler-local shard list. Shard *by whole entry-group* - to preserve the warm `typed_module_cache` (splitting an entry's witnesses re-incurs its cold resolve). - This is the keystone both background audits independently named. -- **The hardware budget is what `compute_fabric` PROVISIONS — do not coin a fresh carrier (§2/§3).** The - width-fold reads the `PlacementSupplyRow` that `compute_fabric` already projects (`placement_supply_row`, - `compute_fabric.dag:220`; `PlacementSupplyRow.hardware_threads` `placement_supply.dag:29-31`). **The - width decision *is* a placement decision:** today `satisfies(offer, demand)` (`compute_fabric.dag:377`) - checks *isolation only* — Phase 1 is "add the thread-count / Pareto dimension to placement." So this - phase is co-designed with Phase 3 (compute_fabric is the provisioning interface; the runner *declares* - the offer, the scheduler *consumes* the placement — one market, two readers). DFS `PlacementSupplyRow` + - `CpuDeploymentFacts` (`cpu/types.dag:42`) before extending; do **not** invent `DeploymentFacts`. -- **The width-fold.** Schedule stays the pure partial order; a peripheral realizer folds it against the - `HardwareBudget` → actual width, a Pareto pick over `{wall-time↓, peak-memory↓}` bounded by `width ≤ - cores` — reusing `std.pareto` + `RealizationObjective.goals` (already `List` — wiring carriers - that already speak the same vocabulary, not inventing one). -- **Bound the spawner** (`claim_executor.rs:403-410`) by `available_parallelism`/budget — fixes the *dual* - hazard: under-parallel (serial corpus) **and** over-parallel (unbounded spawn on a wide batch). -- **Determinism:** schedule topology stays witness-stable; width/shard are peripheral, checked by - given-these-facts witnesses. +- **Explode the corpus node** (`ci_floor_plan.dag:107`) into per-entry-group `Runnable`s — **rows, not Rust**. Express it as a `WorkDemand` whose `parallelism = IndependentShards{shard_count}` (`compute_fabric.dag:282`) — the corpus is today a *degenerate (unsharded) projection* of exactly that, so this reuses the carrier rather than minting a scheduler-local shard list. Shard *by whole entry-group* to preserve the warm `typed_module_cache` (splitting an entry's witnesses re-incurs its cold resolve). This is the keystone both background audits independently named. +- **The hardware budget is what `compute_fabric` PROVISIONS — do not coin a fresh carrier (§2/§3).** The width-fold reads the `PlacementSupplyRow` that `compute_fabric` already projects (`placement_supply_row`, `compute_fabric.dag:220`; `PlacementSupplyRow.hardware_threads` `placement_supply.dag:29-31`). **The width decision *is* a placement decision:** today `satisfies(offer, demand)` (`compute_fabric.dag:377`) checks *isolation only* — Phase 1 is "add the thread-count / Pareto dimension to placement." So this phase is co-designed with Phase 3 (compute_fabric is the provisioning interface; the runner *declares* the offer, the scheduler *consumes* the placement — one market, two readers). DFS `PlacementSupplyRow` + `CpuDeploymentFacts` (`cpu/types.dag:42`) before extending; do **not** invent `DeploymentFacts`. +- **The width-fold.** Schedule stays the pure partial order; a peripheral realizer folds it against the `HardwareBudget` → actual width, a Pareto pick over `{wall-time↓, peak-memory↓}` bounded by `width ≤ cores` — reusing `std.pareto` + `RealizationObjective.goals` (already `List` — wiring carriers that already speak the same vocabulary, not inventing one). +- **Bound the spawner** (`claim_executor.rs:403-410`) by `available_parallelism`/budget — fixes the *dual* hazard: under-parallel (serial corpus) **and** over-parallel (unbounded spawn on a wide batch). +- **Determinism:** schedule topology stays witness-stable; width/shard are peripheral, checked by given-these-facts witnesses. - **Dissolution trigger:** the corpus is ≥2 runnables in the schedule; the spawner reads a budget. --- ## Phase 1.5 — Holistic cleanups (note 4) · mostly parallel to 1 -- **Wire `affected_set` into the corpus + gate roster** (audit lever #1). The compile-time, fail-closed - `v2.lens.affected_set` + runner + superset proof exist and are green but unimported. Skip only on a - content-addressed match to a verified-green baseline; **fail closed** on any miss. Biggest wall-clock - lever on PR branches. (Independent of Phase 0.) -- **`total` = measured critical-path roll-up** (note 4): weights a short phase *on the critical path* - (the perturb gate) at full cost and a short phase *hidden under a parallel branch* at ~0. (Needs Phase 0.) -- **Collapse the perturb cold-recompile** (~14 s, fail-fast root, critical path): resolve the planted - (fresh-name, unimported) module against the green compile's index instead of `cp -r dsl` + cold rebuild; - preserves the discriminating-red (§5). (Independent of Phase 0.) +- **Wire `affected_set` into the corpus + gate roster** (audit lever #1). The compile-time, fail-closed `v2.lens.affected_set` + runner + superset proof exist and are green but unimported. Skip only on a content-addressed match to a verified-green baseline; **fail closed** on any miss. Biggest wall-clock lever on PR branches. (Independent of Phase 0.) +- **`total` = measured critical-path roll-up** (note 4): weights a short phase *on the critical path* (the perturb gate) at full cost and a short phase *hidden under a parallel branch* at ~0. (Needs Phase 0.) +- **Collapse the perturb cold-recompile** (~14 s, fail-fast root, critical path): resolve the planted (fresh-name, unimported) module against the green compile's index instead of `cp -r dsl` + cold rebuild; preserves the discriminating-red (§5). (Independent of Phase 0.) --- @@ -240,116 +125,47 @@ this. NB: the timing *primitives already exist* — this is **"wire the existing **Depends on:** Phase 0 (cost-aware reach needs measured recompute cost). -- **Land the planner the catalog header already promises** (`cache_interface.dag:21` "downstream cache - lookup planner"; dissolve-on-arrival "when first consumer lands"). Given the `CacheInterfaceFacts` rows + - a deployment's *available* backends, emit a `CacheLayerPlan` (type exists, `:91`): L1 in-process → L2 - sccache / cargo target / resolved-graph → L3 CAS. -- **One content-address lookup kernel, N backends bound by `transport_encoding`** (§4 one-kernel/N-handlers). - The in-process memo is just the `InProcess` row of the *same* kernel. **Converge the key derivations onto - ONE content-addressed subject identity.** Today there are *four* keyings: `parse_cache` by path, - `typed_module_cache` by module-name, `resolved_graph` by content-hash, `pure_call_memo` by address — **and - the `ExecutionReceipt` digest the whole three-dimension unification rests on is itself a 4th stub**: - `execution_receipt_digest` returns `receipt.work.id`, a hand-authored brand, not a content hash - (`compute_fabric.dag:588-594`). The §0 thesis ("all three dimensions keyed on one `ExecutionReceipt`") - is only *true once this digest becomes a real content hash aligned with the cache-subject identity* — so - this convergence is shared work between Phase 2 (cache) and the compute-fabric track, not cache-local. - The `key_derivation` axis exists for exactly this. -- **Cost-aware reach (§1).** Reach for a layer only when its predicted delta favors it: - `min(recompute, lookup + p(miss)·recompute)` — `read_latency` (InProcessNs…WanTensMs) is already a - modeled axis; `recompute` comes from Phase 0. A WAN CAS hit can lose to recomputing a cheap node. -- **Auto-wire (the operator's "user shouldn't wire it themselves").** The deployment declares which - backends it offers; the planner emits the wiring — dissolving the bespoke `if sccache --show-stats` - shell in `ci.yml` and the `GUNBC_RESOLVED_GRAPH_CACHE_DIR` env read. -- **Fail-closed (§5).** A backend probe that is absent/unauthorized falls through to the next layer → - ultimately recompute, **never** serves a stale/unverified hit (`CacheRejectReason` already enumerates - `BackendUnavailable`/`BackendUnauthorized`). Verdict-identity, not byte-identity, until the deferred - canonical-byte compare lands — so do NOT route emit/lower consumers through it yet. -- **First free measurement:** un-dormant `resolved_graph_cache` in CI (read by the seed, unset in - `ci.yml`) as a warm A/B. +- **Land the planner the catalog header already promises** (`cache_interface.dag:21` "downstream cache lookup planner"; dissolve-on-arrival "when first consumer lands"). Given the `CacheInterfaceFacts` rows + a deployment's *available* backends, emit a `CacheLayerPlan` (type exists, `:91`): L1 in-process → L2 sccache / cargo target / resolved-graph → L3 CAS. +- **One content-address lookup kernel, N backends bound by `transport_encoding`** (§4 one-kernel/N-handlers). The in-process memo is just the `InProcess` row of the *same* kernel. **Converge the key derivations onto ONE content-addressed subject identity.** Today there are *four* keyings: `parse_cache` by path, `typed_module_cache` by module-name, `resolved_graph` by content-hash, `pure_call_memo` by address — **and the `ExecutionReceipt` digest the whole three-dimension unification rests on is itself a 4th stub**: `execution_receipt_digest` returns `receipt.work.id`, a hand-authored brand, not a content hash (`compute_fabric.dag:588-594`). The §0 thesis ("all three dimensions keyed on one `ExecutionReceipt`") is only *true once this digest becomes a real content hash aligned with the cache-subject identity* — so this convergence is shared work between Phase 2 (cache) and the compute-fabric track, not cache-local. The `key_derivation` axis exists for exactly this. +- **Cost-aware reach (§1).** Reach for a layer only when its predicted delta favors it: `min(recompute, lookup + p(miss)·recompute)` — `read_latency` (InProcessNs…WanTensMs) is already a modeled axis; `recompute` comes from Phase 0. A WAN CAS hit can lose to recomputing a cheap node. +- **Auto-wire (the operator's "user shouldn't wire it themselves").** The deployment declares which backends it offers; the planner emits the wiring — dissolving the bespoke `if sccache --show-stats` shell in `ci.yml` and the `GUNBC_RESOLVED_GRAPH_CACHE_DIR` env read. +- **Fail-closed (§5).** A backend probe that is absent/unauthorized falls through to the next layer → ultimately recompute, **never** serves a stale/unverified hit (`CacheRejectReason` already enumerates `BackendUnavailable`/`BackendUnauthorized`). Verdict-identity, not byte-identity, until the deferred canonical-byte compare lands — so do NOT route emit/lower consumers through it yet. +- **First free measurement:** un-dormant `resolved_graph_cache` in CI (read by the seed, unset in `ci.yml`) as a warm A/B. - **Dissolution trigger:** `ci.yml` carries no hand-wired cache shell; one lookup kernel; one subject key. --- ## Phase 3 — Infra / deployment onto `.dag` (srv1 / srv2) · the second ask -**Goal:** model the actual infra/deployment — runner config, access, host config — as **data**, dissolving -bespoke `ci.yml` shell + manual runner setup. **"Get CI onto `.dag`" = instantiate `compute_fabric` for -srv1/srv2:** a self-hosted runner is one `ComputeOffer`; GHA-hosted, `Ubicloud`, `GcloudRun` are others -(already enumerated, `compute_fabric.dag:71`). This meets note 1 at the placement carrier — the offer the -runner *declares* is the budget Phase 1's scheduler *consumes*. - -**§3 boundary — THREE tiers, not two (refined after the #5177 review).** The operator's rule: keep the -*generic* "CI runner" cleanly apart from *our* CI runner; CI does not need to know our fleet. So: - -- **3a-generic — "CI runner" in the abstract (any project).** What we expect *any* CI runner to do, - project-agnostic: **a workflow triggered by an event** (`trigger → workflow`), realized per platform. - The GHA realization already exists — `Workflow{ on: List, jobs }` + `WorkflowTrigger` - (`actions.dag:56,79`) and `RunnerSpec` (`:233`). The **generic `offer → RunnerSpec` projection** - (`runner_spec_from_offer`, kernel/arch → labels) belongs HERE, next to `RunnerSpec` in the generalized - layer — it works for *any* fleet offer. **This tier MUST NOT import a concrete SKU - (`extdeps.cpu.ampere`) or name srv1/srv2.** (GitLab/Buildkite/etc. would be sibling platform handlers — - one generic interface, N realizations, §2/§4.) -- **3a-ours — OUR gunbc CI runner (our repo's META-modeling).** OUR workflow instance + OUR fleet: the - srv1/srv2 *instantiation* (the Ampere-Altra `ComputeOffer`, the `gunbc-ci-fleet` identity, the - per-thread Hz). This **must live in a file that is gunbc's own meta-model** (`dsl/gunbc/ci_*`), and it - *consumes* the 3a-generic interface — it is where the concrete SKU import is legitimate. The srv1/srv2 - instantiation meta-model is public-in-our-repo; only secrets cross into ctrl. -- **3b — ctrl concrete fleet (private).** Access creds, runner registration tokens, truly-secret per-host - config — **ctrl `plans.fabric.operator_fleet`** (`compute_fabric.dag:5`; `hardware_selection.dag:8`; - memory `idea-pr-compiler-ctrl-boundary`). Concrete rows instantiated against the 3a-ours meta-model. - -**⚠️ #5177 needs this rework (do right after it merges).** `dsl/gunbc/ci_runner.dag` as merged **fuses -3a-generic with 3a-ours**: the generic `runner_spec_from_offer` projection + kernel/arch label tables sit -in the *same module* as our concrete fleet (`gunbc_ci_cpu = altra_q6430_catalog`, `gunbc_ci_host_identity -= "gunbc-ci-fleet"`), and it `import extdeps.cpu.ampere` — a concrete SKU — into what should be the -generic interface. Split it: **generic projection → the generalized layer beside `RunnerSpec`** (no SKU -import, no fleet rows); **our fleet offer → a `dsl/gunbc/` meta-model file** that consumes the generic -projection. Keep the generic interface MINIMAL (trigger→workflow + offer→RunnerSpec) — "CI doesn't need -to know everything." ci.yml stays generated + byte-drift-gated (`expected_ci_yml()` -`dsl/gunbc/ci_yaml_emit.dag:9`, gate `dsl/tools/ci_yaml_gate.dag`); the emit consumes *our* runner spec, -which is *our* fleet offer projected through the *generic* seam. ⚠️ also delete the stale -`extdeps/github/ci.dag:7` "hand-edited, not generated" comment. - -**Dissolution trigger:** `.github/workflows/ci.yml` is emitted from a `.dag` spec whose runner block is -*our* fleet offer projected through the *generic* `offer → RunnerSpec` seam (no hand-authored runner -block, no fleet SKU in the generic tier); the `HardwareBudget` the scheduler reads is the one *our* offer -declares. +**Goal:** model the actual infra/deployment — runner config, access, host config — as **data**, dissolving bespoke `ci.yml` shell + manual runner setup. **"Get CI onto `.dag`" = instantiate `compute_fabric` for srv1/srv2:** a self-hosted runner is one `ComputeOffer`; GHA-hosted, `Ubicloud`, `GcloudRun` are others (already enumerated, `compute_fabric.dag:71`). This meets note 1 at the placement carrier — the offer the runner *declares* is the budget Phase 1's scheduler *consumes*. + +**§3 boundary — THREE tiers, not two (refined after the #5177 review).** The operator's rule: keep the *generic* "CI runner" cleanly apart from *our* CI runner; CI does not need to know our fleet. So: + +- **3a-generic — "CI runner" in the abstract (any project).** What we expect *any* CI runner to do, project-agnostic: **a workflow triggered by an event** (`trigger → workflow`), realized per platform. The GHA realization already exists — `Workflow{ on: List, jobs }` + `WorkflowTrigger` (`actions.dag:56,79`) and `RunnerSpec` (`:233`). The **generic `offer → RunnerSpec` projection** (`runner_spec_from_offer`, kernel/arch → labels) belongs HERE, next to `RunnerSpec` in the generalized layer — it works for *any* fleet offer. **This tier MUST NOT import a concrete SKU (`extdeps.cpu.ampere`) or name srv1/srv2.** (GitLab/Buildkite/etc. would be sibling platform handlers — one generic interface, N realizations, §2/§4.) +- **3a-ours — OUR gunbc CI runner (our repo's META-modeling).** OUR workflow instance + OUR fleet: the srv1/srv2 *instantiation* (the Ampere-Altra `ComputeOffer`, the `gunbc-ci-fleet` identity, the per-thread Hz). This **must live in a file that is gunbc's own meta-model** (`dsl/gunbc/ci_*`), and it *consumes* the 3a-generic interface — it is where the concrete SKU import is legitimate. The srv1/srv2 instantiation meta-model is public-in-our-repo; only secrets cross into ctrl. +- **3b — ctrl concrete fleet (private).** Access creds, runner registration tokens, truly-secret per-host config — **ctrl `plans.fabric.operator_fleet`** (`compute_fabric.dag:5`; `hardware_selection.dag:8`; memory `idea-pr-compiler-ctrl-boundary`). Concrete rows instantiated against the 3a-ours meta-model. + +**⚠️ #5177 needs this rework (do right after it merges).** `dsl/gunbc/ci_runner.dag` as merged **fuses 3a-generic with 3a-ours**: the generic `runner_spec_from_offer` projection + kernel/arch label tables sit in the *same module* as our concrete fleet (`gunbc_ci_cpu = altra_q6430_catalog`, `gunbc_ci_host_identity = "gunbc-ci-fleet"`), and it `import extdeps.cpu.ampere` — a concrete SKU — into what should be the generic interface. Split it: **generic projection → the generalized layer beside `RunnerSpec`** (no SKU import, no fleet rows); **our fleet offer → a `dsl/gunbc/` meta-model file** that consumes the generic projection. Keep the generic interface MINIMAL (trigger→workflow + offer→RunnerSpec) — "CI doesn't need to know everything." ci.yml stays generated + byte-drift-gated (`expected_ci_yml()` `dsl/gunbc/ci_yaml_emit.dag:9`, gate `dsl/tools/ci_yaml_gate.dag`); the emit consumes *our* runner spec, which is *our* fleet offer projected through the *generic* seam. ⚠️ also delete the stale `extdeps/github/ci.dag:7` "hand-edited, not generated" comment. + +**Dissolution trigger:** `.github/workflows/ci.yml` is emitted from a `.dag` spec whose runner block is *our* fleet offer projected through the *generic* `offer → RunnerSpec` seam (no hand-authored runner block, no fleet SKU in the generic tier); the `HardwareBudget` the scheduler reads is the one *our* offer declares. --- ## Dependency-ordered spine (foundation → end state) -The work-item view of the phases above, ordered by dependency toward the acceptance gate (absorbed from -the former quick-ant-298 roadmap; maps onto the phases, does not replace them). +The work-item view of the phases above, ordered by dependency toward the acceptance gate (absorbed from the former quick-ant-298 roadmap; maps onto the phases, does not replace them). - **F1** scheduler gives heavy nodes the budgeted width — *#5421 merged* (= Phase 1 width landing). -- **F2/F3** key-completeness lens (`ToolchainChange ∈ triggers ⟹ input ∈ inputs_considered`) + - `resolved_graph` keyed by construction — *#5423, in review* (= the Phase 2 key-derivation axis, spec-level). -- **P1 — honest keys, verified by execution** *(deps F2,F3)*: realizer-key lens (executed digest ⊇ - declared `inputs_considered`, RED otherwise — would have caught the `from_utf8_lossy` collision); - stable transform-id (reproducible source/commit/tree hash, not binary bytes); census parity for - `parse_table_memo`. (= Phase 2 "converge key derivations".) -- **P2 — one door: caching by inhabitance** *(deps P1)*: `realize(subject)` as the sole API; eliminate - raw bypass (`build_multi_entry_index`, hand-rolled `ParseTable` HashMap → inhabited via `realize`, - DESIGN §6's own example). (= Phase 2 one-kernel/N-backends.) -- **P3 — reach → layer + completeness fail-closed** *(deps P2)* — **the core ask / the acceptance gate**: - reach analysis lens (consumer set + boundary → minimal sufficient `Placement`); completeness gate - (subject realized below reach → ERROR; non-redundant transform with no supplier at reach → ERROR — - **land the redundancy-only cut first**, cost half waits on §4); supplier provisioning + typed request. -- **P4 — economic tier** *(deps Phase 0 measurement)*: per-transform measured cost (`PerformanceReceipt` - → cost-aware reach); `Materialization` = `Recompute | Memoize | Share` chosen by measured cost. -- **P5 — v2 dissolution** *(deps B2)*: `content(T) = content_hash(subgraph)` native; dissolves the - binary-hash/version-string approximations and makes P1's spec↔realizer check structural. - -**External blockers (track as work-items):** **B1** #5295 generic-instantiation (FreeMonoid cached -without variants — itself an under-keyed in-proc cache) → gates cross-shard `Share` (Phase 2.2). **B2** -v2 cross-tree content-hash ("increment 4", the `ContentHash` subject on `RealizedStep`; cf. the -`execution_receipt_digest` stub at `compute_fabric.dag:588-594`) → gates P5. - -**Critical path:** `F2/F3 → P1 → P2 → P3 (redundancy cut) → P3 supplier`. `P1.census`, `P4`, and -Phase-2 sub-items parallelize off it; cross-shard `Share` and P5 wait on B1/B2. The redundancy-only P3 -cut is the earliest point "uncached non-redundant work is an error" is truthful — it needs reach, not -the cost model. +- **F2/F3** key-completeness lens (`ToolchainChange ∈ triggers ⟹ input ∈ inputs_considered`) + `resolved_graph` keyed by construction — *#5423, in review* (= the Phase 2 key-derivation axis, spec-level). +- **P1 — honest keys, verified by execution** *(deps F2,F3)*: realizer-key lens (executed digest ⊇ declared `inputs_considered`, RED otherwise — would have caught the `from_utf8_lossy` collision); stable transform-id (reproducible source/commit/tree hash, not binary bytes); census parity for `parse_table_memo`. (= Phase 2 "converge key derivations".) +- **P2 — one door: caching by inhabitance** *(deps P1)*: `realize(subject)` as the sole API; eliminate raw bypass (`build_multi_entry_index`, hand-rolled `ParseTable` HashMap → inhabited via `realize`, DESIGN §6's own example). (= Phase 2 one-kernel/N-backends.) +- **P3 — reach → layer + completeness fail-closed** *(deps P2)* — **the core ask / the acceptance gate**: reach analysis lens (consumer set + boundary → minimal sufficient `Placement`); completeness gate (subject realized below reach → ERROR; non-redundant transform with no supplier at reach → ERROR — **land the redundancy-only cut first**, cost half waits on §4); supplier provisioning + typed request. +- **P4 — economic tier** *(deps Phase 0 measurement)*: per-transform measured cost (`PerformanceReceipt` → cost-aware reach); `Materialization` = `Recompute | Memoize | Share` chosen by measured cost. +- **P5 — v2 dissolution** *(deps B2)*: `content(T) = content_hash(subgraph)` native; dissolves the binary-hash/version-string approximations and makes P1's spec↔realizer check structural. + +**External blockers (track as work-items):** **B1** #5295 generic-instantiation (FreeMonoid cached without variants — itself an under-keyed in-proc cache) → gates cross-shard `Share` (Phase 2.2). **B2** v2 cross-tree content-hash ("increment 4", the `ContentHash` subject on `RealizedStep`; cf. the `execution_receipt_digest` stub at `compute_fabric.dag:588-594`) → gates P5. + +**Critical path:** `F2/F3 → P1 → P2 → P3 (redundancy cut) → P3 supplier`. `P1.census`, `P4`, and Phase-2 sub-items parallelize off it; cross-shard `Share` and P5 wait on B1/B2. The redundancy-only P3 cut is the earliest point "uncached non-redundant work is an error" is truthful — it needs reach, not the cost model. ## Sequencing & dispatch @@ -367,62 +183,39 @@ the cost model. ``` | Phase | Depends on | Intricacy / Volume | Notes | -|---|---|---|---| +| --- | --- | --- | --- | | 0 keystone | — | high / medium | root of everything quantitative; load-bearing seam (`v1_interpreter.rs`, escalate per DESIGN) | | 1 visible parallelism + width | 0 | high / medium | shares `HardwareBudget` carrier with 3a | | 1.5a affected_set | — | medium / small | fail-closed; can start now | -| 1.5b critical-path total | 0 | medium / small | | +| 1.5b critical-path total | 0 | medium / small | | | 1.5c perturb collapse | — | medium / small | can start now | | 2 cache planner | 0 | high / large | converges 3 key derivations; first catalog consumer | | 3a runner schema + ci.yml gen | (1 for budget carrier) | high / large | public; extends `CiFloorSpec` emission | | 3b ctrl srv1/srv2 | 3a | — | **private `~/ctrl`**, separate PR | -**Start-now lanes (no measurement dependency):** 1.5a (affected_set), 1.5c (perturb), and 3a schema -groundwork. **Critical path:** Phase 0 → 1 / 2. +**Start-now lanes (no measurement dependency):** 1.5a (affected_set), 1.5c (perturb), and 3a schema groundwork. **Critical path:** Phase 0 → 1 / 2. --- ## Guardrails for every worker (DESIGN) -- **Pure central spec, peripheral measured realization** (the §3 invariant above). Anything measured is - peripheral — never in the schedule topology the `schedule_eq` witnesses pin. -- **DFS existing carriers before minting** (§2/§3): `PlacementSupplyRow`, `CpuDeploymentFacts`, - `RunnerSpec`, the cache catalog, `std.pareto`, `RealizationObjective.goals`. The vocabulary mostly - exists — wire it, don't re-coin it. (Background verification specifically flagged: do not invent a fresh - `DeploymentFacts`.) -- **Rows, not Rust** — express new schedule/cache/runner facts as data; do not cement the seed to satisfy - a ratchet (the ratchet is downstream of substrate migration). -- **v2-benefit test (§7)** — the durable artifact is `.dag` that v2 inherits; the Rust seed is only the - proving *handler*. A deliverable that is a Rust patch with no `.dag` model failed. (See the §0 "v2 is the - target" principle.) -- **Fail-closed (§5)** + **purity oracle** on every memo/measurement (byte-identical warm-vs-cold; verdict - identical instrumented-vs-not). A bounded "forever" ≠ an "unknown" error. -- **Green by execution, not spec-without-execution.** A real consumer runs green + a discriminating input - goes red. Typecheck + grep are not consumers. -- **Each phase lands with a named dissolution trigger; the mark is on the carrier.** This doc is - coordination only; delete its entry when the carrier records the fact. -- **Load-bearing files** (DESIGN-named pipeline stages, substrate types, gates: `v1_interpreter.rs`, - `cli_run.rs`, the scheduler, `realization_schedule.dag`) carry a higher bar — escalate before touching - under a brief that pre-dates the relevant model PR. +- **Pure central spec, peripheral measured realization** (the §3 invariant above). Anything measured is peripheral — never in the schedule topology the `schedule_eq` witnesses pin. +- **DFS existing carriers before minting** (§2/§3): `PlacementSupplyRow`, `CpuDeploymentFacts`, `RunnerSpec`, the cache catalog, `std.pareto`, `RealizationObjective.goals`. The vocabulary mostly exists — wire it, don't re-coin it. (Background verification specifically flagged: do not invent a fresh `DeploymentFacts`.) +- **Rows, not Rust** — express new schedule/cache/runner facts as data; do not cement the seed to satisfy a ratchet (the ratchet is downstream of substrate migration). +- **v2-benefit test (§7)** — the durable artifact is `.dag` that v2 inherits; the Rust seed is only the proving *handler*. A deliverable that is a Rust patch with no `.dag` model failed. (See the §0 "v2 is the target" principle.) +- **Fail-closed (§5)** + **purity oracle** on every memo/measurement (byte-identical warm-vs-cold; verdict identical instrumented-vs-not). A bounded "forever" ≠ an "unknown" error. +- **Green by execution, not spec-without-execution.** A real consumer runs green + a discriminating input goes red. Typecheck + grep are not consumers. +- **Each phase lands with a named dissolution trigger; the mark is on the carrier.** This doc is coordination only; delete its entry when the carrier records the fact. +- **Load-bearing files** (DESIGN-named pipeline stages, substrate types, gates: `v1_interpreter.rs`, `cli_run.rs`, the scheduler, `realization_schedule.dag`) carry a higher bar — escalate before touching under a brief that pre-dates the relevant model PR. ## Open decisions to confirm before scoping the affected phase -1. **Placement/budget carrier** — extend `compute_fabric`'s `satisfies` + `PlacementSupplyRow` with the - thread-count/Pareto dimension (the width decision = a placement decision), vs a sibling carrier? (DFS - task in Phase 1 / 3a.) Do not invent `DeploymentFacts`. -2. **The $/billing cost axis crosses the std↔product line.** std `CostAccount` carries `{time,space,power}`; - the $ axis (`CostClass`, `MoneyMicros`) lives in product `compute_fabric`. Confirm: the std schedule's - objective stays `{time,space,power}`; the **peripheral host realizer** combines it with the product $ - axis for the full Pareto pick. (Keeps std product-free.) -3. **Cache planner timing** — the *plan* (which layers, what order) can be compile-time data; only the - *availability probe* is runtime/peripheral. Confirm the split when scoping Phase 2. -4. **Runner-label vocabulary** — how far to close `SelfHosted{labels: List}` toward a typed - topology / a `compute_fabric` offer (3a) without over-fitting to srv1/srv2 (which live in ctrl). -5. **Sharding lives in the demand model — Phase 1 and 3 meet at the parallelism shape, not just the - budget.** `ParallelismShape = ... | IndependentShards{shard_count} | PartitionedReduce{...}` - (`compute_fabric.dag:280-289`) already exists, and the corpus `RunnableDiscoveryBatch` is a **degenerate - (unsharded) projection of a `WorkDemand` whose `parallelism = IndependentShards`** (independent - witnesses). So the easy case needs no new stubs; the `Partitioner`/`Reducer`/`SymbolicCost = Node` - forwards (`:48-58`) are only for the harder `PartitionedReduce` (whole-tree compile → reduce verdicts). - Decide: does Phase 1 express the corpus as an `IndependentShards` `WorkDemand` (preferred — reuses the - carrier) vs a scheduler-local shard list? +1. **Placement/budget carrier** — extend `compute_fabric`'s `satisfies` + `PlacementSupplyRow` with the thread-count/Pareto dimension (the width decision = a placement decision), vs a sibling carrier? (DFS task in Phase 1 / 3a.) Do not invent `DeploymentFacts`. +2. **The $/billing cost axis crosses the std↔product line.** std `CostAccount` carries `{time,space,power}`; the $ axis (`CostClass`, `MoneyMicros`) lives in product `compute_fabric`. Confirm: the std schedule's objective stays `{time,space,power}`; the **peripheral host realizer** combines it with the product $ axis for the full Pareto pick. (Keeps std product-free.) +3. **Cache planner timing** — the *plan* (which layers, what order) can be compile-time data; only the *availability probe* is runtime/peripheral. Confirm the split when scoping Phase 2. +4. **Runner-label vocabulary** — how far to close `SelfHosted{labels: List}` toward a typed topology / a `compute_fabric` offer (3a) without over-fitting to srv1/srv2 (which live in ctrl). +5. **Sharding lives in the demand model — Phase 1 and 3 meet at the parallelism shape, not just the budget.** `ParallelismShape = ... | IndependentShards{shard_count} | PartitionedReduce{...}` (`compute_fabric.dag:280-289`) already exists, and the corpus `RunnableDiscoveryBatch` is a **degenerate (unsharded) projection of a `WorkDemand` whose `parallelism = IndependentShards`** (independent witnesses). So the easy case needs no new stubs; the `Partitioner`/`Reducer`/`SymbolicCost = Node` forwards (`:48-58`) are only for the harder `PartitionedReduce` (whole-tree compile → reduce verdicts). Decide: does Phase 1 express the corpus as an `IndependentShards` `WorkDemand` (preferred — reuses the carrier) vs a scheduler-local shard list? + +## Dissolution trigger (DESIGN §6) + +Delete this plan once the cost→schedule loop is closed — every pure transform's realize(T) is content-addressed by hash(inputs ⊕ content(T)) and materialized at its minimal Placement, CostAccount is fed by Measured basis (not hardcoded zero), schedule width is hardware-bounded and the spawner is bounded by available_parallelism, the cache catalog has live runtime consumers, and a non-redundant transform with no cache supplier at its reach is a located typed ERROR — so the substrate is measurement-fed rather than input-starved. diff --git a/docs/plans/resolver-type-name-collision-wall.md b/docs/plans/resolver-type-name-collision-wall.md index 68e8fe013b3..a6b1d368c88 100644 --- a/docs/plans/resolver-type-name-collision-wall.md +++ b/docs/plans/resolver-type-name-collision-wall.md @@ -1,59 +1,32 @@ # Resolver type-name-collision wall (§5 construction wall) — model-before-implement -Status: **MODEL — SIGNED (parent bright-stag, 2026-06-23).** The model (mechanism + Q2 policy + -activation) is signed; **no resolver edit lands** until the §4 grounding de-fork is clean — the -resolver guard is a separate, operator-gated future PR that lands on the de-forked tree. This -document is the signed model; §3/§4 record the final ruling. +Status: **MODEL — SIGNED (parent bright-stag, 2026-06-23).** The model (mechanism + Q2 policy + activation) is signed; **no resolver edit lands** until the §4 grounding de-fork is clean — the resolver guard is a separate, operator-gated future PR that lands on the de-forked tree. This document is the signed model; §3/§4 record the final ruling. -Owner: jolly-ant-231 (deepest resolver context from the A1 diagnosis). Capstone of the std -de-fork lane. Q2 evidence: `docs/plans/dsl-v2-defork-audit.md` §2A (executed distribution). +Owner: jolly-ant-231 (deepest resolver context from the A1 diagnosis). Capstone of the std de-fork lane. Q2 evidence: `docs/plans/dsl-v2-defork-audit.md` §2A (executed distribution). --- ## 1. The hole this wall closes (grounding) -The A1 (#5615) incident — `type 'EqualsClaim' not found in scope` on -`src/v2/workflow/affected_set_floor_runner_test.dag` — was a **fail-OPEN in the resolver** -(DESIGN §5): a wrong type resolution passed silently as a different, plausible binding. +The A1 (#5615) incident — `type 'EqualsClaim' not found in scope` on `src/v2/workflow/affected_set_floor_runner_test.dag` — was a **fail-OPEN in the resolver** (DESIGN §5): a wrong type resolution passed silently as a different, plausible binding. Mechanism (proven by execution during the diagnosis; receipt below): -- The per-module type scope (`TypeEnv.bindings`) is a `HashMap>` keyed by - the **interned id of the UNQUALIFIED type name** — the intern table is global, so two - module-level types sharing a short name (`v2.std.verification.TestClaim` the Disj coproduct - vs `std.verification.TestClaim` the Conj record) hash to the **same key**. -- `import_bindings` is assembled by folding each imported module's bindings with a blind - `v1_rt::rc_map_merge` (`v1_compiler_infer.rs` ~11799 and the duplicate ~12393). **Map merge - overwrites on duplicate key — last writer wins, no diagnostic.** One authority silently - shadows the other. -- Because variant-constructor registration (`build_module_context`'s `variant_fold`, ~12894) - only fires for `Disj` bindings, when the **record** won the `TestClaim` slot the coproduct's - constructors (`EqualsClaim`, `StructuralEqualsClaim`, …) were never registered → "not found - in scope". A1 was an innocent trigger: it merely grew the test's import-closure to include - `std.verification(dsl)` (via `gunbc.ci_failure_class → extdeps.cache.sccache → - std.cache_interface → std.verification`). - -The existing **`VariantCollision`** guard (`v1_std_core.rs:420`, -`VariantCollision { variant, enum1, enum2, span }`; emitted in `variant_fold` ~12908) already -fails-closed on two imported coproducts sharing a **variant** name. It does **not** cover the -level above: two modules contributing the same **type/enum name** to one closure. The wall is -that guard lifted one level up — the §5 principle of making the bad state *unwritable* rather -than letting it resolve to a plausible wrong binding. - -`#5640` (the `TestClaim → AssertionClaim` rename) dissolved the single instance. The wall -makes the **class** unwritable so the next closure-expanding PR cannot re-arm it. - -Decidability: a closure exporting two distinct authorities under one unqualified name is a -**decidable** condition (finite set of `(name_id, declaring_file)` pairs), so this is a §5 -*wall now*, not a forever-ratchet. "never" is honest here. +- The per-module type scope (`TypeEnv.bindings`) is a `HashMap>` keyed by the **interned id of the UNQUALIFIED type name** — the intern table is global, so two module-level types sharing a short name (`v2.std.verification.TestClaim` the Disj coproduct vs `std.verification.TestClaim` the Conj record) hash to the **same key**. +- `import_bindings` is assembled by folding each imported module's bindings with a blind `v1_rt::rc_map_merge` (`v1_compiler_infer.rs` ~11799 and the duplicate ~12393). **Map merge overwrites on duplicate key — last writer wins, no diagnostic.** One authority silently shadows the other. +- Because variant-constructor registration (`build_module_context`'s `variant_fold`, ~12894) only fires for `Disj` bindings, when the **record** won the `TestClaim` slot the coproduct's constructors (`EqualsClaim`, `StructuralEqualsClaim`, …) were never registered → "not found in scope". A1 was an innocent trigger: it merely grew the test's import-closure to include `std.verification(dsl)` (via `gunbc.ci_failure_class → extdeps.cache.sccache → std.cache_interface → std.verification`). + +The existing **`VariantCollision`** guard (`v1_std_core.rs:420`, `VariantCollision { variant, enum1, enum2, span }`; emitted in `variant_fold` ~12908) already fails-closed on two imported coproducts sharing a **variant** name. It does **not** cover the level above: two modules contributing the same **type/enum name** to one closure. The wall is that guard lifted one level up — the §5 principle of making the bad state *unwritable* rather than letting it resolve to a plausible wrong binding. + +`#5640` (the `TestClaim → AssertionClaim` rename) dissolved the single instance. The wall makes the **class** unwritable so the next closure-expanding PR cannot re-arm it. + +Decidability: a closure exporting two distinct authorities under one unqualified name is a **decidable** condition (finite set of `(name_id, declaring_file)` pairs), so this is a §5 *wall now*, not a forever-ratchet. "never" is honest here. --- ## 2. Mechanism (the model) -Replace the blind `rc_map_merge` of type bindings, at **both** import-binding assembly sites -(`v1_compiler_infer.rs` ~11761 and ~12355 — themselves a §2 duplication this work should -dissolve into **one** shared helper), with a **collision-checking merge**: +Replace the blind `rc_map_merge` of type bindings, at **both** import-binding assembly sites (`v1_compiler_infer.rs` ~11761 and ~12355 — themselves a §2 duplication this work should dissolve into **one** shared helper), with a **collision-checking merge**: ``` merge_type_bindings(acc, incoming, policy) -> { bindings, collisions } @@ -72,21 +45,11 @@ merge_type_bindings(acc, incoming, policy) -> { bindings, collisions } Where: -- `same_authority(a, b)` ≡ `a.resolved.span.file == b.resolved.span.file` (one declaring file - reached via multiple import paths is the SAME authority — a benign re-export, must NOT - flag). `TypeBinding` is `{ name, resolved: Rc, provenance }` and `Node.span.file` - carries the declaring file, so two-authorities-vs-one-re-export is distinguishable today — - **no new field required.** -- `TypeNameCollision` is a new `CompilerDiagnostic` variant modeled exactly on - `VariantCollision`: `{ name: String, module_a: String, module_b: String, span }`, classified - **blocking** (`is_error_diagnostic` true), so it fails the resolve/typecheck closed with a - located, typed message — the §5 "loud error, never a warning". -- Determinism: on collision keep the **first-seen** binding (stable under the existing - dep-order traversal) so the error set is reproducible regardless of which authority "would - have won" the old overwrite. - -This is one mechanism; §3 (the policy) and §4 (activation) are knobs on it, not separate -machinery. +- `same_authority(a, b)` ≡ `a.resolved.span.file == b.resolved.span.file` (one declaring file reached via multiple import paths is the SAME authority — a benign re-export, must NOT flag). `TypeBinding` is `{ name, resolved: Rc, provenance }` and `Node.span.file` carries the declaring file, so two-authorities-vs-one-re-export is distinguishable today — **no new field required.** +- `TypeNameCollision` is a new `CompilerDiagnostic` variant modeled exactly on `VariantCollision`: `{ name: String, module_a: String, module_b: String, span }`, classified **blocking** (`is_error_diagnostic` true), so it fails the resolve/typecheck closed with a located, typed message — the §5 "loud error, never a warning". +- Determinism: on collision keep the **first-seen** binding (stable under the existing dep-order traversal) so the error set is reproducible regardless of which authority "would have won" the old overwrite. + +This is one mechanism; §3 (the policy) and §4 (activation) are knobs on it, not separate machinery. --- @@ -94,26 +57,15 @@ machinery. **One predicate, one boolean knob** — `policy.flags(existing, incoming)`: -- **flag-ANY** (`require_structural_divergence = false`): - `flags = true` for any two distinct authorities (different declaring files) under one name. - Even a **byte/structurally-identical mirror** flags — because it is still *two authorities - for one concept*, the §3 single-authority violation, just benign-looking. It remains a - writable re-fork surface: nothing stops the two copies drifting apart later (which is exactly - how A1's landmine formed). - -- **flag-DIVERGENT** (`require_structural_divergence = true`): - `flags = structural_inequality(existing.resolved, incoming.resolved)`. - Fires only when the two definitions actually differ (connective and/or children) — like the - Disj-coproduct vs Conj-record case. True mirrors are **excused**. +- **flag-ANY** (`require_structural_divergence = false`): `flags = true` for any two distinct authorities (different declaring files) under one name. Even a **byte/structurally-identical mirror** flags — because it is still *two authorities for one concept*, the §3 single-authority violation, just benign-looking. It remains a writable re-fork surface: nothing stops the two copies drifting apart later (which is exactly how A1's landmine formed). +- **flag-DIVERGENT** (`require_structural_divergence = true`): `flags = structural_inequality(existing.resolved, incoming.resolved)`. Fires only when the two definitions actually differ (connective and/or children) — like the Disj-coproduct vs Conj-record case. True mirrors are **excused**. -`structural_inequality` is a normalized structural compare of the two resolved type Nodes -(connective + children names + field types), modulo span/occurrence — the same shape the -emitter's coercion homomorphism check already walks; no new comparison primitive needed. +`structural_inequality` is a normalized structural compare of the two resolved type Nodes (connective + children names + field types), modulo span/occurrence — the same shape the emitter's coercion homomorphism check already walks; no new comparison primitive needed. ### Trade-off (parent rules on the real distribution) -| | flag-ANY | flag-DIVERGENT | -|---|---|---| +| | flag-ANY | flag-DIVERGENT | +| --- | --- | --- | | Catches the A1 class (divergent shadow) | yes | yes | | Catches a *future* mirror that later drifts | yes (at fork time) | no (only after drift, when a closure re-imports both) | | De-fork scope it demands | **all** same-name pairs resolved: divergent → rename-apart, mirror → **merge to one authority** | only divergent pairs resolved; mirrors may stay | @@ -122,31 +74,12 @@ emitter's coercion homomorphism check already walks; no new comparison primitive ### RULED — `flag-ANY` (parent bright-stag, signed 2026-06-23) -**`require_structural_divergence = FALSE`.** Settled against the measured distribution (the -executed per-basename audit in `docs/plans/dsl-v2-defork-audit.md` §2A — `structural_inequality` -run over all 9 std basename pairs + a 351-entry floor-closure reachability BFS). The audit -confirmed the cant-unify-yet set (basenames needing a milestone *later than* the grounding -de-fork) is **{node, coercion} exactly** — no third stuck mirror — so flag-ANY does not block on -an un-unifiable pair. +**`require_structural_divergence = FALSE`.** Settled against the measured distribution (the executed per-basename audit in `docs/plans/dsl-v2-defork-audit.md` §2A — `structural_inequality` run over all 9 std basename pairs + a 351-entry floor-closure reachability BFS). The audit confirmed the cant-unify-yet set (basenames needing a milestone *later than* the grounding de-fork) is **{node, coercion} exactly** — no third stuck mirror — so flag-ANY does not block on an un-unifiable pair. Two consequences parent reconfirmed: -- **flag-ANY FIRES on byte-identical mirror shared type-names too** (the audit's 3 in `algebra`, - 3 in `integer`, 1 in `float`), not only on differing ones. This is **intended**: a - byte-identical mirror is still *two homes for one type* = the §3 single-authority violation and - a writable re-fork surface. So the de-fork must **merge even the mirrors** (delete the v2 copy, - repoint imports), and flag-ANY is exactly what forces that. flag-DIVERGENT would *tolerate* the - byte-mirrors — a standing §3 hole — so it is strictly worse here (it also still fires on every - grounding, sparing nothing). Mirrors are therefore **resolved by the de-fork, not exempted**. - -- **The exemption roster carries NO `{node, coercion}` entry — DROPPED as vacuous.** node and - coercion (and `logic`, and post-#5640 `verification`) share **zero** type names — only the - *basename* — so the type-name guard **never fires** on them. A roster entry for a collision the - mechanism cannot produce is a §5 inert scaffold (a dead line). Their collision is a - module-**basename** rename on the Route-C / v1-delete surface — a *different* mechanism, still - tracked (audit category-(c), `dissolve-on = v1-delete`), not by this guard. The guard's roster - is therefore **deliberately empty** — recorded here so its emptiness reads as a decision, not an - omission. (See §6.) +- **flag-ANY FIRES on byte-identical mirror shared type-names too** (the audit's 3 in `algebra`, 3 in `integer`, 1 in `float`), not only on differing ones. This is **intended**: a byte-identical mirror is still *two homes for one type* = the §3 single-authority violation and a writable re-fork surface. So the de-fork must **merge even the mirrors** (delete the v2 copy, repoint imports), and flag-ANY is exactly what forces that. flag-DIVERGENT would *tolerate* the byte-mirrors — a standing §3 hole — so it is strictly worse here (it also still fires on every grounding, sparing nothing). Mirrors are therefore **resolved by the de-fork, not exempted**. +- **The exemption roster carries NO `{node, coercion}` entry — DROPPED as vacuous.** node and coercion (and `logic`, and post-#5640 `verification`) share **zero** type names — only the *basename* — so the type-name guard **never fires** on them. A roster entry for a collision the mechanism cannot produce is a §5 inert scaffold (a dead line). Their collision is a module-**basename** rename on the Route-C / v1-delete surface — a *different* mechanism, still tracked (audit category-(c), `dissolve-on = v1-delete`), not by this guard. The guard's roster is therefore **deliberately empty** — recorded here so its emptiness reads as a decision, not an omission. (See §6.) --- @@ -154,79 +87,37 @@ Two consequences parent reconfirmed: Two options: -- **Staged-enable** (guard lands dormant, flips fail-closed later): carries **dormant-guard - state** — a loaded mechanism left unwired. DESIGN §5/§6 names this an anti-pattern: an inert - guard is "coverage by illusion", a latent lie until the flip, and adds a flip-event to - sequence and a window where the guard exists but does not gate. - -- **Lands-already-green** (preferred): the de-fork lane first removes **every** collision the - chosen policy flags from the tree; *then* the guard lands **already fail-closed and green**. - No dormant state, no flip event. The guard's own green landing is **self-certifying**: it is - green only if zero flagged collisions remain, so merging it *proves* the tree is - collision-free under the policy. This is the §5 "wall lands live or not at all". - -Sequencing (hard dependency, RULED): **the grounding de-fork of the shared-type-name set -`{algebra, nat, effects, float, integer}` → guard lands flag-ANY, fail-closed, green, in one -PR.** Each of those five is merged to a single authority (delete the v2 copy / repoint, or the -operator grounding-unification design where the bodies diverge) — mirrors included (§3). The set -is fronted by the **LIVE pair `{algebra (75 floor entries), nat (4)}`** (their `std.` / -`v2.std.` co-occur in real floor closures today and silently fail-open — benign only because -they shadow record-with-record, not the coproduct-variant-drop that broke `verification` under -A1) and completed by the **latent `{effects, float, integer}`** (no co-occurring closure today, -but re-arm risks — exactly how `verification` went latent→LIVE under A1's closure expansion). -`verification` already cleared (#5640); `{node, coercion, logic}` are off this surface (zero -shared type-names). - -The guard PR is mergeable iff the full floor corpus resolves clean **with the guard active** — -which holds iff that five-basename de-fork is complete. Its green landing therefore -**self-certifies** the shared-type-name surface is collision-free: the wall is the **capstone** -of the de-fork lane, correctly located. No dormant-guard state, no flip event — lands-already-green. +- **Staged-enable** (guard lands dormant, flips fail-closed later): carries **dormant-guard state** — a loaded mechanism left unwired. DESIGN §5/§6 names this an anti-pattern: an inert guard is "coverage by illusion", a latent lie until the flip, and adds a flip-event to sequence and a window where the guard exists but does not gate. +- **Lands-already-green** (preferred): the de-fork lane first removes **every** collision the chosen policy flags from the tree; *then* the guard lands **already fail-closed and green**. No dormant state, no flip event. The guard's own green landing is **self-certifying**: it is green only if zero flagged collisions remain, so merging it *proves* the tree is collision-free under the policy. This is the §5 "wall lands live or not at all". + +Sequencing (hard dependency, RULED): **the grounding de-fork of the shared-type-name set `{algebra, nat, effects, float, integer}` → guard lands flag-ANY, fail-closed, green, in one PR.** Each of those five is merged to a single authority (delete the v2 copy / repoint, or the operator grounding-unification design where the bodies diverge) — mirrors included (§3). The set is fronted by the **LIVE pair `{algebra (75 floor entries), nat (4)}`** (their `std.` / `v2.std.` co-occur in real floor closures today and silently fail-open — benign only because they shadow record-with-record, not the coproduct-variant-drop that broke `verification` under A1) and completed by the **latent `{effects, float, integer}`** (no co-occurring closure today, but re-arm risks — exactly how `verification` went latent→LIVE under A1's closure expansion). `verification` already cleared (#5640); `{node, coercion, logic}` are off this surface (zero shared type-names). + +The guard PR is mergeable iff the full floor corpus resolves clean **with the guard active** — which holds iff that five-basename de-fork is complete. Its green landing therefore **self-certifies** the shared-type-name surface is collision-free: the wall is the **capstone** of the de-fork lane, correctly located. No dormant-guard state, no flip event — lands-already-green. --- ## 5. Proof plan (model-only; how it is proven by execution when authored) -Per DESIGN §5 ("done" = a real consumer green by execution + a discriminating input that goes -red when the behavior is wrong): - -- **GREEN-by-execution:** with the de-fork complete, run the exact floor closure - (`claim_executor --source-root dsl --source-root src/v2`, both orders) — full corpus resolves - clean **with the guard active**. (Baseline receipt already in hand from #1: post-rename, - `affected_set_floor_runner_test` PASSes both orders, 56 modules.) -- **Discriminating RED (the falsifier):** re-introduce a single synthetic same-name pair into a - test's closure and assert the guard emits `TypeNameCollision` and fails closed — and that - *removing* it returns green. Run it **twice** to pin the flag-ANY semantics: once with a - **divergent** pair (different bodies) and once with a **byte-identical mirror** pair — *both* - must fire (flag-ANY excuses neither). A flag-DIVERGENT build would let the mirror through; that - it does **not** is the §3-fidelity control. -- **No-regression control:** a type legitimately re-exported through multiple import paths - (one declaring file, many hops) must stay green — proves `same_authority` (span.file - identity) correctly excuses re-exports and the wall is not over-broad. +Per DESIGN §5 ("done" = a real consumer green by execution + a discriminating input that goes red when the behavior is wrong): + +- **GREEN-by-execution:** with the de-fork complete, run the exact floor closure (`claim_executor --source-root dsl --source-root src/v2`, both orders) — full corpus resolves clean **with the guard active**. (Baseline receipt already in hand from #1: post-rename, `affected_set_floor_runner_test` PASSes both orders, 56 modules.) +- **Discriminating RED (the falsifier):** re-introduce a single synthetic same-name pair into a test's closure and assert the guard emits `TypeNameCollision` and fails closed — and that *removing* it returns green. Run it **twice** to pin the flag-ANY semantics: once with a **divergent** pair (different bodies) and once with a **byte-identical mirror** pair — *both* must fire (flag-ANY excuses neither). A flag-DIVERGENT build would let the mirror through; that it does **not** is the §3-fidelity control. +- **No-regression control:** a type legitimately re-exported through multiple import paths (one declaring file, many hops) must stay green — proves `same_authority` (span.file identity) correctly excuses re-exports and the wall is not over-broad. --- ## 6. Scope guard / what this is NOT - **No resolver edit lands** here — model only until checkpoint-sign + de-fork clean. -- Does **not** touch the dsl↔v2 std module-**basename** reorganization (Route C / v1-delete) — - orthogonal, operator-strategic. The wall keys on shared **type-name** identity within a - closure, so the zero-shared-type-name basenames `{node, coercion, logic, verification}` are - off its surface entirely (this is why the roster carries no `{node, coercion}` entry, §3). - Their basename de-fork stays tracked in the audit's category-(c) (`dissolve-on = v1-delete`), - a different mechanism. The wall is compatible with whatever Route C decides. -- Mirrors the existing `VariantCollision` precedent; introduces no new resolver concept beyond - lifting that guard one level and dissolving the duplicate import-binding folds into one - checked-merge helper (a §2 win bundled in). +- Does **not** touch the dsl↔v2 std module-**basename** reorganization (Route C / v1-delete) — orthogonal, operator-strategic. The wall keys on shared **type-name** identity within a closure, so the zero-shared-type-name basenames `{node, coercion, logic, verification}` are off its surface entirely (this is why the roster carries no `{node, coercion}` entry, §3). Their basename de-fork stays tracked in the audit's category-(c) (`dissolve-on = v1-delete`), a different mechanism. The wall is compatible with whatever Route C decides. +- Mirrors the existing `VariantCollision` precedent; introduces no new resolver concept beyond lifting that guard one level and dissolving the duplicate import-binding folds into one checked-merge helper (a §2 win bundled in). ## 7. Open items -- **RESOLVED** — Q2 policy: `flag-ANY` signed (§3); per-basename audit executed and homed in - `docs/plans/dsl-v2-defork-audit.md` §2A; activation gate set to the five-basename grounding - de-fork (§4). Roster: deliberately empty (§3). -- Carried to the future resolver PR (not this model): confirm both import-binding assembly sites - (~11761, ~12355) are the only type-binding merge loci (the `std.types`-special-cased branch - folds key-by-key already and is naturally covered by the same checked-merge helper). -- Dependency owned elsewhere: the five-basename grounding de-fork (`algebra` authority ruled; - `nat`/`integer`/`float` via #5428 numeric tower; `effects` axis decision) must complete before - the guard PR can land green. `{node, coercion}` basename de-fork stays on the Route-C / v1-delete - surface (audit category-(c)), unaffected by this guard. +- **RESOLVED** — Q2 policy: `flag-ANY` signed (§3); per-basename audit executed and homed in `docs/plans/dsl-v2-defork-audit.md` §2A; activation gate set to the five-basename grounding de-fork (§4). Roster: deliberately empty (§3). +- Carried to the future resolver PR (not this model): confirm both import-binding assembly sites (~11761, ~12355) are the only type-binding merge loci (the `std.types`-special-cased branch folds key-by-key already and is naturally covered by the same checked-merge helper). +- Dependency owned elsewhere: the five-basename grounding de-fork (`algebra` authority ruled; `nat`/`integer`/`float` via #5428 numeric tower; `effects` axis decision) must complete before the guard PR can land green. `{node, coercion}` basename de-fork stays on the Route-C / v1-delete surface (audit category-(c)), unaffected by this guard. + +## Dissolution trigger (DESIGN §6) + +Delete this model-only DESIGN doc once the resolver type-name-collision wall is implemented and merged — the flag-ANY guard fires fail-closed on any same-name cross-authority type pair (TypeNameCollision diagnostic), the floor closure lands already-green after the de-fork, and the discriminating RED witness (synthetic divergent + byte-identical-mirror pairs both fire) is proven by execution — so this model is realized in the resolver. diff --git a/dsl/gunbc/plan_registry.dag b/dsl/gunbc/plan_registry.dag index d4e900d4cb2..4d2c46230e7 100644 --- a/dsl/gunbc/plan_registry.dag +++ b/dsl/gunbc/plan_registry.dag @@ -8,6 +8,7 @@ import gunbc.plan_registry_batch_c { batch_c_plans } import gunbc.plan_registry_batch_d { batch_d_plans } import gunbc.plan_registry_batch_e { batch_e_plans } import gunbc.plan_registry_batch_f { batch_f_plans } +import gunbc.plan_registry_batch_g { batch_g_plans } data all_plans: List = concat( [idea_machine_plan], @@ -15,4 +16,5 @@ data all_plans: List = concat( concat(batch_b_plans, concat(batch_c_plans, concat(batch_d_plans, - concat(batch_e_plans, batch_f_plans)))))) + concat(batch_e_plans, + concat(batch_f_plans, batch_g_plans))))))) diff --git a/dsl/gunbc/plan_registry_batch_g.dag b/dsl/gunbc/plan_registry_batch_g.dag new file mode 100644 index 00000000000..072b0b6f2fe --- /dev/null +++ b/dsl/gunbc/plan_registry_batch_g.dag @@ -0,0 +1,14 @@ +module gunbc.plan_registry_batch_g + +import gunbc.plan { Plan } +import gunbc.plans.ci_humming { ci_humming_plan } +import gunbc.plans.edge_b_rust_dag_provenance_brief { edge_b_rust_dag_provenance_brief_plan } +import gunbc.plans.resolver_type_name_collision_wall { resolver_type_name_collision_wall_plan } +import gunbc.plans.realization_measurement_loop { realization_measurement_loop_plan } + +data batch_g_plans: List = [ + ci_humming_plan, + edge_b_rust_dag_provenance_brief_plan, + resolver_type_name_collision_wall_plan, + realization_measurement_loop_plan +] diff --git a/dsl/gunbc/plans/ci_humming.dag b/dsl/gunbc/plans/ci_humming.dag new file mode 100644 index 00000000000..d659d57dbd3 --- /dev/null +++ b/dsl/gunbc/plans/ci_humming.dag @@ -0,0 +1,67 @@ +module gunbc.plans.ci_humming + +import gunbc.plan { Plan, DissolutionTrigger, HasTrigger } +import std.markdown { MarkdownBlock } +import gunbc.plans.md_helpers { h2, p, li, ul } + +fn ci_humming_body() -> List { + [ + p(text: "Home: ROADMAP §1 (CI as the substrate integration dogfood). This is the **▸ NOW — host-operation on `.dag`** milestone made concrete: placement, runner deployment, and caps are hand-managed and off-fabric today; this plan migrates them onto the modeled budget + carrier and uses that to un-throttle CI."), + p(text: "**GOAL.** CI fast (low wall-clock per PR) + high throughput (many PRs concurrent) + reliable (no reds / OOM / flakes) — and all three falling *out* of a single modeled budget consumed by a verified-effective apply, never a hand-picked number (§2/§5)."), + h2(text: "Root cause (live-verified 2026-06-23)"), + p(text: "srv1 + srv2 (128c / 125GiB each) sit at ~10-34% CPU, ~24-32% MEM, with only **~3 runner slots per host** — so PRs **queue while the cores idle**. The throttle is the runner-slot count, which is set by the per-host **memory budget allocation**, not by saturation, not by fleet capacity, not by OOM."), + p(text: "The slot count is starved because the budget model (`dsl/gunbc/fleet_host_budget.dag`) derives `runner_slice_cap ≈ 0`: build memory is subtracted as a `build_pool` **and** re-charged inside the per-job whole-tree-peak divisor. A GHA-CI runner job *is* a build — its `rustc` lives **inside** `system-actions-runner.slice` — so the build memory must be counted **once**, not twice."), + h2(text: "oomd demoted (operator §5 insight)"), + p(text: "Proper allocation (slice cap + per-slot caps ≤ physical − overhead, **verified-effective**) makes OOM impossible *by construction*. oomd is defense-in-depth for the **residue that is not yet capped-by-construction**, not a hard precondition. The srv2 reboots were construction *failing to realize* (the authored cap sat at `MemoryMax=infinity` on the live cgroup), not a missing daemon."), + p(text: "→ Relax `fleet_host_plan`'s hard `OomdUnverified` gate; the primary gate is **caps verified-effective**. oomd stays as a non-blocking backstop, and its honest residual job is the one co-resident slice still uncapped — see SessionSliceEnforcement below."), + h2(text: "1. Throughput (the capacity critical path)"), + ul(items: [ + li(text: "**T0 — build-pool vs runner-slice double-count** [CRITICAL, design call signed]: `runner_slice` must NOT subtract the GHA-CI build memory it already contains. Revised model (smart-pike-244): `runner_slice = host − overhead − session_worst_case_slice − headroom`; `runner_count = min(slice / per_job_peak, effective_build_tokens, cpu_cores_available)` — a 3-axis min-over-constraints. Fix this and the model derives > 0 runners. (smart-pike #5674.)"), + li(text: "**T1 — verified-effective slice cap** (construction; primary wall; the srv2 fix): ctrl PR built + signed, awaiting operator GO to open. The authored cap becomes *effective* on the live cgroup (reconcile verifies `MemoryMax != infinity`), closing the inert-cap hole."), + li(text: "**T2 — per-slot `MemoryMax` caps**: a job that over-caps is cgroup-killed in isolation, not the host. Part of the apply."), + li(text: "**T3 — budget manifest** (`.github/fleet-runner-deploy.manifest`: per-host count + per-slot cap + tokens): smart-pike #5674 landed; emits typed `UNSOUND` until the caps are sound (correct fail-closed)."), + li(text: "**T4 — per-job peak / build-pool sizing 24 → 8GiB**: cap `rustc`/slot via jobserver tokens; confirm `mem_reserve`. Same problem as T0 from the sizing angle. **manager-owned.**"), + li(text: "**T5 — ctrl apply**: consume the manifest → enable N slots + per-slot caps + tokens on srv1/srv2, verified-effective. Was blocked on #1753; operator now authorizes execute-ASAP. **The live host apply is surfaced to the operator before it executes.**"), + li(text: "**T6 — cpu.weight priority axis**: runner slice = `BatchLatencyTolerant` (weight 100, cgroup v2 default); sessions slice = `InteractiveLatencySensitive` (weight 1000, 10x). cgroup v2 cpu.weight is work-conserving: raising sessions above runners costs zero CI throughput when sessions are idle; under contention interactive sessions preempt batch builds. Fixes dashboard slowness on srv2 under CI load. (merry-stag-459, `WorkloadClass` modeled + emitted on manifest.)"), + ]), + h2(text: "2. Wall-clock (faster runs)"), + ul(items: [ + li(text: "**W1 — floor `spawn_width` memory-aware**: designed in `std.realization_width`; VERIFY it is wired to the executor. **manager-verify.**"), + li(text: "**W2 — split the cargo-test debug monolith** (~16m tentpole; also halves the T4 peak). **manager-owned.**"), + li(text: "**W3 — sccache corruption flakes** (false reds + full rebuilds). **manager-owned.**"), + ]), + h2(text: "3. Reliability (no reds / flakes) — folds in the red-rate lockdown lane"), + ul(items: [ + li(text: "**R1 — floor OOM exit137**: solved by T1+T2+T4 construction; oomd backstop."), + li(text: "**R2 — gate-trigger false-green** (`.dag`-only changes run 0 tests). **manager-owned.**"), + li(text: "**R3 — merge-result re-run** (catch stale-green merge skew): VERIFY wired."), + li(text: "The existing **main-red-rate lockdown** (structural floor defects, merge-freshness, anchor-completeness; crisp-carp-603 / quick-carp-124) is the reliability arm of this plan — the CI-humming manager coordinates it as one CI authority rather than letting throughput and reliability drift into unrelated workstreams."), + ]), + h2(text: "4. The carrier (mechanism for T5 + all host config)"), + ul(items: [ + li(text: "**C1 — std reconcile / verify-ground carrier** (signed signature; home = std): `reconcile(apply_effect, show_read, grounding) → Converged\{evidence\} | NotConverged\{reason\}`, with the §5 type-level invariant that the evidence carrier is constructible only via the grounding over a real read — \"verify the realization, not the declaration\" promoted to a constructor restriction. valiant-pike-233."), + li(text: "**C2 — `extdeps/os/systemd` unit-mgmt + apt install-effect**: re-homed under `extdeps/os/`, reusing the existing `extdeps.os.systemd` state. valiant-pike-233."), + li(text: "**C3 — oomd model + install Realization** (now defense-in-depth, off the critical path): valiant-pike-233 (#5677)."), + li(text: "**C4 — PXE/autoinstall + GCP keyless token**: neat-boar-71 (+ children)."), + li(text: "**One emit-from-fleet-model Realization** (§2 regime-2 projection fold): `ci.yml` + `fleet-runner-deploy.manifest` + Ubuntu user-data + `dnsmasq.conf` + the oomd drop-in are all the same projection."), + ]), + h2(text: "5. SessionSliceEnforcement (the safe-apply gate — new)"), + p(text: "The hosts co-host the agent-session fleet AND the CI runners. Full safe-by-construction needs **both** slices capped-verified-effective (runner + session), summing all maxes ≤ 125GiB. Today the agent-session cgroups have **no** citable verified-effective cap — that is the residual over-commit vector, and exactly where oomd-as-backstop earns its keep until a `SessionSliceEnforcement` carrier (parallel to the runner-slot enforcement) lands."), + p(text: "**Apply rule:** do NOT apply the runner cap while sessions are *both* uncapped AND oomd-absent — that is an un-backstopped over-commit (the srv2 vector). Pick (a) cap both slices verified-effective → no oomd needed, or (b) cap the runner slice + keep oomd live as the session backstop. The single `resolve_session_slice` figure is the §3 authority: it is subtracted by the runner budget AND drives the dashboard session reservation — one number, passed *down* into the budget, never imported up."), + h2(text: "6. Auth (separate, near-resolved)"), + ul(items: [ + li(text: "**A1 — `resolve_auth` `svc_auth_input` realization**: #5661 (8 approvals, CLEAN) — the positive path, live-verified on GCP."), + li(text: "**A2 — `AuthDeclaredButUnwired` guard** (additive fail-closed delta on #5661; its own PR): re-homed under neat-boar-71."), + li(text: "**A3 — perturbation confirm** (the §5 done-bar: drop the token → typed error PRE-SEND, never a remote 401): snappy-otter-298."), + ]), + h2(text: "Critical path to capacity (do first, both hosts ASAP)"), + p(text: "T0 (un-zero the runner slice) → model derives sane N + per-slot caps → T1+T2 verified-effective apply on srv1+srv2, **with the session slice either capped (5) or oomd-backstopped** → safe by construction (Σ caps + overhead + baselines ≤ physical). T4 (peak → 8GiB) multiplies N afterward. oomd is not required on the critical path."), + ] +} + +data ci_humming_plan: Plan = Plan { + slug: "ci-humming", + title: "CI humming — throughput, wall-clock, reliability (the single CI-operations authority)", + body: ci_humming_body(), + dissolution: HasTrigger { text: "Delete this doc when CI throughput, wall-clock, and reliability all fall out of the single modeled fleet budget consumed by a verified-effective apply (T0 un-zeroes the runner slice, T1/T2 caps are verified-effective on srv1+srv2, and the session slice is capped or oomd-backstopped) — so capacity is safe by construction rather than hand-managed." } +} diff --git a/dsl/gunbc/plans/edge_b_rust_dag_provenance_brief.dag b/dsl/gunbc/plans/edge_b_rust_dag_provenance_brief.dag new file mode 100644 index 00000000000..4828f014ecf --- /dev/null +++ b/dsl/gunbc/plans/edge_b_rust_dag_provenance_brief.dag @@ -0,0 +1,63 @@ +module gunbc.plans.edge_b_rust_dag_provenance_brief + +import gunbc.plan { Plan, DissolutionTrigger, HasTrigger } +import std.markdown { MarkdownBlock } +import gunbc.plans.md_helpers { h2, p, li, ul, ol } + +fn edge_b_rust_dag_provenance_brief_body() -> List { + [ + p(text: "**Status: SCOPING ONLY.** The multi-day build holds for the operator's explicit greenlight. This document is the decision artifact for that greenlight call."), + h2(text: "Goal"), + p(text: "Make the rust↔.dag dependency a **declared structural fact**, recorded once and read in two directions. It is the single fact under three consumers (DESIGN §4, one grammar both directions), which is why this is the §1 *coverage keystone*, not a cost follow-up."), + h2(text: "Why — one fact, three consumers"), + ol(items: [ + li(text: "**Coverage wall (soundness, fail-closed).** Today a pure-.dag PR fires *no* rust gate: `any_rust_monolith` (`dsl/tools/rust_stage0_gates.dag`) matches only `.rs`/Cargo/toolchain suffixes. But rust tests *read* `.dag` via opaque `filesystem_read`/`ws.join`, so a `.dag` change that breaks a rust test ships **silently green** — a §5 fail-OPEN. That file's own COMPLETENESS CLAIM (\"every change that can alter a rust gate's verdict carries a `.rs`/Cargo suffix\") is *false* for .dag-consuming tests, and its header names per-file rust→.dag dependence as the deliberately-skipped proper model. Edge-(b) FIRES the rust gate when a changed `.dag` is in a rust test's declared closure → makes the claim true. This is the operator's \"lock fail-closed before you expand\" priority."), + li(text: "**Affordability selector.** The *same* declared closure read the other way — skip rust tests whose closure the diff doesn't touch — is the affected-set shrink (the ROADMAP end-state: run-all baseline SHRUNK to affected). cargo has *zero* affected-test selection (every `#[test]` every run; nextest too) and can't see `.dag` deps, so a declared closure is the *only* path to it."), + li(text: "**Testgen reflection.** The rust-test→.dag closure is the same provenance testgen needs to regenerate the right tests when a `.dag` node changes."), + ]), + p(text: "FIRE-when-consumed and SKIP-when-unaffected are the single fact read in opposite directions — that unification is the moat (one carrier, three consumers)."), + h2(text: "The asymmetry that decides what the build buys (construction, not validation)"), + p(text: "The two directions have **asymmetric robustness to an incomplete declaration**, and this is the construction-vs-validation lesson made concrete:"), + ul(items: [ + li(text: "**Affordability (skip-unaffected) is fail-SAFE to over-declaration.** Declare too much → you just run more → never unsound. Robust to a sloppy/partial closure."), + li(text: "**Coverage (fire-on-change) is fail-OPEN to UNDER-declaration.** If a test reads `.dag` A and B but its closure declares only A, a change to B does NOT fire the gate → the exact `.dag`→rust fail-open we are closing, silently re-introduced as **declaration drift**. The coverage wall is only as sound as the declaration is COMPLETE: **closure ⊇ actual-.dag-reads**."), + ]), + p(text: "Consequence: the coverage wall's soundness lives entirely in the *completeness* of the closure, which means a **hand-authored closure is the §3/§5 fork** — for the coverage consumer it silently re-opens the hole. So the closure MUST be structurally derived (drift-proof); any hand-authored interim must be marked **NON-SOUND** (delivers affordability only, not the coverage wall). The \"shared blocker\" below is therefore not the tail of the work — it is *where the soundness lives*."), + h2(text: "Bounded core"), + ol(items: [ + li(text: "**Declare rust-test → consumed-.dag-paths on the EXISTING `NodeArtifactProvenance` / `EditLocusBinding` carrier** — no parallel mint (§3 single authority). Implementer must first verify the carrier shape fits `rust-test-identity → .dag-path list`; if not, add a *sibling entry on the same authority*, never a new module."), + li(text: "**Gate integration is small and precise:** extend `should_run_gates` / `any_rust_monolith` (`dsl/tools/rust_stage0_gates.dag`) so a changed `.dag` path in the union of declared rust-test closures ALSO returns true."), + li(text: "**Fail-closed default AT THE CONSUMER:** a rust test with no declared closure → *must-run*, never skip. Absent provenance = run. This keeps the soundness direction safe while declarations are added incrementally."), + li(text: "**Completeness-lens gated — on CORRECTNESS, not presence.** A lens that merely asserts \"every rust test HAS a closure declaration\" checks *presence*, which is exactly the §5 trap: it is satisfiable by editing the declaration while the realization diverges (the faked-cache-key / dead-field pattern). The lens must check **closure ⊇ actual-.dag-reads** — otherwise a partial or stale declaration passes the lens AND leaks coverage. Presence-only is not enough; correctness (the superset relation) is the soundness condition."), + ]), + h2(text: "Shared blocker (testgen-reflection) — this IS the soundness, not optional polish"), + p(text: "Per the asymmetry above: the `.dag`-closure must be DISCOVERED structurally, not hand-listed (hand-listing is the §3/§5 fork that rots, and for the coverage consumer it *silently re-opens the hole*). The reflection infra exists *partially* — `v2.std.node_query` + `dependency_lens` + the `affected_set` node-frontier (compile-time, structural over Node/DependencyView). The missing piece: rust tests reach `.dag` through *opaque host paths* (`ws.join`/`filesystem_read`), so the closure isn't visible to the Node-tree lens. Surfacing each rust test's `.dag` reads as a declared, lens-visible dependency is the shared blocker all three consumers wait on — and because the coverage wall is only sound when `closure ⊇ actual-reads`, this structural discovery is the **load-bearing core**, not the tail. It is the hard part and the multi-day driver precisely because it is where the soundness is bought."), + h2(text: "First vertical slice (smallest end-to-end, green-by-execution)"), + ul(items: [ + li(text: "Pick ONE rust test with a clear `.dag` closure — `coproduct_reflection_conformance_test` (inputs entirely `.dag`) is the natural first."), + li(text: "Declare its consumed-.dag closure on the carrier."), + li(text: "Wire `should_run_gates` to fire when a changed path is in THAT test's declared closure."), + li(text: "Prove by execution with a discriminating control: a diff to a `.dag` IN the closure FIRES the gate; a diff to a `.dag` OUTSIDE the closure does NOT. Green = both directions observed."), + li(text: "This proves the structural fact end-to-end on one test before any corpus fan-out."), + li(text: "**State explicitly which the slice proves.** For the slice to prove the *coverage direction soundly*, `coproduct_reflection_conformance_test`'s closure must be **structurally derived** (so a newly-added `.dag` read is captured automatically). If slice-1 hand-lists the closure as an interim, it proves the *wiring* (fire/skip plumbing) but NOT the *wall* (drift-proof completeness) — and must be labelled accordingly. The keystone's value is the wall, so the slice should target the derived closure, not the hand-listed one."), + ]), + h2(text: "Honest estimate"), + p(text: "Multi-day."), + ul(items: [ + li(text: "Slice 1 (one test: declare + gate-fire + discriminating control): ~1 day."), + li(text: "Shared blocker (structural .dag-closure discovery through opaque host reads, lens-visible): the bulk — ~2–4 days, depending on whether the host-read seam can surface declarations cheaply or needs the reflection layer deepened."), + li(text: "Corpus fan-out + completeness lens: after."), + ]), + h2(text: "Decoupling"), + p(text: "Independent of #5427. #5427 is the cheap `.rs`-hole-closer (widen the rust gate's test command on `.rs`-touching PRs) — lands now, behind the two operator levers. Edge-(b) is the structural keystone that later makes the rust gate BOTH sound on `.dag` changes AND affordable by selection. Neither blocks the other."), + ] +} + +data edge_b_rust_dag_provenance_brief_plan: Plan = Plan { + slug: "edge-b-rust-dag-provenance-brief", + title: "Edge-(b) scoped dispatch brief — rust-test ↔ consumed-.dag provenance (the coverage keystone)", + body: edge_b_rust_dag_provenance_brief_body(), + dissolution: HasTrigger { + text: "Delete this brief once edge-(b) is built and merged — the rust-test→consumed-.dag closure is a structurally-derived (drift-proof) declared fact on the NodeArtifactProvenance carrier, the coverage wall fires the rust gate on an in-closure .dag change (closure ⊇ actual-reads, lens-checked on correctness not presence), and the affordability selector skips unaffected rust tests — so the scoping decision this doc records is realized." + } +} diff --git a/dsl/gunbc/plans/realization_measurement_loop.dag b/dsl/gunbc/plans/realization_measurement_loop.dag new file mode 100644 index 00000000000..9f27d7b02d5 --- /dev/null +++ b/dsl/gunbc/plans/realization_measurement_loop.dag @@ -0,0 +1,187 @@ +module gunbc.plans.realization_measurement_loop + +import gunbc.plan { Plan, DissolutionTrigger, HasTrigger } +import std.markdown { MarkdownBlock, CodeBlock, TableBlock, AlignNone, ThematicBreak } +import gunbc.plans.md_helpers { h2, h3, p, li, ul, ol, cell, row, quote, hr } + +fn realization_measurement_loop_body() -> List { + [ + p(text: "**Status:** stable coordination plan · dispatch workers per phase · **DESIGN.md + the carriers remain the authority** — this doc is a worker-dispatch tracker, not a fact ledger, and each phase dissolves into a mark on its carrier when it lands (DESIGN §6 \"no parallel-ledger docs\"). A phase's real state is its branch/PR, not this file (mirrors `ROADMAP.md`)."), + p(text: "**Owner:** unowned (original coordinator `zesty-deer-479` archived 2026-06-21) — operator-coordinated; consolidates the formerly-separate quick-ant-298 dependency-ordered roadmap (single authority, no fork). Linked from `ROADMAP.md` §2 *Minimal work — caching by realization*."), + hr(), + h2(text: "0. Thesis — the substrate is shape-complete but input-starved"), + p(text: "The realization layer is *fully modeled and almost entirely inert*: every carrier that should drive \"minimal work, as parallel as possible, guaranteed\" exists with the right type and is read by **no scheduler, fed by **no measurement, consulted by **no router. This is DESIGN §6's failure mode — *\"the tier where the machinery exists but nothing gates on it\"* — landed squarely on §1's **cost axis**."), + p(text: "The fix is **one control loop**, not a pile of local patches (this is why §4 \"evaluate the whole pipeline\" is load-bearing, not a footnote):"), + CodeBlock { code: " measure (Phase 0) ← the keystone; makes cost a real fact\n → CostAccount.time = Measured (today: cost_account_predicted_zero())\n → RealizationObjective Pareto over \{time, space, power, $\}\n bounded by a deployment HardwareBudget (Phase 1 / Phase 3)\n → Schedule width + shard balance + cache-layer choice\n → total rolled up along the CRITICAL PATH, not the node sum (Phase 1.5)\n" }, + p(text: "The three notes from the operator are **not peers — they are a dependency chain rooted at measurement**: `minimal work` = §2 (cache planner) and `as parallel as possible` = §1 (width) can only be *optimized against a measured cost*, and `guaranteed` = §5 (measured, not predicted). Cost must become a measured fact before anything can plan against it. The independent CI audit reached the same conclusion (\"add the two-clock timing first\"); the dependency structure above is *why*."), + h3(text: "The end-state acceptance gate (what the whole plan builds to)"), + quote(blocks: [ + p(text: "For every pure transform `T` (resolve, parse, typecheck, *and* derived analyses like complexity-synthesis / affected-set — see `ROADMAP.md` §3 *Complexity / synthesis lens* and §4 *Testgen*), `realize(T)` returns a result content-addressed by `hash(inputs ⊕ content(T))`, materialized at the **minimal `Placement` spanning T's consumers (its reach)**. A transform that is **non-redundant** (shared across a layer boundary, or recompute-cost > cache-cost) with **no cache supplier at its reach layer** is a located, typed **ERROR** that emits a *request to provision a supplier there*. No silent `Recompute`; no under-keyed hit."), + ]), + p(text: "This is §5 (fail-closed) turned on the cost axis: uncached non-redundant work is not \"slow\", it is an *error*. The earliest truthful point to assert it is the **redundancy-only** cut (shared-across-boundary — needs reach, not measurement); the cost-based \"non-redundant\" half waits on measured cost (Phase 0 / §4). The phases below are the path to this gate; the dependency-ordered spine that maps work items onto it is in **§ Dependency-ordered spine** (before Sequencing)."), + h3(text: "The invariant that governs every phase (DESIGN §3 / §4)"), + quote(blocks: [ + p(text: "**Pure schedule TOPOLOGY stays central and deterministic; every measurement-fed decision is a PERIPHERAL realization.**"), + ]), + p(text: "The schedule (`Schedule = List>`) is a deterministic partial order — it expresses what *can* run in parallel, hardware-free, and is pinned by the `schedule_eq` / `schedule_generates_identical_schedule` witnesses (`realization_schedule.dag:222-236`; `src/v2/test/claim/realization_schedule_witness.dag:35-48`). A schedule whose *width or membership* depended on a measured per-machine `HardwareThreadCount` would break that equality across hosts. So: **measured ⇒ peripheral, by construction.** Width, shard balance, cache-layer choice, and the timing tap all live in the periphery (`extdeps/realization`, the host realizer), checked by *\"given these DeploymentFacts + these measured costs, the realizer picks X\"* witnesses — deterministic *given their inputs*. This is exactly what the `CostAccount` dissolve-on comment anticipates (`realization_schedule.dag:25-26`). Most `.dag` programs are stateless/short-lived: they declare dependency structure and never mention hardware; the width-fold degenerates to \"just run it.\""), + h3(text: "Realization has THREE dimensions (schedule · cache · compute-fabric)"), + p(text: "\"Realization\" is one concept with three orthogonal-but-composed dimensions, **all keyed on the same content-addressed `ExecutionReceipt`**, all **peripheral** (§3), all governed by the **same measured cost + Pareto objective**:"), + TableBlock { + header: row(cells: [cell(text: "Dimension"), cell(text: "Carrier"), cell(text: "Asks"), cell(text: "§1 axis")]), + alignments: [AlignNone, AlignNone, AlignNone, AlignNone], + rows: [ + row(cells: [cell(text: "**schedule**"), cell(text: "`std.realization_schedule`"), cell(text: "*when / how parallel*"), cell(text: "parallel")]), + row(cells: [cell(text: "**cache**"), cell(text: "`std.cache_interface`"), cell(text: "*whether it needs to run at all*"), cell(text: "§2 minimal work")]), + row(cells: [cell(text: "**compute fabric**"), cell(text: "`product.compute_fabric`"), cell(text: "*where / on what it runs* (provision)"), cell(text: "placement / $")]), + ], + }, + p(text: "The proof they are dimensions of *one* concept rather than three separate models is **structural and already in the tree**: cache `MUST NOT import compute_fabric` (`cache_interface.dag:4`) and compute_fabric `MUST NOT import cache_interface` (`compute_fabric.dag:9`); **both compose only over `ExecutionReceipt`**. They meet *only* at the content-addressed receipt — never by direct coupling (§3/§4)."), + p(text: "**The `compute_fabric()` zero-arg interface is the same §3 move as the whole plan.** `compute_fabric` is a **demand → placement → supply** market: an execution emits a `WorkDemand` (isolation, memory, GPU) and `satisfies(offer, demand)` (`compute_fabric.dag:377`) places it on a satisfying `ComputeOffer`. \"Provision compute for this execution\" with **empty args** = the `WorkDemand` is *inferred from the .dag-modeled execution*, and placement is *resolved from the deployment's offers* — **neither is a caller argument**. Identical to the cache planner auto-wiring and the scheduler's hardware-budget fold: *caller declares intent; the realization is resolved from modeled deployment facts.* All three dimensions share this."), + p(text: "**Layering discipline (§3):** `compute_fabric` and `placement_supply` are **product**; schedule/cache are **std** (imports point toward std). Split: product owns the *placement projection carrier* (`product.placement_supply` ✓) and std owns the `\{time,space,power\}` cost-axis measure carriers it composes; product `compute_fabric` owns the **$/billing axis** (`CostClass`, `MoneyMicros`) and *projects* fleet rows into that carrier (`placement_supply_row`, `compute_fabric.dag:220`); the **peripheral host realizer** bridges product→std and runs the Pareto pick. std stays product-free."), + h3(text: "v2 is the target; v1 is the proving ground (DESIGN §7)"), + p(text: "v1 (the Rust seed) is shrinking to zero; v2 (the self-hosted `.dag` compiler) is what must benefit. **Every phase's durable artifact is `.dag` that v2 inherits; the Rust seed is only the proving *handler* — where a host-effect attaches today, while v2 is mid-bootstrap and the v1 interpreter is still the only evaluator that actually runs.** You MAY edit v1 (it's a proving ground), but:"), + quote(blocks: [ + p(text: "**The v2-benefit test:** if a phase's deliverable is a Rust patch with *no `.dag` model*, it failed. The carrier / lens / kernel / effect-shape is the artifact; the Rust code is one handler of it (§2 one-shape-N-handlers; §3 measured⇒peripheral; §7 Rust→zero)."), + ]), + p(text: "This is *why* the keystone's measurement is modeled as an **effect-shape + `PerformanceReceipt` carrier + a roll-up lens over the Node fold** (the same `fold_node` v2's own evaluator uses) — so when v2 self-hosts, the instrumentation, the cache kernel, the scheduler, and the fabric all come along for free. The Rust tap in `v1_interpreter.rs` *proves* the model green-by-execution today; it is the realization, not the authority. Per-phase split: **Phase 0** durable = the `.dag` measure model/lens, proving = the Rust eval tap; **Phase 1** durable = the `.dag` width-fold (`scheduler.dag` is already v2), proving = the `claim_executor` spawn cap; **Phase 1.5a/2/3** are already `.dag`-native (`v2.lens.affected_set`, the cache catalog/kernel, `compute_fabric`/`ci_yaml_emit`) — v2-inheriting by construction; only the cache *backends* (`resolved_graph_cache.rs`, `ParseTableMemo`) stay v1 handlers of the one `.dag` kernel."), + hr(), + h2(text: "Verified ground truth (file:line — do not re-derive)"), + TableBlock { + header: row(cells: [cell(text: "Fact"), cell(text: "Evidence")]), + alignments: [AlignNone, AlignNone], + rows: [ + row(cells: [cell(text: "Schedule width = full dependency frontier, **no capacity bound**"), cell(text: "`ReadinessLayer.ready: List` `src/v2/workflow/scheduler.dag:29`; `runnable_frontier_from_dependencies` `scheduler.dag:147-154`")]), + row(cells: [cell(text: "Thread-spawn **unbounded by hardware** (one OS thread per runnable-in-batch)"), cell(text: "`thread::spawn(... run_one_runnable ...)` `src/v1/stage0/src/bin/claim_executor.rs:403-410`")]), + row(cells: [cell(text: "Corpus = **one** `RunnableDiscoveryBatch` node → serial `for` loop (293 witnesses invisible)"), cell(text: "`ci_floor_plan.dag:107`; `run_discovery_corpus` serial loop `cli_run.rs:2148-2171`")]), + row(cells: [cell(text: "`CostAccount.total` is hardcoded zero"), cell(text: "`cost_account_predicted_zero()` `realization_schedule.dag:33-39`; `CostBasis/Measured` exist **only** in the `:25-26` dissolve-on comment")]), + row(cells: [cell(text: "Single eval seam exists; per-variant self-time tap already there, **not** content-hash-keyed, **not** fed to CostAccount"), cell(text: "`eval_expr` `v1_interpreter.rs:1451`; profiler `:1466-1476` (keys by `expr_variant_index`)")]), + row(cells: [cell(text: "Per-witness/per-resolve wall-clock timing **exists but only goes to stderr**"), cell(text: "`claim_batch.rs:372,404`; the floor runner `claim_executor.rs` does no timing; `DiscoverySummary` keeps only `\{total,passed,failures\}` `cli_run.rs ~1903`")]), + row(cells: [cell(text: "Cache catalog has **zero runtime consumers**; `CacheLayerPlan` unused"), cell(text: "`cache_interface.dag:91`; importers are comments only (`realization.dag:16`, `02_parse.dag:162-168`)")]), + row(cells: [cell(text: "3 live caches hand-wired, **3 different key derivations**"), cell(text: "`resolved_graph_cache.rs:76-199` (content-hash); `ParseTableMemo` `v1_interpreter.rs:768,1116` (in-proc map); `pure_call_memo` keys by **address** `(usize,Vec)` not hash `v1_interpreter.rs:748-752`; sccache external")]), + row(cells: [cell(text: "Carrier for hardware budget **already exists**"), cell(text: "`HardwareThreadCount = Measure` `measure.dag:254`; `PlacementSupplyRow.hardware_threads` `placement_supply.dag:29-31`; `CpuDeploymentFacts` `cpu/types.dag:42`")]), + row(cells: [cell(text: "Pareto kernel + objective vocabulary already shared"), cell(text: "`std.pareto` dominance + `AxisGoal`; `RealizationObjective.goals: List` `realization_schedule.dag:41`")]), + row(cells: [cell(text: "Runner model exists; ci.yml **is generated + byte-drift-gated**"), cell(text: "`RunnerSpec = HostedRunner \| SelfHosted\{labels\}` `extdeps/github/actions.dag:233` (emission consumer is a future trigger, `:226-232`); generator = `expected_ci_yml()` `dsl/gunbc/ci_yaml_emit.dag:9`, drift gate `dsl/tools/ci_yaml_gate.dag` (byte-for-byte), parse-validate `dsl/gunbc/ci_yaml_validate.dag`. **NOT** `dsl/tools/gunbc_ci.dag` (a 732B wrapper). ⚠️ `extdeps/github/ci.dag:7` has a **stale** comment \"ci.yml is hand-edited, not generated\" — contradicts the live gate; ignore it (track for deletion). `runs-on: [self-hosted,linux,arm64]` is emitted as a **literal** today — the seam Phase 3a routes through `RunnerSpec`")]), + row(cells: [cell(text: "A 3rd (richest) measured-time carrier already exists"), cell(text: "`compute_fabric.PerformanceReceipt\{wall_duration:Duration, sample_count, confidence: MeasurementConfidence = SingleSample\|Range\|DistributionSummary\}` `:414-423`; on `ExecutionReceipt.performance :453` + `ComputeSupplyFacts.observed_performance :166`")]), + row(cells: [cell(text: "`ExecutionReceipt` digest is **itself a stub** (not yet a content hash)"), cell(text: "`execution_receipt_digest` returns `receipt.work.id` (a hand-authored brand) `:588-594` — \"full canonical encoding supplied by the harness when Outcome/ArtifactRef inhabit\"")]), + row(cells: [cell(text: "Corpus sharding already has a demand-model home"), cell(text: "`ParallelismShape = ... \| IndependentShards\{shard_count\} \| PartitionedReduce\{...\}` `compute_fabric.dag:280-289`; `WorkDemand.parallelism :273`")]), + row(cells: [cell(text: "srv1/srv2 concrete facts are **ctrl-tier (private), not public gunbc**"), cell(text: "`hardware_selection.dag:8`; `compute_fabric.dag:5` (\"ctrl `plans.fabric.operator_fleet`\")")]), + row(cells: [cell(text: "compute fabric = demand→placement→supply market; provisioning is `satisfies(offer, demand)`; composes over `ExecutionReceipt`"), cell(text: "`product.compute_fabric` — `WorkDemand` `:268`, `ComputeOffer`/`satisfies` `:377`, `ExecutionReceipt` `:449`, projects `PlacementSupplyRow` `:220`; `satisfies` checks **isolation only** today (no thread-count/Pareto dim)")]), + row(cells: [cell(text: "map→reduce execution decomposition is forward-stubbed (`= Node`) — anticipates sharding"), cell(text: "`WorkGraph`/`Partitioner`/`Reducer`/`SymbolicCost`/`EffectBoundary` `compute_fabric.dag:48-58`")]), + ], + }, + hr(), + h2(text: "Phase 0 — Measured cost (THE KEYSTONE)"), + p(text: "**Goal:** flip `CostAccount.time` from `predicted_zero` to `Measured`. Everything quantitative depends on this. NB: the timing *primitives already exist* — this is **\"wire the existing tap to a content-hash key + CostAccount,\"** not \"build timing from scratch.\""), + ul(items: [ + li(text: "**Grain decision (settled this session): key on the content-hash of the cache SUBJECT, not per-AST-node, not per-variant.** Rationale: the `Node` is an `Rc` with **no ambient content-hash** (today the profiler keys by `expr_variant_index`), so per-node hashing at `eval_expr` is *not free* and would perturb the measurement (§5 observer effect). The cache-subject frame is exactly where a content-hash *is already computed*, and it is the grain the scheduler (per-Runnable) and the cache router (per-subject recompute cost) both consume — so per-subject is the §2 \"model once, derive every use\" point: per-Runnable is its aggregate, per-variant its `group-by`, full per-node an **opt-in deep projection** over the same seam. Per-variant counters are a *dead end* (a variant is not a cacheable identity → can't feed Phase 2)."), + li(text: "**Instrumentation = the dual of the cache.** Both wrap the same fold boundary keyed by the same content-hash: the cache stores node→value, the instrument stores node→duration. The *analysis* is a pure lens; the measurement itself is a §1 host-effect. Use the existing gross−children self-time decomposition (`v1_interpreter.rs:1466-1476`)."), + li(text: "**The measurement output is a `PerformanceReceipt`, NOT a new struct (§3 — do not coin a 4th).** The observation carrier already exists: `compute_fabric.PerformanceReceipt\{ wall_duration, sample_count, confidence \}` (`compute_fabric.dag:414-423`), and `ExecutionReceipt.performance` (`:453`) already hangs it on the receipt. So Phase 0 emits a `PerformanceReceipt` keyed by the cache-subject hash → it rolls up into `CostAccount.time` (the aggregate). This is what *fuses the keystone to the compute-fabric deliverable*: the thing Phase 0 measures **is** the fabric's execution receipt, and `MeasurementConfidence` (SingleSample/Range/DistributionSummary) is exactly the per-witness-distribution honesty the audit's observability gap needs."), + li(text: "**Feed `CostAccount`.** Add `CostBasis = Measured | Predicted` (the `:25-26` dissolve-on); aggregate PerformanceReceipts → `RealizationPlan.total`."), + li(text: "**Converge the time authorities — there are THREE, not two (§3).** `NanosecondDuration` (`measure.dag:258`) is the authority. `TestNodeCostDimension.measured_ms` (Milliseconds, `verification.dag`) **dissolves** into a budget-*predicate* over the measured `CostAccount.time` (a ns threshold), not a parallel measured field (ms truncates a 5 ns step to 0 — DESIGN §6). And `PerformanceReceipt.wall_duration` is the *observation* feeding the roll-up — observation vs roll-up, not a fork. Net: one observation carrier (`PerformanceReceipt`), one roll-up (`CostAccount.time`), `measured_ms` deleted."), + li(text: "**Persist the dropped timing.** Carry per-witness/per-entry timing through `DiscoverySummary` and the floor path (`claim_executor`), closing the audit's observability gap (the \"two-clock\" per-entry-resolve vs aggregate-per-witness split) — which is *itself* the profiling the operator was about to do by hand, made first-class."), + li(text: "**§5 gate:** purity oracle — witness verdicts byte-identical instrumented vs not."), + li(text: "**Dissolution trigger:** `cost_account_predicted_zero()` has no callers on the floor path; `measured_ms` deleted."), + ]), + hr(), + h2(text: "Phase 1 — Make parallelism visible + hardware-bounded width (note 1)"), + p(text: "**Depends on:** Phase 0 (shard balance needs measured per-shard cost)."), + ul(items: [ + li(text: "**Explode the corpus node** (`ci_floor_plan.dag:107`) into per-entry-group `Runnable`s — **rows, not Rust**. Express it as a `WorkDemand` whose `parallelism = IndependentShards\{shard_count\}` (`compute_fabric.dag:282`) — the corpus is today a *degenerate (unsharded) projection* of exactly that, so this reuses the carrier rather than minting a scheduler-local shard list. Shard *by whole entry-group* to preserve the warm `typed_module_cache` (splitting an entry's witnesses re-incurs its cold resolve). This is the keystone both background audits independently named."), + li(text: "**The hardware budget is what `compute_fabric` PROVISIONS — do not coin a fresh carrier (§2/§3).** The width-fold reads the `PlacementSupplyRow` that `compute_fabric` already projects (`placement_supply_row`, `compute_fabric.dag:220`; `PlacementSupplyRow.hardware_threads` `placement_supply.dag:29-31`). **The width decision *is* a placement decision:** today `satisfies(offer, demand)` (`compute_fabric.dag:377`) checks *isolation only* — Phase 1 is \"add the thread-count / Pareto dimension to placement.\" So this phase is co-designed with Phase 3 (compute_fabric is the provisioning interface; the runner *declares* the offer, the scheduler *consumes* the placement — one market, two readers). DFS `PlacementSupplyRow` + `CpuDeploymentFacts` (`cpu/types.dag:42`) before extending; do **not** invent `DeploymentFacts`."), + li(text: "**The width-fold.** Schedule stays the pure partial order; a peripheral realizer folds it against the `HardwareBudget` → actual width, a Pareto pick over `\{wall-time↓, peak-memory↓\}` bounded by `width ≤ cores` — reusing `std.pareto` + `RealizationObjective.goals` (already `List` — wiring carriers that already speak the same vocabulary, not inventing one)."), + li(text: "**Bound the spawner** (`claim_executor.rs:403-410`) by `available_parallelism`/budget — fixes the *dual* hazard: under-parallel (serial corpus) **and** over-parallel (unbounded spawn on a wide batch)."), + li(text: "**Determinism:** schedule topology stays witness-stable; width/shard are peripheral, checked by given-these-facts witnesses."), + li(text: "**Dissolution trigger:** the corpus is ≥2 runnables in the schedule; the spawner reads a budget."), + ]), + hr(), + h2(text: "Phase 1.5 — Holistic cleanups (note 4) · mostly parallel to 1"), + ul(items: [ + li(text: "**Wire `affected_set` into the corpus + gate roster** (audit lever #1). The compile-time, fail-closed `v2.lens.affected_set` + runner + superset proof exist and are green but unimported. Skip only on a content-addressed match to a verified-green baseline; **fail closed** on any miss. Biggest wall-clock lever on PR branches. (Independent of Phase 0.)"), + li(text: "**`total` = measured critical-path roll-up** (note 4): weights a short phase *on the critical path* (the perturb gate) at full cost and a short phase *hidden under a parallel branch* at ~0. (Needs Phase 0.)"), + li(text: "**Collapse the perturb cold-recompile** (~14 s, fail-fast root, critical path): resolve the planted (fresh-name, unimported) module against the green compile's index instead of `cp -r dsl` + cold rebuild; preserves the discriminating-red (§5). (Independent of Phase 0.)"), + ]), + hr(), + h2(text: "Phase 2 — Cache-layer planner: the catalog's first consumer (note 2)"), + p(text: "**Depends on:** Phase 0 (cost-aware reach needs measured recompute cost)."), + ul(items: [ + li(text: "**Land the planner the catalog header already promises** (`cache_interface.dag:21` \"downstream cache lookup planner\"; dissolve-on-arrival \"when first consumer lands\"). Given the `CacheInterfaceFacts` rows + a deployment's *available* backends, emit a `CacheLayerPlan` (type exists, `:91`): L1 in-process → L2 sccache / cargo target / resolved-graph → L3 CAS."), + li(text: "**One content-address lookup kernel, N backends bound by `transport_encoding`** (§4 one-kernel/N-handlers). The in-process memo is just the `InProcess` row of the *same* kernel. **Converge the key derivations onto ONE content-addressed subject identity.** Today there are *four* keyings: `parse_cache` by path, `typed_module_cache` by module-name, `resolved_graph` by content-hash, `pure_call_memo` by address — **and the `ExecutionReceipt` digest the whole three-dimension unification rests on is itself a 4th stub**: `execution_receipt_digest` returns `receipt.work.id`, a hand-authored brand, not a content hash (`compute_fabric.dag:588-594`). The §0 thesis (\"all three dimensions keyed on one `ExecutionReceipt`\") is only *true once this digest becomes a real content hash aligned with the cache-subject identity* — so this convergence is shared work between Phase 2 (cache) and the compute-fabric track, not cache-local. The `key_derivation` axis exists for exactly this."), + li(text: "**Cost-aware reach (§1).** Reach for a layer only when its predicted delta favors it: `min(recompute, lookup + p(miss)·recompute)` — `read_latency` (InProcessNs…WanTensMs) is already a modeled axis; `recompute` comes from Phase 0. A WAN CAS hit can lose to recomputing a cheap node."), + li(text: "**Auto-wire (the operator's \"user shouldn't wire it themselves\").** The deployment declares which backends it offers; the planner emits the wiring — dissolving the bespoke `if sccache --show-stats` shell in `ci.yml` and the `GUNBC_RESOLVED_GRAPH_CACHE_DIR` env read."), + li(text: "**Fail-closed (§5).** A backend probe that is absent/unauthorized falls through to the next layer → ultimately recompute, **never** serves a stale/unverified hit (`CacheRejectReason` already enumerates `BackendUnavailable`/`BackendUnauthorized`). Verdict-identity, not byte-identity, until the deferred canonical-byte compare lands — so do NOT route emit/lower consumers through it yet."), + li(text: "**First free measurement:** un-dormant `resolved_graph_cache` in CI (read by the seed, unset in `ci.yml`) as a warm A/B."), + li(text: "**Dissolution trigger:** `ci.yml` carries no hand-wired cache shell; one lookup kernel; one subject key."), + ]), + hr(), + h2(text: "Phase 3 — Infra / deployment onto `.dag` (srv1 / srv2) · the second ask"), + p(text: "**Goal:** model the actual infra/deployment — runner config, access, host config — as **data**, dissolving bespoke `ci.yml` shell + manual runner setup. **\"Get CI onto `.dag`\" = instantiate `compute_fabric` for srv1/srv2:** a self-hosted runner is one `ComputeOffer`; GHA-hosted, `Ubicloud`, `GcloudRun` are others (already enumerated, `compute_fabric.dag:71`). This meets note 1 at the placement carrier — the offer the runner *declares* is the budget Phase 1's scheduler *consumes*."), + p(text: "**§3 boundary — THREE tiers, not two (refined after the #5177 review).** The operator's rule: keep the *generic* \"CI runner\" cleanly apart from *our* CI runner; CI does not need to know our fleet. So:"), + ul(items: [ + li(text: "**3a-generic — \"CI runner\" in the abstract (any project).** What we expect *any* CI runner to do, project-agnostic: **a workflow triggered by an event** (`trigger → workflow`), realized per platform. The GHA realization already exists — `Workflow\{ on: List, jobs \}` + `WorkflowTrigger` (`actions.dag:56,79`) and `RunnerSpec` (`:233`). The **generic `offer → RunnerSpec` projection** (`runner_spec_from_offer`, kernel/arch → labels) belongs HERE, next to `RunnerSpec` in the generalized layer — it works for *any* fleet offer. **This tier MUST NOT import a concrete SKU (`extdeps.cpu.ampere`) or name srv1/srv2.** (GitLab/Buildkite/etc. would be sibling platform handlers — one generic interface, N realizations, §2/§4.)"), + li(text: "**3a-ours — OUR gunbc CI runner (our repo's META-modeling).** OUR workflow instance + OUR fleet: the srv1/srv2 *instantiation* (the Ampere-Altra `ComputeOffer`, the `gunbc-ci-fleet` identity, the per-thread Hz). This **must live in a file that is gunbc's own meta-model** (`dsl/gunbc/ci_*`), and it *consumes* the 3a-generic interface — it is where the concrete SKU import is legitimate. The srv1/srv2 instantiation meta-model is public-in-our-repo; only secrets cross into ctrl."), + li(text: "**3b — ctrl concrete fleet (private).** Access creds, runner registration tokens, truly-secret per-host config — **ctrl `plans.fabric.operator_fleet`** (`compute_fabric.dag:5`; `hardware_selection.dag:8`; memory `idea-pr-compiler-ctrl-boundary`). Concrete rows instantiated against the 3a-ours meta-model."), + ]), + p(text: "**⚠️ #5177 needs this rework (do right after it merges).** `dsl/gunbc/ci_runner.dag` as merged **fuses 3a-generic with 3a-ours**: the generic `runner_spec_from_offer` projection + kernel/arch label tables sit in the *same module* as our concrete fleet (`gunbc_ci_cpu = altra_q6430_catalog`, `gunbc_ci_host_identity = \"gunbc-ci-fleet\"`), and it `import extdeps.cpu.ampere` — a concrete SKU — into what should be the generic interface. Split it: **generic projection → the generalized layer beside `RunnerSpec`** (no SKU import, no fleet rows); **our fleet offer → a `dsl/gunbc/` meta-model file** that consumes the generic projection. Keep the generic interface MINIMAL (trigger→workflow + offer→RunnerSpec) — \"CI doesn't need to know everything.\" ci.yml stays generated + byte-drift-gated (`expected_ci_yml()` `dsl/gunbc/ci_yaml_emit.dag:9`, gate `dsl/tools/ci_yaml_gate.dag`); the emit consumes *our* runner spec, which is *our* fleet offer projected through the *generic* seam. ⚠️ also delete the stale `extdeps/github/ci.dag:7` \"hand-edited, not generated\" comment."), + p(text: "**Dissolution trigger:** `.github/workflows/ci.yml` is emitted from a `.dag` spec whose runner block is *our* fleet offer projected through the *generic* `offer → RunnerSpec` seam (no hand-authored runner block, no fleet SKU in the generic tier); the `HardwareBudget` the scheduler reads is the one *our* offer declares."), + hr(), + h2(text: "Dependency-ordered spine (foundation → end state)"), + p(text: "The work-item view of the phases above, ordered by dependency toward the acceptance gate (absorbed from the former quick-ant-298 roadmap; maps onto the phases, does not replace them)."), + ul(items: [ + li(text: "**F1** scheduler gives heavy nodes the budgeted width — *#5421 merged* (= Phase 1 width landing)."), + li(text: "**F2/F3** key-completeness lens (`ToolchainChange ∈ triggers ⟹ input ∈ inputs_considered`) + `resolved_graph` keyed by construction — *#5423, in review* (= the Phase 2 key-derivation axis, spec-level)."), + li(text: "**P1 — honest keys, verified by execution** *(deps F2,F3)*: realizer-key lens (executed digest ⊇ declared `inputs_considered`, RED otherwise — would have caught the `from_utf8_lossy` collision); stable transform-id (reproducible source/commit/tree hash, not binary bytes); census parity for `parse_table_memo`. (= Phase 2 \"converge key derivations\".)"), + li(text: "**P2 — one door: caching by inhabitance** *(deps P1)*: `realize(subject)` as the sole API; eliminate raw bypass (`build_multi_entry_index`, hand-rolled `ParseTable` HashMap → inhabited via `realize`, DESIGN §6's own example). (= Phase 2 one-kernel/N-backends.)"), + li(text: "**P3 — reach → layer + completeness fail-closed** *(deps P2)* — **the core ask / the acceptance gate**: reach analysis lens (consumer set + boundary → minimal sufficient `Placement`); completeness gate (subject realized below reach → ERROR; non-redundant transform with no supplier at reach → ERROR — **land the redundancy-only cut first**, cost half waits on §4); supplier provisioning + typed request."), + li(text: "**P4 — economic tier** *(deps Phase 0 measurement)*: per-transform measured cost (`PerformanceReceipt` → cost-aware reach); `Materialization` = `Recompute | Memoize | Share` chosen by measured cost."), + li(text: "**P5 — v2 dissolution** *(deps B2)*: `content(T) = content_hash(subgraph)` native; dissolves the binary-hash/version-string approximations and makes P1's spec↔realizer check structural."), + ]), + p(text: "**External blockers (track as work-items):** **B1** #5295 generic-instantiation (FreeMonoid cached without variants — itself an under-keyed in-proc cache) → gates cross-shard `Share` (Phase 2.2). **B2** v2 cross-tree content-hash (\"increment 4\", the `ContentHash` subject on `RealizedStep`; cf. the `execution_receipt_digest` stub at `compute_fabric.dag:588-594`) → gates P5."), + p(text: "**Critical path:** `F2/F3 → P1 → P2 → P3 (redundancy cut) → P3 supplier`. `P1.census`, `P4`, and Phase-2 sub-items parallelize off it; cross-shard `Share` and P5 wait on B1/B2. The redundancy-only P3 cut is the earliest point \"uncached non-redundant work is an error\" is truthful — it needs reach, not the cost model."), + h2(text: "Sequencing & dispatch"), + CodeBlock { code: " ┌─────────────── Phase 0 (keystone: measured cost) ───────────────┐\n │ │\n Phase 1.5a (affected_set) Phase 1 (visible parallelism Phase 2 (cache planner)\n Phase 1.5c (perturb) + hardware-bounded width) │\n — independent of 0 │ │\n │ Phase 1.5b (critical-path total) ←──────┘ (needs 0)\n │\n Phase 3a (runner schema + ci.yml gen) — HardwareBudget carrier co-designed with Phase 1\n │\n Phase 3b (ctrl: srv1/srv2 concrete) — private, separate repo\n" }, + TableBlock { + header: row(cells: [cell(text: "Phase"), cell(text: "Depends on"), cell(text: "Intricacy / Volume"), cell(text: "Notes")]), + alignments: [AlignNone, AlignNone, AlignNone, AlignNone], + rows: [ + row(cells: [cell(text: "0 keystone"), cell(text: "—"), cell(text: "high / medium"), cell(text: "root of everything quantitative; load-bearing seam (`v1_interpreter.rs`, escalate per DESIGN)")]), + row(cells: [cell(text: "1 visible parallelism + width"), cell(text: "0"), cell(text: "high / medium"), cell(text: "shares `HardwareBudget` carrier with 3a")]), + row(cells: [cell(text: "1.5a affected_set"), cell(text: "—"), cell(text: "medium / small"), cell(text: "fail-closed; can start now")]), + row(cells: [cell(text: "1.5b critical-path total"), cell(text: "0"), cell(text: "medium / small"), cell(text: "")]), + row(cells: [cell(text: "1.5c perturb collapse"), cell(text: "—"), cell(text: "medium / small"), cell(text: "can start now")]), + row(cells: [cell(text: "2 cache planner"), cell(text: "0"), cell(text: "high / large"), cell(text: "converges 3 key derivations; first catalog consumer")]), + row(cells: [cell(text: "3a runner schema + ci.yml gen"), cell(text: "(1 for budget carrier)"), cell(text: "high / large"), cell(text: "public; extends `CiFloorSpec` emission")]), + row(cells: [cell(text: "3b ctrl srv1/srv2"), cell(text: "3a"), cell(text: "—"), cell(text: "**private `~/ctrl`**, separate PR")]), + ], + }, + p(text: "**Start-now lanes (no measurement dependency):** 1.5a (affected_set), 1.5c (perturb), and 3a schema groundwork. **Critical path:** Phase 0 → 1 / 2."), + hr(), + h2(text: "Guardrails for every worker (DESIGN)"), + ul(items: [ + li(text: "**Pure central spec, peripheral measured realization** (the §3 invariant above). Anything measured is peripheral — never in the schedule topology the `schedule_eq` witnesses pin."), + li(text: "**DFS existing carriers before minting** (§2/§3): `PlacementSupplyRow`, `CpuDeploymentFacts`, `RunnerSpec`, the cache catalog, `std.pareto`, `RealizationObjective.goals`. The vocabulary mostly exists — wire it, don't re-coin it. (Background verification specifically flagged: do not invent a fresh `DeploymentFacts`.)"), + li(text: "**Rows, not Rust** — express new schedule/cache/runner facts as data; do not cement the seed to satisfy a ratchet (the ratchet is downstream of substrate migration)."), + li(text: "**v2-benefit test (§7)** — the durable artifact is `.dag` that v2 inherits; the Rust seed is only the proving *handler*. A deliverable that is a Rust patch with no `.dag` model failed. (See the §0 \"v2 is the target\" principle.)"), + li(text: "**Fail-closed (§5)** + **purity oracle** on every memo/measurement (byte-identical warm-vs-cold; verdict identical instrumented-vs-not). A bounded \"forever\" ≠ an \"unknown\" error."), + li(text: "**Green by execution, not spec-without-execution.** A real consumer runs green + a discriminating input goes red. Typecheck + grep are not consumers."), + li(text: "**Each phase lands with a named dissolution trigger; the mark is on the carrier.** This doc is coordination only; delete its entry when the carrier records the fact."), + li(text: "**Load-bearing files** (DESIGN-named pipeline stages, substrate types, gates: `v1_interpreter.rs`, `cli_run.rs`, the scheduler, `realization_schedule.dag`) carry a higher bar — escalate before touching under a brief that pre-dates the relevant model PR."), + ]), + h2(text: "Open decisions to confirm before scoping the affected phase"), + ol(items: [ + li(text: "**Placement/budget carrier** — extend `compute_fabric`'s `satisfies` + `PlacementSupplyRow` with the thread-count/Pareto dimension (the width decision = a placement decision), vs a sibling carrier? (DFS task in Phase 1 / 3a.) Do not invent `DeploymentFacts`."), + li(text: "**The $/billing cost axis crosses the std↔product line.** std `CostAccount` carries `\{time,space,power\}`; the $ axis (`CostClass`, `MoneyMicros`) lives in product `compute_fabric`. Confirm: the std schedule's objective stays `\{time,space,power\}`; the **peripheral host realizer** combines it with the product $ axis for the full Pareto pick. (Keeps std product-free.)"), + li(text: "**Cache planner timing** — the *plan* (which layers, what order) can be compile-time data; only the *availability probe* is runtime/peripheral. Confirm the split when scoping Phase 2."), + li(text: "**Runner-label vocabulary** — how far to close `SelfHosted\{labels: List\}` toward a typed topology / a `compute_fabric` offer (3a) without over-fitting to srv1/srv2 (which live in ctrl)."), + li(text: "**Sharding lives in the demand model — Phase 1 and 3 meet at the parallelism shape, not just the budget.** `ParallelismShape = ... | IndependentShards\{shard_count\} | PartitionedReduce\{...\}` (`compute_fabric.dag:280-289`) already exists, and the corpus `RunnableDiscoveryBatch` is a **degenerate (unsharded) projection of a `WorkDemand` whose `parallelism = IndependentShards`** (independent witnesses). So the easy case needs no new stubs; the `Partitioner`/`Reducer`/`SymbolicCost = Node` forwards (`:48-58`) are only for the harder `PartitionedReduce` (whole-tree compile → reduce verdicts). Decide: does Phase 1 express the corpus as an `IndependentShards` `WorkDemand` (preferred — reuses the carrier) vs a scheduler-local shard list?"), + ]), + ] +} + +data realization_measurement_loop_plan: Plan = Plan { + slug: "realization-measurement-loop", + title: "Plan — Realization & Measurement: closing the cost → schedule loop (+ infra onto `.dag`)", + body: realization_measurement_loop_body(), + dissolution: HasTrigger { + text: "Delete this plan once the cost→schedule loop is closed — every pure transform's realize(T) is content-addressed by hash(inputs ⊕ content(T)) and materialized at its minimal Placement, CostAccount is fed by Measured basis (not hardcoded zero), schedule width is hardware-bounded and the spawner is bounded by available_parallelism, the cache catalog has live runtime consumers, and a non-redundant transform with no cache supplier at its reach is a located typed ERROR — so the substrate is measurement-fed rather than input-starved." + } +} diff --git a/dsl/gunbc/plans/resolver_type_name_collision_wall.dag b/dsl/gunbc/plans/resolver_type_name_collision_wall.dag new file mode 100644 index 00000000000..3d480bcc835 --- /dev/null +++ b/dsl/gunbc/plans/resolver_type_name_collision_wall.dag @@ -0,0 +1,125 @@ +module gunbc.plans.resolver_type_name_collision_wall + +import gunbc.plan { Plan, DissolutionTrigger, HasTrigger } +import std.markdown { MarkdownBlock, CodeBlock, TableBlock, AlignNone } +import gunbc.plans.md_helpers { h2, h3, p, li, ul, cell, row, hr } + +fn resolver_type_name_collision_wall_body() -> List { + [ + p(text: "Status: **MODEL — SIGNED (parent bright-stag, 2026-06-23).** The model (mechanism + Q2 policy + activation) is signed; **no resolver edit lands** until the §4 grounding de-fork is clean — the resolver guard is a separate, operator-gated future PR that lands on the de-forked tree. This document is the signed model; §3/§4 record the final ruling."), + p(text: "Owner: jolly-ant-231 (deepest resolver context from the A1 diagnosis). Capstone of the std de-fork lane. Q2 evidence: `docs/plans/dsl-v2-defork-audit.md` §2A (executed distribution)."), + hr(), + h2(text: "1. The hole this wall closes (grounding)"), + p(text: "The A1 (#5615) incident — `type 'EqualsClaim' not found in scope` on `src/v2/workflow/affected_set_floor_runner_test.dag` — was a **fail-OPEN in the resolver** (DESIGN §5): a wrong type resolution passed silently as a different, plausible binding."), + p(text: "Mechanism (proven by execution during the diagnosis; receipt below):"), + ul(items: [ + li(text: "The per-module type scope (`TypeEnv.bindings`) is a `HashMap>` keyed by the **interned id of the UNQUALIFIED type name** — the intern table is global, so two module-level types sharing a short name (`v2.std.verification.TestClaim` the Disj coproduct vs `std.verification.TestClaim` the Conj record) hash to the **same key**."), + li(text: "`import_bindings` is assembled by folding each imported module's bindings with a blind `v1_rt::rc_map_merge` (`v1_compiler_infer.rs` ~11799 and the duplicate ~12393). **Map merge overwrites on duplicate key — last writer wins, no diagnostic.** One authority silently shadows the other."), + li(text: "Because variant-constructor registration (`build_module_context`'s `variant_fold`, ~12894) only fires for `Disj` bindings, when the **record** won the `TestClaim` slot the coproduct's constructors (`EqualsClaim`, `StructuralEqualsClaim`, …) were never registered → \"not found in scope\". A1 was an innocent trigger: it merely grew the test's import-closure to include `std.verification(dsl)` (via `gunbc.ci_failure_class → extdeps.cache.sccache → std.cache_interface → std.verification`)."), + ]), + p(text: "The existing **`VariantCollision`** guard (`v1_std_core.rs:420`, `VariantCollision \{ variant, enum1, enum2, span \}`; emitted in `variant_fold` ~12908) already fails-closed on two imported coproducts sharing a **variant** name. It does **not** cover the level above: two modules contributing the same **type/enum name** to one closure. The wall is that guard lifted one level up — the §5 principle of making the bad state *unwritable* rather than letting it resolve to a plausible wrong binding."), + p(text: "`#5640` (the `TestClaim → AssertionClaim` rename) dissolved the single instance. The wall makes the **class** unwritable so the next closure-expanding PR cannot re-arm it."), + p(text: "Decidability: a closure exporting two distinct authorities under one unqualified name is a **decidable** condition (finite set of `(name_id, declaring_file)` pairs), so this is a §5 *wall now*, not a forever-ratchet. \"never\" is honest here."), + hr(), + h2(text: "2. Mechanism (the model)"), + p(text: "Replace the blind `rc_map_merge` of type bindings, at **both** import-binding assembly sites (`v1_compiler_infer.rs` ~11761 and ~12355 — themselves a §2 duplication this work should dissolve into **one** shared helper), with a **collision-checking merge**:"), + CodeBlock { code: "merge_type_bindings(acc, incoming, policy) -> \{ bindings, collisions \}\n for each (name_id, incoming_binding) in incoming:\n case acc.get(name_id):\n None -> insert\n Some(existing) ->\n if same_authority(existing, incoming): # re-export of ONE authority\n keep existing (no flag)\n else if policy.flags(existing, incoming): # TWO authorities, one name\n emit TypeNameCollision\{ name, module_a, module_b, span \}\n keep existing (deterministic) — fail-closed downstream\n else:\n keep existing (policy excused it)\n" }, + p(text: "Where:"), + ul(items: [ + li(text: "`same_authority(a, b)` ≡ `a.resolved.span.file == b.resolved.span.file` (one declaring file reached via multiple import paths is the SAME authority — a benign re-export, must NOT flag). `TypeBinding` is `\{ name, resolved: Rc, provenance \}` and `Node.span.file` carries the declaring file, so two-authorities-vs-one-re-export is distinguishable today — **no new field required.**"), + li(text: "`TypeNameCollision` is a new `CompilerDiagnostic` variant modeled exactly on `VariantCollision`: `\{ name: String, module_a: String, module_b: String, span \}`, classified **blocking** (`is_error_diagnostic` true), so it fails the resolve/typecheck closed with a located, typed message — the §5 \"loud error, never a warning\"."), + li(text: "Determinism: on collision keep the **first-seen** binding (stable under the existing dep-order traversal) so the error set is reproducible regardless of which authority \"would have won\" the old overwrite."), + ]), + p(text: "This is one mechanism; §3 (the policy) and §4 (activation) are knobs on it, not separate machinery."), + hr(), + h2(text: "3. KEY DECISION (parent's Q2): which collisions fail closed?"), + p(text: "**One predicate, one boolean knob** — `policy.flags(existing, incoming)`:"), + ul(items: [ + li(text: "**flag-ANY** (`require_structural_divergence = false`): `flags = true` for any two distinct authorities (different declaring files) under one name. Even a **byte/structurally-identical mirror** flags — because it is still *two authorities for one concept*, the §3 single-authority violation, just benign-looking. It remains a writable re-fork surface: nothing stops the two copies drifting apart later (which is exactly how A1's landmine formed)."), + li(text: "**flag-DIVERGENT** (`require_structural_divergence = true`): `flags = structural_inequality(existing.resolved, incoming.resolved)`. Fires only when the two definitions actually differ (connective and/or children) — like the Disj-coproduct vs Conj-record case. True mirrors are **excused**."), + ]), + p(text: "`structural_inequality` is a normalized structural compare of the two resolved type Nodes (connective + children names + field types), modulo span/occurrence — the same shape the emitter's coercion homomorphism check already walks; no new comparison primitive needed."), + h3(text: "Trade-off (parent rules on the real distribution)"), + TableBlock { + header: row(cells: [ + cell(text: ""), + cell(text: "flag-ANY"), + cell(text: "flag-DIVERGENT"), + ]), + alignments: [AlignNone, AlignNone, AlignNone], + rows: [ + row(cells: [ + cell(text: "Catches the A1 class (divergent shadow)"), + cell(text: "yes"), + cell(text: "yes"), + ]), + row(cells: [ + cell(text: "Catches a *future* mirror that later drifts"), + cell(text: "yes (at fork time)"), + cell(text: "no (only after drift, when a closure re-imports both)"), + ]), + row(cells: [ + cell(text: "De-fork scope it demands"), + cell(text: "**all** same-name pairs resolved: divergent → rename-apart, mirror → **merge to one authority**"), + cell(text: "only divergent pairs resolved; mirrors may stay"), + ]), + row(cells: [ + cell(text: "False-positive risk"), + cell(text: "a legitimately-duplicated mirror that *cannot* be merged yet would block until merged"), + cell(text: "a divergent pair that *looks* similar but isn't structurally-equal still correctly fires"), + ]), + row(cells: [ + cell(text: "§3 fidelity"), + cell(text: "full (one name ⇒ one authority, tree-wide)"), + cell(text: "partial (tolerates two authorities iff currently identical)"), + ]), + ], + }, + h3(text: "RULED — `flag-ANY` (parent bright-stag, signed 2026-06-23)"), + p(text: "**`require_structural_divergence = FALSE`.** Settled against the measured distribution (the executed per-basename audit in `docs/plans/dsl-v2-defork-audit.md` §2A — `structural_inequality` run over all 9 std basename pairs + a 351-entry floor-closure reachability BFS). The audit confirmed the cant-unify-yet set (basenames needing a milestone *later than* the grounding de-fork) is **\{node, coercion\} exactly** — no third stuck mirror — so flag-ANY does not block on an un-unifiable pair."), + p(text: "Two consequences parent reconfirmed:"), + ul(items: [ + li(text: "**flag-ANY FIRES on byte-identical mirror shared type-names too** (the audit's 3 in `algebra`, 3 in `integer`, 1 in `float`), not only on differing ones. This is **intended**: a byte-identical mirror is still *two homes for one type* = the §3 single-authority violation and a writable re-fork surface. So the de-fork must **merge even the mirrors** (delete the v2 copy, repoint imports), and flag-ANY is exactly what forces that. flag-DIVERGENT would *tolerate* the byte-mirrors — a standing §3 hole — so it is strictly worse here (it also still fires on every grounding, sparing nothing). Mirrors are therefore **resolved by the de-fork, not exempted**."), + li(text: "**The exemption roster carries NO `\{node, coercion\}` entry — DROPPED as vacuous.** node and coercion (and `logic`, and post-#5640 `verification`) share **zero** type names — only the *basename* — so the type-name guard **never fires** on them. A roster entry for a collision the mechanism cannot produce is a §5 inert scaffold (a dead line). Their collision is a module-**basename** rename on the Route-C / v1-delete surface — a *different* mechanism, still tracked (audit category-(c), `dissolve-on = v1-delete`), not by this guard. The guard's roster is therefore **deliberately empty** — recorded here so its emptiness reads as a decision, not an omission. (See §6.)"), + ]), + hr(), + h2(text: "4. ACTIVATION / DORMANCY (parent's Q3): **lands-already-green** (preferred)"), + p(text: "Two options:"), + ul(items: [ + li(text: "**Staged-enable** (guard lands dormant, flips fail-closed later): carries **dormant-guard state** — a loaded mechanism left unwired. DESIGN §5/§6 names this an anti-pattern: an inert guard is \"coverage by illusion\", a latent lie until the flip, and adds a flip-event to sequence and a window where the guard exists but does not gate."), + li(text: "**Lands-already-green** (preferred): the de-fork lane first removes **every** collision the chosen policy flags from the tree; *then* the guard lands **already fail-closed and green**. No dormant state, no flip event. The guard's own green landing is **self-certifying**: it is green only if zero flagged collisions remain, so merging it *proves* the tree is collision-free under the policy. This is the §5 \"wall lands live or not at all\"."), + ]), + p(text: "Sequencing (hard dependency, RULED): **the grounding de-fork of the shared-type-name set `\{algebra, nat, effects, float, integer\}` → guard lands flag-ANY, fail-closed, green, in one PR.** Each of those five is merged to a single authority (delete the v2 copy / repoint, or the operator grounding-unification design where the bodies diverge) — mirrors included (§3). The set is fronted by the **LIVE pair `\{algebra (75 floor entries), nat (4)\}`** (their `std.` / `v2.std.` co-occur in real floor closures today and silently fail-open — benign only because they shadow record-with-record, not the coproduct-variant-drop that broke `verification` under A1) and completed by the **latent `\{effects, float, integer\}`** (no co-occurring closure today, but re-arm risks — exactly how `verification` went latent→LIVE under A1's closure expansion). `verification` already cleared (#5640); `\{node, coercion, logic\}` are off this surface (zero shared type-names)."), + p(text: "The guard PR is mergeable iff the full floor corpus resolves clean **with the guard active** — which holds iff that five-basename de-fork is complete. Its green landing therefore **self-certifies** the shared-type-name surface is collision-free: the wall is the **capstone** of the de-fork lane, correctly located. No dormant-guard state, no flip event — lands-already-green."), + hr(), + h2(text: "5. Proof plan (model-only; how it is proven by execution when authored)"), + p(text: "Per DESIGN §5 (\"done\" = a real consumer green by execution + a discriminating input that goes red when the behavior is wrong):"), + ul(items: [ + li(text: "**GREEN-by-execution:** with the de-fork complete, run the exact floor closure (`claim_executor --source-root dsl --source-root src/v2`, both orders) — full corpus resolves clean **with the guard active**. (Baseline receipt already in hand from #1: post-rename, `affected_set_floor_runner_test` PASSes both orders, 56 modules.)"), + li(text: "**Discriminating RED (the falsifier):** re-introduce a single synthetic same-name pair into a test's closure and assert the guard emits `TypeNameCollision` and fails closed — and that *removing* it returns green. Run it **twice** to pin the flag-ANY semantics: once with a **divergent** pair (different bodies) and once with a **byte-identical mirror** pair — *both* must fire (flag-ANY excuses neither). A flag-DIVERGENT build would let the mirror through; that it does **not** is the §3-fidelity control."), + li(text: "**No-regression control:** a type legitimately re-exported through multiple import paths (one declaring file, many hops) must stay green — proves `same_authority` (span.file identity) correctly excuses re-exports and the wall is not over-broad."), + ]), + hr(), + h2(text: "6. Scope guard / what this is NOT"), + ul(items: [ + li(text: "**No resolver edit lands** here — model only until checkpoint-sign + de-fork clean."), + li(text: "Does **not** touch the dsl↔v2 std module-**basename** reorganization (Route C / v1-delete) — orthogonal, operator-strategic. The wall keys on shared **type-name** identity within a closure, so the zero-shared-type-name basenames `\{node, coercion, logic, verification\}` are off its surface entirely (this is why the roster carries no `\{node, coercion\}` entry, §3). Their basename de-fork stays tracked in the audit's category-(c) (`dissolve-on = v1-delete`), a different mechanism. The wall is compatible with whatever Route C decides."), + li(text: "Mirrors the existing `VariantCollision` precedent; introduces no new resolver concept beyond lifting that guard one level and dissolving the duplicate import-binding folds into one checked-merge helper (a §2 win bundled in)."), + ]), + h2(text: "7. Open items"), + ul(items: [ + li(text: "**RESOLVED** — Q2 policy: `flag-ANY` signed (§3); per-basename audit executed and homed in `docs/plans/dsl-v2-defork-audit.md` §2A; activation gate set to the five-basename grounding de-fork (§4). Roster: deliberately empty (§3)."), + li(text: "Carried to the future resolver PR (not this model): confirm both import-binding assembly sites (~11761, ~12355) are the only type-binding merge loci (the `std.types`-special-cased branch folds key-by-key already and is naturally covered by the same checked-merge helper)."), + li(text: "Dependency owned elsewhere: the five-basename grounding de-fork (`algebra` authority ruled; `nat`/`integer`/`float` via #5428 numeric tower; `effects` axis decision) must complete before the guard PR can land green. `\{node, coercion\}` basename de-fork stays on the Route-C / v1-delete surface (audit category-(c)), unaffected by this guard."), + ]), + ] +} + +data resolver_type_name_collision_wall_plan: Plan = Plan { + slug: "resolver-type-name-collision-wall", + title: "Resolver type-name-collision wall (§5 construction wall) — model-before-implement", + body: resolver_type_name_collision_wall_body(), + dissolution: HasTrigger { + text: "Delete this model-only DESIGN doc once the resolver type-name-collision wall is implemented and merged — the flag-ANY guard fires fail-closed on any same-name cross-authority type pair (TypeNameCollision diagnostic), the floor closure lands already-green after the de-fork, and the discriminating RED witness (synthetic divergent + byte-identical-mirror pairs both fire) is proven by execution — so this model is realized in the resolver." + } +} diff --git a/src/v2/compiler/manual/typescript_bind_let_iife_emit_test.dag b/src/v2/compiler/manual/typescript_bind_let_iife_emit_test.dag new file mode 100644 index 00000000000..99716ce1c33 --- /dev/null +++ b/src/v2/compiler/manual/typescript_bind_let_iife_emit_test.dag @@ -0,0 +1,168 @@ +module v2.test.manual.typescript_bind_let_iife_emit + +import v2.std.host_transport { target_emit_host_runtime_row_unconfigured } +import v2.std.diagnostic { Accepted, Outcome, Rejected, bind_outcome } +import v2.std.collection { Map, empty_map, map_insert } +import v2.std.node { Symbol } +import v2.std.compilers.target_model { + ValueProducing, + TargetModel, + TargetValueExpression, + TargetValueExpressionProjection, + target_value_expression_binding_ref, + target_value_expression_bind_let, + target_value_expression_loop, + target_value_expression_closure, + target_value_expression_to_concrete_tokens, + target_model_emit_transforms_empty +} +import extdeps.communication.medium { Medium } +import v2.compiler.translate { serialize_concrete_syntax_tokens_to_source } +import v2.extdeps.languages.typescript { + ts_mvp1_target_model_node, + ts_operator_realizations_catalog_node, + ts_value_expression_projection, + ts_value_expression_projection_with_block_evaluation_mode, + ts_wave2a_lex +} +import v2.extdeps.languages.dag { + dag_value_expression_projection, + dag_operator_realizations_catalog_node +} +import v2.std.logic { Bool } + +fn bind_let_binding_spellings() -> Map { + map_insert( + map_insert( + map_insert(empty_map(), ^bind_let_binding_k, "k"), + ^bind_let_binding_v, + "v" + ), + ^bind_let_binding_b, + "b" + ) +} + +fn bind_let_target_model() -> TargetModel { + TargetModel { + bundle: ts_mvp1_target_model_node(), + lex: ts_wave2a_lex(), + binding_spellings: bind_let_binding_spellings(), + token_class_emit_transforms: target_model_emit_transforms_empty, + authority_source_text: "", + runtime_row: target_emit_host_runtime_row_unconfigured + } +} + +fn ts_bind_let_expr() -> TargetValueExpression { + target_value_expression_bind_let( + bind_key: target_value_expression_binding_ref(binding: ^bind_let_binding_k), + bind_value: target_value_expression_binding_ref(binding: ^bind_let_binding_v), + bind_body: target_value_expression_binding_ref(binding: ^bind_let_binding_b) + ) +} + +fn ts_bind_let_emit_with_projection( + projection: TargetValueExpressionProjection +) -> Outcome> { + bind_outcome( + o: target_value_expression_to_concrete_tokens( + expr: ts_bind_let_expr(), + projection: projection, + catalog: ts_operator_realizations_catalog_node() + ), + f: fn(tokens) { + serialize_concrete_syntax_tokens_to_source( + target: bind_let_target_model(), + tokens: tokens + ) + } + ) +} + +fn ts_bind_let_emit_statement_sequenced() -> String { + match ts_bind_let_emit_with_projection( + projection: ts_value_expression_projection() + ) { + Accepted { value: source, diagnostics: _ } => source.carried + Rejected { diagnostics: _ } => "BIND_LET_EMIT_REJECTED" + } +} + +fn ts_bind_let_emit_value_producing() -> String { + match ts_bind_let_emit_with_projection( + projection: ts_value_expression_projection_with_block_evaluation_mode( + block_evaluation_mode: ValueProducing + ) + ) { + Accepted { value: source, diagnostics: _ } => source.carried + Rejected { diagnostics: _ } => "BIND_LET_EMIT_REJECTED" + } +} + +test fn ts_bind_let_iife_emit_exact_holds() -> Bool { + ts_bind_let_emit_statement_sequenced() == "(function () { let k =v;return b; })()" +} + +test fn ts_bind_let_mode_perturbation_flips_holds() -> Bool { + (ts_bind_let_emit_statement_sequenced() == "(function () { let k =v;return b; })()") + && (ts_bind_let_emit_statement_sequenced() != ts_bind_let_emit_value_producing()) + && (ts_bind_let_emit_statement_sequenced() != "BIND_LET_EMIT_REJECTED") +} + +fn block_construct_loop_expr() -> TargetValueExpression { + target_value_expression_loop( + body: target_value_expression_binding_ref(binding: ^bind_let_binding_b) + ) +} + +test fn ts_loop_statement_sequenced_fails_closed_holds() -> Bool { + match target_value_expression_to_concrete_tokens( + expr: block_construct_loop_expr(), + projection: ts_value_expression_projection(), + catalog: ts_operator_realizations_catalog_node() + ) { + Accepted { value: _, diagnostics: _ } => false + Rejected { diagnostics: _ } => true + } +} + +test fn dag_loop_value_producing_emits_holds() -> Bool { + match target_value_expression_to_concrete_tokens( + expr: block_construct_loop_expr(), + projection: dag_value_expression_projection(), + catalog: dag_operator_realizations_catalog_node() + ) { + Accepted { value: _, diagnostics: _ } => true + Rejected { diagnostics: _ } => false + } +} + +fn block_construct_closure_expr() -> TargetValueExpression { + target_value_expression_closure( + params: [^bind_let_binding_k], + body: target_value_expression_binding_ref(binding: ^bind_let_binding_b) + ) +} + +test fn ts_closure_statement_sequenced_fails_closed_holds() -> Bool { + match target_value_expression_to_concrete_tokens( + expr: block_construct_closure_expr(), + projection: ts_value_expression_projection(), + catalog: ts_operator_realizations_catalog_node() + ) { + Accepted { value: _, diagnostics: _ } => false + Rejected { diagnostics: _ } => true + } +} + +test fn dag_closure_value_producing_emits_holds() -> Bool { + match target_value_expression_to_concrete_tokens( + expr: block_construct_closure_expr(), + projection: dag_value_expression_projection(), + catalog: dag_operator_realizations_catalog_node() + ) { + Accepted { value: _, diagnostics: _ } => true + Rejected { diagnostics: _ } => false + } +} diff --git a/src/v2/extdeps/languages/dag.dag b/src/v2/extdeps/languages/dag.dag index 846d2e64d21..824abd98d1b 100644 --- a/src/v2/extdeps/languages/dag.dag +++ b/src/v2/extdeps/languages/dag.dag @@ -120,7 +120,10 @@ import v2.std.compilers.target_model { grammar_relation_row_attach_bodied_scaffold, target_operator_realizations_catalog_node, value_expr_projection_bundle_node, target_model_emit_transforms_empty, - Prepend} + Prepend, + BlockEvaluationMode, + ValueProducing, + derive_bodied_arrow_scaffold} import v2.std.logic { Bool } import v2.std.algebra { Cons, Empty, fold_list, for_all, list_append, list_snoc_item } import v2.std.diagnostic { @@ -4952,10 +4955,15 @@ fn dag_value_expression_projection() -> TargetValueExpressionProjection { close: ^dag_token_rbrace, fat_arrow: ^dag_token_fat_arrow, arm_separator: ^dag_token_comma - } + }, + block_evaluation_mode: dag_block_evaluation_mode() } } +fn dag_block_evaluation_mode() -> BlockEvaluationMode { + ValueProducing +} + fn dag_operator_realizations_catalog_node() -> Node { target_operator_realizations_catalog_node(rows: []) } @@ -4977,10 +4985,11 @@ fn dag_mvp1_pick_statement_suffix_tokens() -> List { } fn dag_mvp1_pick_bodied_arrow_statement_scaffold() -> TargetBodiedArrowStatementScaffold { - TargetBodiedArrowStatementScaffold { - prefix: dag_mvp1_pick_statement_prefix_tokens(), - suffix: dag_mvp1_pick_statement_suffix_tokens() - } + derive_bodied_arrow_scaffold( + signature_with_open: dag_mvp1_pick_statement_prefix_tokens(), + block_close: dag_mvp1_pick_statement_suffix_tokens(), + mode: dag_block_evaluation_mode() + ) } fn dag_mvp1_pick_grammar_relation_row_node() -> Node { @@ -5119,10 +5128,11 @@ fn dag_mvp1_bind_statement_prefix_tokens() -> List { } fn dag_mvp1_bind_bodied_arrow_statement_scaffold() -> TargetBodiedArrowStatementScaffold { - TargetBodiedArrowStatementScaffold { - prefix: dag_mvp1_bind_statement_prefix_tokens(), - suffix: dag_mvp1_pick_statement_suffix_tokens() - } + derive_bodied_arrow_scaffold( + signature_with_open: dag_mvp1_bind_statement_prefix_tokens(), + block_close: dag_mvp1_pick_statement_suffix_tokens(), + mode: dag_block_evaluation_mode() + ) } fn dag_mvp1_bind_grammar_relation_row_node() -> Node { @@ -5261,10 +5271,11 @@ fn dag_mvp1_loop_statement_prefix_tokens() -> List { } fn dag_mvp1_loop_bodied_arrow_statement_scaffold() -> TargetBodiedArrowStatementScaffold { - TargetBodiedArrowStatementScaffold { - prefix: dag_mvp1_loop_statement_prefix_tokens(), - suffix: dag_mvp1_pick_statement_suffix_tokens() - } + derive_bodied_arrow_scaffold( + signature_with_open: dag_mvp1_loop_statement_prefix_tokens(), + block_close: dag_mvp1_pick_statement_suffix_tokens(), + mode: dag_block_evaluation_mode() + ) } fn dag_mvp1_loop_grammar_relation_row_node() -> Node { @@ -5525,10 +5536,11 @@ fn dag_mvp1_rec_statement_prefix_tokens() -> List { } fn dag_mvp1_rec_bodied_arrow_statement_scaffold() -> TargetBodiedArrowStatementScaffold { - TargetBodiedArrowStatementScaffold { - prefix: dag_mvp1_rec_statement_prefix_tokens(), - suffix: dag_mvp1_pick_statement_suffix_tokens() - } + derive_bodied_arrow_scaffold( + signature_with_open: dag_mvp1_rec_statement_prefix_tokens(), + block_close: dag_mvp1_pick_statement_suffix_tokens(), + mode: dag_block_evaluation_mode() + ) } fn dag_mvp1_rec_grammar_relation_row_node() -> Node { @@ -5669,10 +5681,11 @@ fn dag_mvp1_field_access_statement_prefix_tokens() -> List } fn dag_mvp1_field_access_bodied_arrow_statement_scaffold() -> TargetBodiedArrowStatementScaffold { - TargetBodiedArrowStatementScaffold { - prefix: dag_mvp1_field_access_statement_prefix_tokens(), - suffix: dag_mvp1_pick_statement_suffix_tokens() - } + derive_bodied_arrow_scaffold( + signature_with_open: dag_mvp1_field_access_statement_prefix_tokens(), + block_close: dag_mvp1_pick_statement_suffix_tokens(), + mode: dag_block_evaluation_mode() + ) } fn dag_mvp1_field_access_grammar_relation_row_node() -> Node { diff --git a/src/v2/extdeps/languages/typescript.dag b/src/v2/extdeps/languages/typescript.dag index 5c570b2b6db..bf91167e65c 100644 --- a/src/v2/extdeps/languages/typescript.dag +++ b/src/v2/extdeps/languages/typescript.dag @@ -145,7 +145,11 @@ import v2.std.compilers.target_model { value_expr_projection_bundle_node, RecordLiteralTypeNaming, Omit, - Prepend + Prepend, + BlockEvaluationMode, + ValueProducing, + StatementSequenced, + derive_bodied_arrow_scaffold } import v2.std.node { Arrow, @@ -536,13 +540,33 @@ fn ts_mvp1_emitted_add_fn_with_body_node() -> Node { } fn ts_value_expression_projection() -> TargetValueExpressionProjection { - ts_value_expression_projection_with_record_literal_naming( - record_literal_names_type: Omit + ts_value_expression_projection_full( + record_literal_names_type: Omit, + block_evaluation_mode: ts_block_evaluation_mode() ) } fn ts_value_expression_projection_with_record_literal_naming( record_literal_names_type: RecordLiteralTypeNaming +) -> TargetValueExpressionProjection { + ts_value_expression_projection_full( + record_literal_names_type: record_literal_names_type, + block_evaluation_mode: ts_block_evaluation_mode() + ) +} + +fn ts_value_expression_projection_with_block_evaluation_mode( + block_evaluation_mode: BlockEvaluationMode +) -> TargetValueExpressionProjection { + ts_value_expression_projection_full( + record_literal_names_type: Omit, + block_evaluation_mode: block_evaluation_mode + ) +} + +fn ts_value_expression_projection_full( + record_literal_names_type: RecordLiteralTypeNaming, + block_evaluation_mode: BlockEvaluationMode ) -> TargetValueExpressionProjection { TargetValueExpressionProjection { binding_ref_form: TargetBindingRefShape { ident_token: ^ts_token_ident }, @@ -559,13 +583,13 @@ fn ts_value_expression_projection_with_record_literal_naming( }, closure_form: TargetClosureShape { - fn_token: ^ts_closure_emit_unsupported, - open: ^ts_closure_emit_unsupported, - separator: ^ts_closure_emit_unsupported, - close: ^ts_closure_emit_unsupported, - body_open: ^ts_closure_emit_unsupported, - body_close: ^ts_closure_emit_unsupported, - param_ident_token: ^ts_closure_emit_unsupported + fn_token: ^ts_token_kw_function, + open: ^ts_token_lparen, + separator: ^ts_token_comma, + close: ^ts_token_rparen, + body_open: ^ts_token_lbrace, + body_close: ^ts_token_rbrace, + param_ident_token: ^ts_token_ident }, effect_apply_form: TargetEffectApplyShape { @@ -615,7 +639,8 @@ fn ts_value_expression_projection_with_record_literal_naming( close: ^ts_token_rbrace, fat_arrow: ^ts_token_fat_arrow, arm_separator: ^ts_token_comma - } + }, + block_evaluation_mode: block_evaluation_mode } } @@ -630,7 +655,14 @@ fn ts_operator_realizations_catalog_node() -> Node { target_operator_realizations_catalog_node(rows: [ts_add_operator_realization_row()]) } -fn ts_mvp1_fn_add_statement_prefix_tokens() -> List { +fn ts_block_evaluation_mode() -> BlockEvaluationMode { + StatementSequenced { + return_token: ^ts_token_kw_return, + statement_terminator: ^ts_token_semicolon + } +} + +fn ts_add_signature_with_open() -> List { [ FixedToken { token_class: ^ts_token_kw_function }, BoundToken { token_class: ^ts_token_ident, binding: ^ts_binding_fn_add }, @@ -645,23 +677,32 @@ fn ts_mvp1_fn_add_statement_prefix_tokens() -> List { FixedToken { token_class: ^ts_token_rparen }, FixedToken { token_class: ^ts_token_colon }, FixedToken { token_class: ^ts_token_ty_number }, - FixedToken { token_class: ^ts_token_lbrace }, - FixedToken { token_class: ^ts_token_kw_return } + FixedToken { token_class: ^ts_token_lbrace } ] } -fn ts_mvp1_fn_add_statement_suffix_tokens() -> List { +fn ts_add_block_close() -> List { [ - FixedToken { token_class: ^ts_token_semicolon }, FixedToken { token_class: ^ts_token_rbrace } ] } fn ts_mvp1_bodied_arrow_statement_scaffold() -> TargetBodiedArrowStatementScaffold { - TargetBodiedArrowStatementScaffold { - prefix: ts_mvp1_fn_add_statement_prefix_tokens(), - suffix: ts_mvp1_fn_add_statement_suffix_tokens() - } + derive_bodied_arrow_scaffold( + signature_with_open: ts_add_signature_with_open(), + block_close: ts_add_block_close(), + mode: ts_block_evaluation_mode() + ) +} + +fn ts_mvp1_fn_add_statement_prefix_tokens() -> List { + let scaffold = ts_mvp1_bodied_arrow_statement_scaffold() + scaffold.prefix +} + +fn ts_mvp1_fn_add_statement_suffix_tokens() -> List { + let scaffold = ts_mvp1_bodied_arrow_statement_scaffold() + scaffold.suffix } fn ts_mvp1_compose_add_fn_tokens(body_tokens: List) -> List { diff --git a/src/v2/std/compilers/target_model.dag b/src/v2/std/compilers/target_model.dag index df83e5dbf0b..5bb0e5797a7 100644 --- a/src/v2/std/compilers/target_model.dag +++ b/src/v2/std/compilers/target_model.dag @@ -710,6 +710,13 @@ type TargetLoopShape { loop_token: Symbol } +type BlockEvaluationMode + = ValueProducing + | StatementSequenced { + return_token: Symbol + statement_terminator: Symbol + } + type RecordLiteralTypeNaming = Prepend | Omit @@ -746,6 +753,7 @@ type TargetValueExpressionProjection { record_construct_form: TargetRecordConstructShape field_access_form: TargetFieldAccessShape match_form: TargetMatchShape + block_evaluation_mode: BlockEvaluationMode } type TargetBodiedArrowStatementScaffold { @@ -753,6 +761,34 @@ type TargetBodiedArrowStatementScaffold { suffix: List } +fn derive_bodied_arrow_scaffold( + signature_with_open: List, + block_close: List, + mode: BlockEvaluationMode +) -> TargetBodiedArrowStatementScaffold { + match mode { + ValueProducing => + TargetBodiedArrowStatementScaffold { + prefix: signature_with_open, + suffix: block_close + } + StatementSequenced { + return_token: return_token, + statement_terminator: statement_terminator + } => + TargetBodiedArrowStatementScaffold { + prefix: list_snoc_item( + xs: signature_with_open, + item: FixedToken { token_class: return_token } + ), + suffix: list_append( + left: [FixedToken { token_class: statement_terminator }], + right: block_close + ) + } + } +} + fn target_model_type_atom_node(identity: Symbol) -> Node { Node { kind: TypeNode { connective: Atom { identity: identity } }, @@ -1535,6 +1571,87 @@ fn record_literal_type_naming_from_symbol(symbol: Symbol) -> Outcome Node { + match mode { + ValueProducing => + target_model_type_conj_node( + children: [ + target_model_named_edge( + name: ^target_value_expr_field_block_eval_kind, + target: target_model_type_atom_node( + identity: ^block_evaluation_mode_value_producing + ) + ) + ] + ) + StatementSequenced { + return_token: return_token, + statement_terminator: statement_terminator + } => + target_model_type_conj_node( + children: [ + target_model_named_edge( + name: ^target_value_expr_field_block_eval_kind, + target: target_model_type_atom_node( + identity: ^block_evaluation_mode_statement_sequenced + ) + ), + target_model_named_edge( + name: ^target_value_expr_field_block_eval_return_token, + target: target_model_type_atom_node(identity: return_token) + ), + target_model_named_edge( + name: ^target_value_expr_field_block_eval_terminator, + target: target_model_type_atom_node(identity: statement_terminator) + ) + ] + ) + } +} + +fn decode_block_evaluation_mode(bundle: Node) -> Outcome { + bind_outcome( + o: projection_bundle_symbol_field( + bundle: bundle, + field: ^target_value_expr_field_block_eval_kind + ), + f: fn(kind) { + if kind == ^block_evaluation_mode_value_producing { + outcome_accepted(ValueProducing) + } else if kind == ^block_evaluation_mode_statement_sequenced { + bind_outcome( + o: projection_bundle_symbol_field( + bundle: bundle, + field: ^target_value_expr_field_block_eval_return_token + ), + f: fn(return_token) { + bind_outcome( + o: projection_bundle_symbol_field( + bundle: bundle, + field: ^target_value_expr_field_block_eval_terminator + ), + f: fn(statement_terminator) { + outcome_accepted( + StatementSequenced { + return_token: return_token, + statement_terminator: statement_terminator + } + ) + } + ) + } + ) + } else { + outcome_rejected( + target_value_expr_operand_wire_malformed_diagnostic( + wire: bundle + ) + ) + } + } + ) +} + fn decode_record_construct_shape_bundle(bundle: Node) -> Outcome { bind_outcome( o: projection_bundle_symbol_field(bundle: bundle, field: ^target_value_expr_field_record_open), @@ -1924,6 +2041,48 @@ fn decode_vep_chain_match( bind_outcome( o: decode_vep_parent_match(bundle: bundle), f: fn(match_form) { + decode_vep_chain_block_eval( + bundle: bundle, + binding_ref_form: binding_ref_form, + primitive_apply_form: primitive_apply_form, + callable_apply_form: callable_apply_form, + closure_form: closure_form, + effect_apply_form: effect_apply_form, + conditional_form: conditional_form, + let_form: let_form, + loop_form: loop_form, + record_construct_form: record_construct_form, + field_access_form: field_access_form, + match_form: match_form + ) + } + ) +} + +fn decode_vep_parent_block_eval(bundle: Node) -> Outcome { + bind_outcome( + o: projection_bundle_child(bundle: bundle, name: ^target_value_expr_field_block_eval), + f: decode_block_evaluation_mode + ) +} + +fn decode_vep_chain_block_eval( + bundle: Node, + binding_ref_form: TargetBindingRefShape, + primitive_apply_form: TargetPrimitiveApplyShape, + callable_apply_form: TargetCallApplyShape, + closure_form: TargetClosureShape, + effect_apply_form: TargetEffectApplyShape, + conditional_form: TargetConditionalShape, + let_form: TargetBindLetShape, + loop_form: TargetLoopShape, + record_construct_form: TargetRecordConstructShape, + field_access_form: TargetFieldAccessShape, + match_form: TargetMatchShape +) -> Outcome { + bind_outcome( + o: decode_vep_parent_block_eval(bundle: bundle), + f: fn(block_evaluation_mode) { outcome_accepted( TargetValueExpressionProjection { binding_ref_form: binding_ref_form, @@ -1936,7 +2095,8 @@ fn decode_vep_chain_match( loop_form: loop_form, record_construct_form: record_construct_form, field_access_form: field_access_form, - match_form: match_form + match_form: match_form, + block_evaluation_mode: block_evaluation_mode } ) } @@ -4527,6 +4687,83 @@ fn target_value_expr_bind_let_child_from_wire( target_value_expr_conditional_child_from_wire(wire: wire, field: field) } +fn bind_let_value_producing_tokens( + projection: TargetValueExpressionProjection, + key_tokens: List, + value_tokens: List, + body_tokens: List +) -> List { + list_append( + left: list_append( + left: list_append( + left: list_append( + left: list_append( + left: [ + FixedToken { token_class: projection.let_form.let_token } + ], + right: key_tokens + ), + right: [ + FixedToken { token_class: projection.let_form.assign_token } + ] + ), + right: value_tokens + ), + right: [ + FixedToken { token_class: projection.let_form.in_token } + ] + ), + right: body_tokens + ) +} + +fn bind_let_statement_sequenced_tokens( + projection: TargetValueExpressionProjection, + key_tokens: List, + value_tokens: List, + body_tokens: List, + return_token: Symbol, + statement_terminator: Symbol +) -> List { + list_append( + left: list_append( + left: list_append( + left: list_append( + left: list_append( + left: list_append( + left: [ + FixedToken { token_class: projection.primitive_apply_form.open }, + FixedToken { token_class: projection.closure_form.fn_token }, + FixedToken { token_class: projection.closure_form.open }, + FixedToken { token_class: projection.closure_form.close }, + FixedToken { token_class: projection.closure_form.body_open }, + FixedToken { token_class: projection.let_form.let_token } + ], + right: key_tokens + ), + right: [ + FixedToken { token_class: projection.let_form.assign_token } + ] + ), + right: value_tokens + ), + right: [ + FixedToken { token_class: statement_terminator }, + FixedToken { token_class: return_token } + ] + ), + right: body_tokens + ), + right: [ + FixedToken { token_class: statement_terminator }, + FixedToken { token_class: projection.closure_form.body_close }, + FixedToken { token_class: projection.primitive_apply_form.close }, + FixedToken { token_class: projection.primitive_apply_form.open }, + FixedToken { token_class: projection.primitive_apply_form.close } + ] + ) +} + fn target_value_expression_bind_let_to_concrete_tokens( expr: TargetValueExpression, projection: TargetValueExpressionProjection, @@ -4574,39 +4811,31 @@ fn target_value_expression_bind_let_to_concrete_tokens( catalog: catalog ), f: fn(body_tokens) { - outcome_accepted( - list_append( - left: list_append( - left: list_append( - left: list_append( - left: list_append( - left: Cons { - head: FixedToken { - token_class: projection.let_form.let_token - }, - tail: Empty - }, - right: key_tokens - ), - right: Cons { - head: FixedToken { - token_class: projection.let_form.assign_token - }, - tail: Empty - } - ), - right: value_tokens - ), - right: Cons { - head: FixedToken { - token_class: projection.let_form.in_token - }, - tail: Empty - } - ), - right: body_tokens - ) - ) + match projection.block_evaluation_mode { + ValueProducing => + outcome_accepted( + bind_let_value_producing_tokens( + projection: projection, + key_tokens: key_tokens, + value_tokens: value_tokens, + body_tokens: body_tokens + ) + ) + StatementSequenced { + return_token: return_token, + statement_terminator: statement_terminator + } => + outcome_accepted( + bind_let_statement_sequenced_tokens( + projection: projection, + key_tokens: key_tokens, + value_tokens: value_tokens, + body_tokens: body_tokens, + return_token: return_token, + statement_terminator: statement_terminator + ) + ) + } } ) } @@ -4654,10 +4883,54 @@ fn target_value_expr_loop_child_from_wire(wire: Node) -> Outcome Diagnostic { + Diagnostic { + reason: ^statement_sequenced_block_construct_unwired, + at: node_locus(node: wire), + correction: Unavailable { reason: ExternalContractUnknown } + } +} + +fn statement_sequenced_block_construct_guard( + block_evaluation_mode: BlockEvaluationMode, + wire: Node +) -> Outcome { + match block_evaluation_mode { + ValueProducing => outcome_accepted(true) + StatementSequenced { + return_token: _, + statement_terminator: _ + } => + outcome_rejected( + statement_sequenced_block_construct_unwired_diagnostic(wire: wire) + ) + } +} + fn target_value_expression_loop_to_concrete_tokens( expr: TargetValueExpression, projection: TargetValueExpressionProjection, catalog: Node +) -> Outcome> { + bind_outcome( + o: statement_sequenced_block_construct_guard( + block_evaluation_mode: projection.block_evaluation_mode, + wire: expr.node + ), + f: fn(_) { + target_value_expression_loop_to_concrete_tokens_inner( + expr: expr, + projection: projection, + catalog: catalog + ) + } + ) +} + +fn target_value_expression_loop_to_concrete_tokens_inner( + expr: TargetValueExpression, + projection: TargetValueExpressionProjection, + catalog: Node ) -> Outcome> { bind_outcome( o: target_value_expr_loop_wire_schema_valid(wire: expr.node), @@ -5332,6 +5605,26 @@ fn target_value_expression_match_to_concrete_tokens( expr: TargetValueExpression, projection: TargetValueExpressionProjection, catalog: Node +) -> Outcome> { + bind_outcome( + o: statement_sequenced_block_construct_guard( + block_evaluation_mode: projection.block_evaluation_mode, + wire: expr.node + ), + f: fn(_) { + target_value_expression_match_to_concrete_tokens_inner( + expr: expr, + projection: projection, + catalog: catalog + ) + } + ) +} + +fn target_value_expression_match_to_concrete_tokens_inner( + expr: TargetValueExpression, + projection: TargetValueExpressionProjection, + catalog: Node ) -> Outcome> { bind_outcome( o: target_value_expr_match_wire_schema_valid(wire: expr.node), @@ -5745,6 +6038,26 @@ fn target_value_expression_closure_to_concrete_tokens( expr: TargetValueExpression, projection: TargetValueExpressionProjection, catalog: Node +) -> Outcome> { + bind_outcome( + o: statement_sequenced_block_construct_guard( + block_evaluation_mode: projection.block_evaluation_mode, + wire: expr.node + ), + f: fn(_) { + target_value_expression_closure_to_concrete_tokens_inner( + expr: expr, + projection: projection, + catalog: catalog + ) + } + ) +} + +fn target_value_expression_closure_to_concrete_tokens_inner( + expr: TargetValueExpression, + projection: TargetValueExpressionProjection, + catalog: Node ) -> Outcome> { bind_outcome( o: target_value_expr_closure_params_from_wire(wire: expr.node), @@ -6350,6 +6663,12 @@ fn value_expr_projection_bundle_node(projection: TargetValueExpressionProjection ) ] ) + ), + target_model_named_edge( + name: ^target_value_expr_field_block_eval, + target: block_evaluation_mode_to_node( + mode: projection.block_evaluation_mode + ) ) ] )