From 7c895105cd86a752fcd43f1ca5ab41a7e8a16368 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:45:02 +0000 Subject: [PATCH 01/51] 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/51] 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/51] =?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/51] 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/51] =?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/51] =?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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] =?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/51] =?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/51] 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 a1b9334dc0f97c4dc7e0f7e4b61598daf609b354 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 03:55:33 +0000 Subject: [PATCH 42/51] fix(seed-green): restore main serialize/record_emit after stale merge regressions The branch had accidentally reverted #6045 record serialization and related witnesses during prior main merges. Restore the main-line authorities so the emitter/seed-green-integration branch tracks current main for Route-A closure. Co-authored-by: Cursor --- dsl/gunbc/runner_deploy_emit.dag | 110 ++++++++++------ dsl/std/languages.dag | 52 ++++++-- dsl/std/render.dag | 2 + dsl/std/serialize.dag | 55 ++++++++ dsl/test/claim/config_record_emit_test.dag | 121 ++++++++++++++++++ .../claim/runner_placement_witness_test.dag | 45 ++++++- .../languages_consumer_census.rs | 4 +- src/v2/lens/languages_consumer_census.dag | 4 +- src/v2/workflow/ci_floor_plan.dag | 2 +- 9 files changed, 333 insertions(+), 62 deletions(-) create mode 100644 dsl/std/serialize.dag create mode 100644 dsl/test/claim/config_record_emit_test.dag diff --git a/dsl/gunbc/runner_deploy_emit.dag b/dsl/gunbc/runner_deploy_emit.dag index a82825df162..3baf96dafcb 100644 --- a/dsl/gunbc/runner_deploy_emit.dag +++ b/dsl/gunbc/runner_deploy_emit.dag @@ -33,14 +33,24 @@ import extdeps.github.actions { RunnerSpec, SelfHosted, HostedRunner, RunsOnExpr import std.measure { byte_size_count, hardware_thread_count_value, percent_count } import std.types { String, List, Bool } import std.layout { - Doc, DocConcat, + Doc, DocConcat, DocLine, LayoutProtocol, - doc_concat, doc_line_of, + doc_text, doc_concat, doc_line_of, render } +import std.languages { SerializationKnobs, SerialField, SerialValue, ScalarValue, json_record_knobs } +import std.serialize { serial_scalar, serial_field, serialize_fields_doc, serialize_record_doc } data runner_deploy_protocol: LayoutProtocol = LayoutProtocol { indent_unit: "" } +data manifest_record_knobs: SerializationKnobs = { + assign: "=", + entry_separator: " ", + open: "", + close: "", + quote_keys: false, + value_quote: null +} fn runner_labels_text(spec: RunnerSpec) -> String { match spec { @@ -51,23 +61,20 @@ fn runner_labels_text(spec: RunnerSpec) -> String { } } -fn manifest_host_text(h: RunnerHostDeployment) -> String { - concat( - concat( - concat( - concat( - concat( - concat(concat("host=", h.identity), concat(" runner_count=", to_string(h.runner_count))), - concat(" runner_slice_cap_bytes=", to_string(byte_size_count(b: h.runner_slice_cap))) - ), - concat(" per_slot_memory_max_bytes=", to_string(byte_size_count(b: h.per_runner_memory_cap))) - ), - concat(" build_tokens=", to_string(hardware_thread_count_value(t: h.build_tokens))) - ), - concat(" labels=", runner_labels_text(spec: h.runner)) - ), - concat(" cpu_weight=", to_string(workload_class_cpu_weight(wc: h.workload_class))) - ) +fn manifest_host_fields(h: RunnerHostDeployment) -> List { + [ + serial_field(key: "host", value: serial_scalar(text: h.identity)), + serial_field(key: "runner_count", value: serial_scalar(text: to_string(h.runner_count))), + serial_field(key: "runner_slice_cap_bytes", value: serial_scalar(text: to_string(byte_size_count(b: h.runner_slice_cap)))), + serial_field(key: "per_slot_memory_max_bytes", value: serial_scalar(text: to_string(byte_size_count(b: h.per_runner_memory_cap)))), + serial_field(key: "build_tokens", value: serial_scalar(text: to_string(hardware_thread_count_value(t: h.build_tokens)))), + serial_field(key: "labels", value: serial_scalar(text: runner_labels_text(spec: h.runner))), + serial_field(key: "cpu_weight", value: serial_scalar(text: to_string(workload_class_cpu_weight(wc: h.workload_class)))) + ] +} + +fn manifest_host_doc(h: RunnerHostDeployment) -> Doc { + serialize_fields_doc(knobs: manifest_record_knobs, fields: manifest_host_fields(h: h)) } fn runner_plan_doc() -> Doc { @@ -76,17 +83,22 @@ fn runner_plan_doc() -> Doc { doc_line_of(text: concat("runner-deploy UNSOUND: ", reason)) PlanDerived { hosts: hosts, fleet_concurrent_runs: total } => doc_concat(parts: append( - map(hosts, h => doc_line_of(text: concat("runner-deploy ", manifest_host_text(h: h)))), + map(hosts, h => doc_concat(parts: [doc_text(text: "runner-deploy "), manifest_host_doc(h: h), DocLine])), items: [doc_line_of(text: concat("runner-deploy fleet_concurrent_runs=", to_string(total)))] )) } } -fn session_host_text(h: SessionHostReservation) -> String { - concat( - concat(concat("host=", h.identity), concat(" sessions=", to_string(h.session_count))), - concat(" per_session_cap_bytes=", to_string(byte_size_count(b: h.per_session_reservation))) - ) +fn session_host_fields(h: SessionHostReservation) -> List { + [ + serial_field(key: "host", value: serial_scalar(text: h.identity)), + serial_field(key: "sessions", value: serial_scalar(text: to_string(h.session_count))), + serial_field(key: "per_session_cap_bytes", value: serial_scalar(text: to_string(byte_size_count(b: h.per_session_reservation)))) + ] +} + +fn session_host_doc(h: SessionHostReservation) -> Doc { + serialize_fields_doc(knobs: manifest_record_knobs, fields: session_host_fields(h: h)) } fn session_plan_doc() -> Doc { @@ -101,7 +113,7 @@ fn session_plan_doc() -> Doc { sample_count: samples } => doc_concat(parts: append( - map(hosts, h => doc_line_of(text: concat("session-reservation ", session_host_text(h: h)))), + map(hosts, h => doc_concat(parts: [doc_text(text: "session-reservation "), session_host_doc(h: h), DocLine])), items: [doc_line_of(text: concat( concat("session-reservation fleet_concurrent_sessions=", to_string(total)), concat(" measured_peak_coverage=", concat(to_string(covered), concat("/", to_string(samples)))) @@ -110,23 +122,27 @@ fn session_plan_doc() -> Doc { } } -fn operating_row_text(r: OperatingPointRow) -> String { - concat( - concat( - concat(" per_session_cap_bytes=", to_string(byte_size_count(b: r.per_session_cap))), - concat(" concurrency=", to_string(r.session_concurrency)) - ), - concat( - concat(" sessions_slice_bytes=", to_string(byte_size_count(b: r.sessions_slice))), - concat(" peak_coverage=", concat(to_string(r.coverage_count), concat("/", to_string(r.sample_count)))) - ) - ) +fn operating_row_fields(r: OperatingPointRow) -> List { + [ + serial_field(key: "per_session_cap_bytes", value: serial_scalar(text: to_string(byte_size_count(b: r.per_session_cap)))), + serial_field(key: "concurrency", value: serial_scalar(text: to_string(r.session_concurrency))), + serial_field(key: "sessions_slice_bytes", value: serial_scalar(text: to_string(byte_size_count(b: r.sessions_slice)))), + serial_field(key: "peak_coverage", value: serial_scalar(text: concat(concat(to_string(r.coverage_count), "/"), to_string(r.sample_count)))) + ] +} + +fn operating_row_doc(r: OperatingPointRow) -> Doc { + doc_concat(parts: [ + doc_text(text: " "), + serialize_fields_doc(knobs: manifest_record_knobs, fields: operating_row_fields(r: r)), + DocLine + ]) } fn operating_curve_doc() -> Doc { doc_concat(parts: concat( [doc_line_of(text: "operating-curve (SESSION-side coverage only: operator selects one per-session operating point grounded in measured per-session peaks min 0.28 / median ~2.06 / max 8.27 GiB; sessions_slice = per_session_cap*concurrency. The per-host runner_count is budget-derived from runner_slice_cap and reported on the runner-deploy lines above, independent of this curve):")], - map(operating_curve(), r => doc_line_of(text: operating_row_text(r: r))) + map(operating_curve(), r => operating_row_doc(r: r)) )) } @@ -177,3 +193,21 @@ fn expected_runner_deploy_manifest() -> String { fn runner_deploy_drifted(committed: String) -> Bool { !(committed == expected_runner_deploy_manifest()) } + +fn expected_runner_deploy_manifest_json() -> String { + match runner_deployment_plan() { + PlanUnsound { reason: reason } => + render(doc: doc_line_of(text: concat("runner-deploy UNSOUND: ", reason)), proto: runner_deploy_protocol) + PlanDerived { hosts: hosts, fleet_concurrent_runs: _ } => + render( + doc: doc_concat(parts: map(hosts, h => + doc_concat(parts: [ + doc_text(text: "runner-deploy "), + serialize_record_doc(knobs: json_record_knobs, fields: manifest_host_fields(h: h)), + DocLine + ]) + )), + proto: runner_deploy_protocol + ) + } +} diff --git a/dsl/std/languages.dag b/dsl/std/languages.dag index eaa5813f8be..032b963c14e 100644 --- a/dsl/std/languages.dag +++ b/dsl/std/languages.dag @@ -17,6 +17,24 @@ type CommentSyntax { doc_prefix: String? } +type SerializationKnobs { + assign: String + entry_separator: String + open: String + close: String + quote_keys: Bool + value_quote: String? +} + +type SerialField { + key: String + value: SerialValue +} + +type SerialValue + = ScalarValue { text: String } + | RecordValue { fields: List } + type NamingConvention { type_case: NamingCase function_case: NamingCase @@ -33,13 +51,6 @@ type ImportGrouping = StdExternalLocal | NoGrouping -type FormatModel { - indent: IndentStyle - max_line_width: Int - import_grouping: ImportGrouping - trailing_newline: Bool -} - type ImportTrigger = TypeUsageTrigger { type_name: String } | TraitImplTrigger { trait_name: String } @@ -348,6 +359,7 @@ type ConfigFormat { name: String extensions: List comment: CommentSyntax + record: SerializationKnobs? } data rust_language: Language = { @@ -1122,7 +1134,8 @@ data yaml_format: ConfigFormat = { block_start: null, block_end: null, doc_prefix: null - } + }, + record: { assign: ": ", entry_separator: "\n", open: "", close: "", quote_keys: false, value_quote: null } } data toml_format: ConfigFormat = { @@ -1134,7 +1147,8 @@ data toml_format: ConfigFormat = { block_start: null, block_end: null, doc_prefix: null - } + }, + record: { assign: " = ", entry_separator: "\n", open: "", close: "", quote_keys: false, value_quote: "\"" } } data makefile_format: ConfigFormat = { @@ -1146,7 +1160,8 @@ data makefile_format: ConfigFormat = { block_start: null, block_end: null, doc_prefix: null - } + }, + record: { assign: " = ", entry_separator: "\n", open: "", close: "", quote_keys: false, value_quote: null } } data gitignore_format: ConfigFormat = { @@ -1158,7 +1173,8 @@ data gitignore_format: ConfigFormat = { block_start: null, block_end: null, doc_prefix: null - } + }, + record: null } data css_format: ConfigFormat = { @@ -1170,5 +1186,17 @@ data css_format: ConfigFormat = { block_start: "/*", block_end: "*/", doc_prefix: null - } + }, + record: null } + +data json_record_knobs: SerializationKnobs = { + assign: ": ", + entry_separator: ", ", + open: "{", + close: "}", + quote_keys: true, + value_quote: "\"" +} + +data value_quote_escape_dissolution_trigger: String = "dissolve-on (two gaps): (1) SerializationKnobs.value_quote is a wrap-char (concat(q,t,q)), NOT RFC-8259 JSON or TOML string escaping — a value containing a double-quote or newline produces silently invalid output; dissolution = real string-escape authority citing RFC 8259 §7 (JSON) and TOML v1.0 §String (TOML) in std.serialize. (2) ScalarValue { text: String } lacks typed scalars — Int/Bool values serialize as quoted strings (e.g. runner_count '4' not 4), making json_record_knobs non-conforming JSON the moment a real typed consumer arrives; dissolution = split SerialValue into TypedScalar { kind: ScalarKind, text: String } where ScalarKind = StringKind | NumberKind | BoolKind drives value_quote elision; no live bug today (manifest values are all stringified by to_string() at the call site)" diff --git a/dsl/std/render.dag b/dsl/std/render.dag index 69730530b02..c5e6239e360 100644 --- a/dsl/std/render.dag +++ b/dsl/std/render.dag @@ -171,3 +171,5 @@ type GeneratorHeader { generator: String regen_command: String } + +data output_format_dissolution_trigger: String = "dissolve-on: gitignore consumer in extdeps.git.gitignore migrates to std.serialize.SerializationKnobs + std.layout.LayoutProtocol + std.languages.ConfigFormat; OutputFormat.name -> ConfigFormat.name, OutputFormat.comment_prefix -> CommentSyntax.line_prefix, OutputFormat.indent_unit -> LayoutProtocol.indent_unit; residue = SerializationKnobs (kv_separator, list_prefix)" diff --git a/dsl/std/serialize.dag b/dsl/std/serialize.dag new file mode 100644 index 00000000000..daec4fc942d --- /dev/null +++ b/dsl/std/serialize.dag @@ -0,0 +1,55 @@ +module std.serialize + +import std.types { String, Bool, List } +import std.layout { Doc, DocConcat, doc_text, doc_concat } +import std.languages { SerializationKnobs, SerialField, SerialValue, ScalarValue, RecordValue } + +fn serial_scalar(text: String) -> SerialValue { + ScalarValue { text: text } +} + +fn serial_field(key: String, value: SerialValue) -> SerialField { + SerialField { key: key, value: value } +} + +fn serialize_value_doc(knobs: SerializationKnobs, v: SerialValue) -> Doc { + match v { + ScalarValue { text: t } => + match knobs.value_quote { + null => doc_text(text: t) + q => doc_text(text: concat(concat(q, t), q)) + } + RecordValue { fields: fields } => + serialize_record_doc(knobs: knobs, fields: fields) + } +} + +fn serialize_field_doc(knobs: SerializationKnobs, f: SerialField) -> Doc { + let key_text = if knobs.quote_keys { + concat(concat("\"", f.key), "\"") + } else { + f.key + } + doc_concat(parts: [ + doc_text(text: concat(key_text, knobs.assign)), + serialize_value_doc(knobs: knobs, v: f.value) + ]) +} + +fn serialize_fields_doc(knobs: SerializationKnobs, fields: List) -> Doc { + doc_concat(parts: fold(fields, init: [], f: (acc, fld) => + if count(acc) == 0 { + [serialize_field_doc(knobs: knobs, f: fld)] + } else { + concat(acc, [doc_text(text: knobs.entry_separator), serialize_field_doc(knobs: knobs, f: fld)]) + } + )) +} + +fn serialize_record_doc(knobs: SerializationKnobs, fields: List) -> Doc { + doc_concat(parts: [ + doc_text(text: knobs.open), + serialize_fields_doc(knobs: knobs, fields: fields), + doc_text(text: knobs.close) + ]) +} diff --git a/dsl/test/claim/config_record_emit_test.dag b/dsl/test/claim/config_record_emit_test.dag new file mode 100644 index 00000000000..0c4110f49f4 --- /dev/null +++ b/dsl/test/claim/config_record_emit_test.dag @@ -0,0 +1,121 @@ +module test.claim.config_record_emit_witness + +import std.languages { + yaml_format, toml_format, makefile_format, gitignore_format, + json_record_knobs, SerializationKnobs, SerialField, SerialValue +} +import std.serialize { + serial_scalar, serial_field, + serialize_field_doc, serialize_fields_doc, serialize_record_doc +} +import std.layout { render, LayoutProtocol } +import gunbc.runner_deploy_emit { manifest_record_knobs } + +data flat_proto: LayoutProtocol = LayoutProtocol { indent_unit: "" } + +fn render_field(knobs: SerializationKnobs, key: String, value: String) -> String { + render( + doc: serialize_field_doc(knobs: knobs, f: serial_field(key: key, value: serial_scalar(text: value))), + proto: flat_proto + ) +} + +fn render_fields(knobs: SerializationKnobs, fields: List) -> String { + render(doc: serialize_fields_doc(knobs: knobs, fields: fields), proto: flat_proto) +} + +fn render_record(knobs: SerializationKnobs, fields: List) -> String { + render(doc: serialize_record_doc(knobs: knobs, fields: fields), proto: flat_proto) +} + +fn witness_yaml_field_uses_colon_separator() -> Bool { + match yaml_format.record { + null => false + knobs => render_field(knobs: knobs, key: "name", value: "gunbc") == "name: gunbc" + } +} + +fn witness_toml_field_uses_equals_and_double_quotes() -> Bool { + match toml_format.record { + null => false + knobs => render_field(knobs: knobs, key: "name", value: "gunbc") == "name = \"gunbc\"" + } +} + +fn witness_makefile_field_uses_equals_no_quotes() -> Bool { + match makefile_format.record { + null => false + knobs => render_field(knobs: knobs, key: "CC", value: "gcc") == "CC = gcc" + } +} + +fn witness_gitignore_has_no_record_knobs() -> Bool { + match gitignore_format.record { + null => true + _ => false + } +} + +fn witness_yaml_toml_fields_differ() -> Bool { + match yaml_format.record { + null => false + yaml_knobs => match toml_format.record { + null => false + toml_knobs => + render_field(knobs: yaml_knobs, key: "k", value: "v") != + render_field(knobs: toml_knobs, key: "k", value: "v") + } + } +} + +fn witness_yaml_two_fields_newline_joined() -> Bool { + match yaml_format.record { + null => false + knobs => + render_fields(knobs: knobs, fields: [ + serial_field(key: "host", value: serial_scalar(text: "localhost")), + serial_field(key: "port", value: serial_scalar(text: "8080")) + ]) == "host: localhost\nport: 8080" + } +} + +fn witness_manifest_knobs_space_separated() -> Bool { + render_fields( + knobs: manifest_record_knobs, + fields: [ + serial_field(key: "host", value: serial_scalar(text: "srv1")), + serial_field(key: "runner_count", value: serial_scalar(text: "4")) + ] + ) == "host=srv1 runner_count=4" +} + +fn witness_json_knobs_produce_quoted_record() -> Bool { + render_record( + knobs: json_record_knobs, + fields: [ + serial_field(key: "host", value: serial_scalar(text: "srv1")), + serial_field(key: "runner_count", value: serial_scalar(text: "4")) + ] + ) == "{\"host\": \"srv1\", \"runner_count\": \"4\"}" +} + +fn witness_same_fields_differ_across_knobs() -> Bool { + let fields = [ + serial_field(key: "host", value: serial_scalar(text: "srv1")), + serial_field(key: "runner_count", value: serial_scalar(text: "4")) + ] + render_record(knobs: manifest_record_knobs, fields: fields) != + render_record(knobs: json_record_knobs, fields: fields) +} + +test fn config_record_emit_keystone_holds() -> Bool { + witness_yaml_field_uses_colon_separator() && + witness_toml_field_uses_equals_and_double_quotes() && + witness_makefile_field_uses_equals_no_quotes() && + witness_gitignore_has_no_record_knobs() && + witness_yaml_toml_fields_differ() && + witness_yaml_two_fields_newline_joined() && + witness_manifest_knobs_space_separated() && + witness_json_knobs_produce_quoted_record() && + witness_same_fields_differ_across_knobs() +} diff --git a/dsl/test/claim/runner_placement_witness_test.dag b/dsl/test/claim/runner_placement_witness_test.dag index 3d77624395d..0308b14bdd2 100644 --- a/dsl/test/claim/runner_placement_witness_test.dag +++ b/dsl/test/claim/runner_placement_witness_test.dag @@ -48,10 +48,16 @@ import gunbc.ci_floor_measurement { import gunbc.ci_fleet { fleet_intent_offers } import gunbc.runner_deploy_emit { expected_runner_deploy_manifest, + expected_runner_deploy_manifest_json, runner_deploy_drifted, - manifest_host_text, - session_host_text, + manifest_host_doc, + manifest_host_fields, + session_host_doc, + runner_deploy_protocol, } +import std.languages { json_record_knobs } +import std.serialize { serialize_record_doc } +import std.layout { render } import std.measure { byte_size, byte_size_count, hardware_thread_count_value } import std.types { Bool, Int, List, String } @@ -107,9 +113,10 @@ fn witness_sound_manifest_line_is_populated() -> Bool { match live_plan() { PlanDerived { hosts: hosts, fleet_concurrent_runs: _ } => hosts.length() > 0 - && all(hosts, h => - starts_with(manifest_host_text(h: h), prefix: concat(concat("host=", h.identity), " runner_count=")) - ) + && all(hosts, h => { + let rendered = render(doc: manifest_host_doc(h: h), proto: runner_deploy_protocol) + starts_with(s: rendered, prefix: concat(concat("host=", h.identity), " runner_count=")) + }) PlanUnsound { reason: _ } => false } } @@ -193,7 +200,7 @@ fn witness_runner_manifest_line_contains_cpu_weight() -> Bool { match live_plan() { PlanDerived { hosts: hosts, fleet_concurrent_runs: _ } => hosts.length() > 0 - && all(hosts, h => string_contains(s: manifest_host_text(h: h), pattern: " cpu_weight=100")) + && all(hosts, h => string_contains(s: render(doc: manifest_host_doc(h: h), proto: runner_deploy_protocol), pattern: " cpu_weight=100")) PlanUnsound { reason: _ } => false } } @@ -219,7 +226,29 @@ fn witness_session_reservation_line_has_no_cpu_weight() -> Bool { per_session_reservation: byte_size(4294967296), workload_class: InteractiveLatencySensitive, } - !(string_contains(s: session_host_text(h: fixture), pattern: "cpu_weight")) + !(string_contains(s: render(doc: session_host_doc(h: fixture), proto: runner_deploy_protocol), pattern: "cpu_weight")) +} + +fn witness_real_manifest_fields_drive_both_formats() -> Bool { + match runner_deployment_plan() { + PlanUnsound { reason: _ } => false + PlanDerived { hosts: hosts, fleet_concurrent_runs: _ } => + hosts.length() > 0 && + all(hosts, h => { + let text_out = render(doc: manifest_host_doc(h: h), proto: runner_deploy_protocol) + let json_out = render(doc: serialize_record_doc(knobs: json_record_knobs, fields: manifest_host_fields(h: h)), proto: runner_deploy_protocol) + text_out != json_out && + string_contains(s: text_out, pattern: concat("host=", h.identity)) && + string_contains(s: json_out, pattern: concat("\"host\": \"", h.identity)) + }) + } +} + +fn witness_manifest_json_entry_point_produces_json_format() -> Bool { + let full = expected_runner_deploy_manifest_json() + string_contains(s: full, pattern: "runner-deploy {") && + string_contains(s: full, pattern: "\"host\": \"") && + string_contains(s: full, pattern: "\"cpu_weight\": \"") } test fn runner_placement_holds() -> Bool { @@ -243,4 +272,6 @@ test fn runner_placement_holds() -> Bool { && witness_runner_and_session_cpu_weights_are_distinct() && witness_session_slice_line_emits_cpu_weight() && witness_session_reservation_line_has_no_cpu_weight() + && witness_real_manifest_fields_drive_both_formats() + && witness_manifest_json_entry_point_produces_json_format() } diff --git a/src/v1/stage0/src/module_path_index/languages_consumer_census.rs b/src/v1/stage0/src/module_path_index/languages_consumer_census.rs index 297c7f38aa5..a63e8f2c6ef 100644 --- a/src/v1/stage0/src/module_path_index/languages_consumer_census.rs +++ b/src/v1/stage0/src/module_path_index/languages_consumer_census.rs @@ -243,12 +243,12 @@ mod tests { #[test] fn data_decl_baseline_is_seventy_one() { - assert_eq!(languages_consumer_census_data_decl_count(), 71); + assert_eq!(languages_consumer_census_data_decl_count(), 73); } #[test] fn per_language_row_baseline_is_sixty_four() { - assert_eq!(languages_consumer_census_per_language_row_count(), 64); + assert_eq!(languages_consumer_census_per_language_row_count(), 66); } #[test] diff --git a/src/v2/lens/languages_consumer_census.dag b/src/v2/lens/languages_consumer_census.dag index 7c60e8ac6c8..42fa74f55c2 100644 --- a/src/v2/lens/languages_consumer_census.dag +++ b/src/v2/lens/languages_consumer_census.dag @@ -6,8 +6,8 @@ import v2.std.collection { List } import v2.std.logic { Bool } import v2.std.text { String } -data languages_consumer_census_data_decl_baseline: Int = 71 -data languages_consumer_census_per_language_row_baseline: Int = 64 +data languages_consumer_census_data_decl_baseline: Int = 73 +data languages_consumer_census_per_language_row_baseline: Int = 66 data languages_consumer_census_format_row_baseline: Int = 7 fn languages_consumer_census_ratchet_holds(live_count: Int, baseline: Int) -> Bool { diff --git a/src/v2/workflow/ci_floor_plan.dag b/src/v2/workflow/ci_floor_plan.dag index 1a60d2a3463..25edbd5cab5 100644 --- a/src/v2/workflow/ci_floor_plan.dag +++ b/src/v2/workflow/ci_floor_plan.dag @@ -530,7 +530,7 @@ fn witness_floor_spawn_width_tight_budget_backs_off() -> Bool { fn witness_floor_spawn_width_zero_budget_falls_back() -> Bool { let width = hardware_thread_count_value(t: gunbc_ci_plan_spawn_width(memory_budget_bytes: 0)) - width == gunbc_ci_floor_conservative_fallback_width + width == int_min(a: gunbc_ci_floor_conservative_fallback_width, b: execution_corpus_spawn_width()) } fn floor_batch_heavy_gate_resolve_count(batch: List) -> Int { From 8f6c9b0e53a5e93ae4aff386e68dde32c4669839 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 04:04:07 +0000 Subject: [PATCH 43/51] test(route-a): add emit-fresh cargo-green execution witness Reconcile emitter/seed-green-integration with main and land an ignored-by-default test that assembles the faithful --emit-fresh crate and proves debug+release cargo build succeed (0 rustc errors). Closes the Route-A last-mile receipt loop alongside the existing regen --verify CI gate. Co-authored-by: Cursor --- src/v1/tests/src/lib.rs | 2 + .../route_a_emit_fresh_cargo_green_test.rs | 84 +++++++++++++++++++ src/v1/tests/src/route_a_final_six_test.rs | 4 +- 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/v1/tests/src/route_a_emit_fresh_cargo_green_test.rs diff --git a/src/v1/tests/src/lib.rs b/src/v1/tests/src/lib.rs index c26b0fd9e07..abcf936aeb6 100644 --- a/src/v1/tests/src/lib.rs +++ b/src/v1/tests/src/lib.rs @@ -147,6 +147,8 @@ mod resolve_typed_cache_equivalence_test; #[cfg(test)] mod resolved_graph_cache_size_bound_test; #[cfg(test)] +mod route_a_emit_fresh_cargo_green_test; +#[cfg(test)] mod route_a_final_six_test; #[cfg(test)] mod source_audit; diff --git a/src/v1/tests/src/route_a_emit_fresh_cargo_green_test.rs b/src/v1/tests/src/route_a_emit_fresh_cargo_green_test.rs new file mode 100644 index 00000000000..fa16d43ac5c --- /dev/null +++ b/src/v1/tests/src/route_a_emit_fresh_cargo_green_test.rs @@ -0,0 +1,84 @@ +//! Route-A cargo-green witness: the faithful `--emit-fresh` assembled crate must +//! `cargo build` with 0 errors (debug + release). Receipt for roadmap `5-cargo-green` +//! (#5777/#5873); `regen_stage0 --verify` alone only proves byte-identical seed, not rustc-green. + +fn regen_stage0_bin() -> std::path::PathBuf { + let ws = crate::helpers::workspace_root(); + let target_dir = std::env::var_os("CARGO_TARGET_DIR") + .map(std::path::PathBuf::from) + .unwrap_or_else(|| ws.join("target")); + let bin = target_dir.join("release/regen_stage0"); + if !bin.exists() { + let build = std::process::Command::new("cargo") + .current_dir(&ws) + .args([ + "build", + "-p", + "v1-compiler", + "--release", + "--bin", + "regen_stage0", + ]) + .output() + .expect("failed to build regen_stage0"); + assert!( + build.status.success(), + "regen_stage0 build failed:\n{}", + String::from_utf8_lossy(&build.stderr) + ); + } + bin +} + +fn emit_fresh_dir() -> std::path::PathBuf { + let unique = format!( + "route-a-emit-fresh-{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .expect("clock before unix epoch") + .as_nanos() + ); + std::env::temp_dir().join(unique) +} + +fn assemble_emit_fresh_crate(regen: &std::path::Path, fresh_dir: &std::path::Path) { + let ws = crate::helpers::workspace_root(); + let output = std::process::Command::new(regen) + .current_dir(&ws) + .args(["--emit-fresh"]) + .arg(fresh_dir) + .output() + .expect("failed to run regen_stage0 --emit-fresh"); + assert!( + output.status.success(), + "regen_stage0 --emit-fresh failed:\n{}", + String::from_utf8_lossy(&output.stderr) + ); +} + +fn cargo_build_in(dir: &std::path::Path, release: bool) { + let mut cmd = std::process::Command::new("cargo"); + cmd.current_dir(dir).arg("build"); + if release { + cmd.arg("--release"); + } + let output = cmd.output().expect("failed to run cargo build"); + assert!( + output.status.success(), + "cargo build{} in {} failed:\n{}", + if release { " --release" } else { "" }, + dir.display(), + String::from_utf8_lossy(&output.stderr) + ); +} + +#[test] +#[ignore = "Expensive: regen_stage0 --emit-fresh + cargo build debug+release (~3-5min)"] +fn emit_fresh_crate_cargo_builds_green() { + let regen = regen_stage0_bin(); + let fresh = emit_fresh_dir(); + assemble_emit_fresh_crate(®en, &fresh); + cargo_build_in(&fresh, false); + cargo_build_in(&fresh, true); + let _ = std::fs::remove_dir_all(&fresh); +} diff --git a/src/v1/tests/src/route_a_final_six_test.rs b/src/v1/tests/src/route_a_final_six_test.rs index d80b7883fce..a14780622a2 100644 --- a/src/v1/tests/src/route_a_final_six_test.rs +++ b/src/v1/tests/src/route_a_final_six_test.rs @@ -2,8 +2,8 @@ //! that cleared the residual E0308 tail (647 -> 0 E0308) in the faithful `--emit-fresh` //! seed. Each fix is faithful CONSTRUCTION derived from the declared type, with a //! negative control proving it is type-derived (not a blanket transform). NOTE: 0 E0308 -//! is a MILESTONE, not cargo-green — 32 other-family errors (measure-tower, etc.) remain -//! pre-existing and are tracked separately. +//! was a milestone on the path to cargo-green; the full faithful `--emit-fresh` crate +//! now builds green (see `route_a_emit_fresh_cargo_green_test`). use crate::helpers::compile_dag_target; use v1_compiler::v1_compiler_artifact::RenderTarget; From b1cbe3841d06bd7a7ab74f4036c10fd9140df822 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 04:40:54 +0000 Subject: [PATCH 44/51] fix(ci): align zero-budget spawn width with execution-corpus cap witness gunbc_ci_floor_spawn_width_for_budget(0) returned the blind conservative fallback (4) while witness_floor_spawn_width_zero_budget_falls_back expected min(4, execution_corpus_spawn_width()) = 3. Apply the same int_min at the authority site and update the envelope witness to match. Co-authored-by: Cursor --- src/v2/workflow/ci_floor_plan.dag | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/v2/workflow/ci_floor_plan.dag b/src/v2/workflow/ci_floor_plan.dag index 25edbd5cab5..d5234b208ef 100644 --- a/src/v2/workflow/ci_floor_plan.dag +++ b/src/v2/workflow/ci_floor_plan.dag @@ -14,7 +14,7 @@ import v2.std.node { Atom, Node, TypeNode } import v2.std.text { String } import std.types { ContentHash, Int } import std.measure { HardwareThreadCount, hardware_thread_count, hardware_thread_count_value, byte_size, ByteSize, byte_size_count } -import std.realization_width { width_fold_objective_goals, bounded_host_spawn_width } +import std.realization_width { width_fold_objective_goals, bounded_host_spawn_width, int_min } import gunbc.fleet_container { ResourceEnvelope, parallel_run_demand_envelope, @@ -461,7 +461,10 @@ fn gunbc_ci_floor_hardware_threads() -> HardwareThreadCount { fn gunbc_ci_floor_spawn_width_for_budget(memory_budget: ByteSize) -> HardwareThreadCount { let budget_count = byte_size_count(b: memory_budget) if budget_count <= 0 { - hardware_thread_count(count: gunbc_ci_floor_conservative_fallback_width) + hardware_thread_count(count: int_min( + a: gunbc_ci_floor_conservative_fallback_width, + b: execution_corpus_spawn_width() + )) } else { let cpu_bound = hardware_thread_count_value(t: bounded_host_spawn_width( shard_count: gunbc_ci_floor_breadth(), @@ -508,7 +511,10 @@ fn witness_floor_fail_open_would_exceed_budget() -> Bool { fn witness_floor_unreadable_budget_uses_conservative_envelope() -> Bool { let envelope = gunbc_ci_floor_run_envelope(memory_budget_bytes: 0) - demand_envelope_thread_count(envelope: envelope) == gunbc_ci_floor_conservative_fallback_width + demand_envelope_thread_count(envelope: envelope) == int_min( + a: gunbc_ci_floor_conservative_fallback_width, + b: execution_corpus_spawn_width() + ) } fn witness_floor_width_governed_by_budget_tree() -> Bool { From abaca597e78b74401543b8b40808397e21e4ecd2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 17:18:39 +0000 Subject: [PATCH 45/51] docs(self-host): mark Route-A cargo-green landed (#5777/#5873) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-verified cool-ant-875: regen_stage0 --emit-fresh → cargo build debug+release is 0 errors. Sync v2_self_hosting plan bullets that still claimed the last mile was open; note emitter/seed-green-integration absorbed. Co-authored-by: Cursor --- dsl/gunbc/plans/v2_self_hosting.dag | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dsl/gunbc/plans/v2_self_hosting.dag b/dsl/gunbc/plans/v2_self_hosting.dag index 2ed960615e5..c1781bece7c 100644 --- a/dsl/gunbc/plans/v2_self_hosting.dag +++ b/dsl/gunbc/plans/v2_self_hosting.dag @@ -19,13 +19,13 @@ fn v2_self_hosting_body() -> List { li(text: "**IMPROVED — the gap now has an owner and a construction-first fix.** The reconciliation endgame is **bright-stag-owned**: a model-first *single-authority* kill — **derive** the hand-maintained copy-lists FROM the emitted-module authority so the emitted↔hand drift becomes **unwritable** (the `invert-hand-maintained` move), with crisp-carp's `regen-verify` floor gate as the weaker post-hoc backstop layered on top. roadmap **`5-regen-verify` pulled forward**. cool-carp owns the *immediate* reconcile (fix the copy-lists + re-seed the 4 + verify clean) ahead of the construction fix."), li(text: "**IMPROVED — sequencing crystallized (emitter-first).** Order is now fixed: emitter-correctness settles (jolly-cat's Route-A lane; the corpus-emit surface measured at **~12,600 `E0308`**) → **single regen cutover** (bright-stag reconciliation) → `regen-verify` green → §7 fixpoint provable. Cutting over mid-emitter-churn re-drifts immediately, so the cutover is the *closing* step, not concurrent. This refines *Forced precondition order* step 3 below (it now has an owner + an ordering)."), li(text: "**DECIDED — open question #1 (reopen direction).** Resolved to **(a)**: finish the Route-A green bootstrap (continue `emitter/seed-green-integration`, do **not** restart into a pure-`.dag` coherence reset). Anchored; do not re-litigate."), - li(text: "**UNTOUCHED (still the wall, unchanged since 2026-06-21):** the Route-A last mile — the emitted crate still does **not** `cargo build` green (the `dsl_compile_clean` gate still only proves *well-typed*, not *built*). Track B / Stage C is still fail-closed (no real-digest match; comparison substrate still operator-pending, merry-crab-687). Track T (TypeScript) is still proven only on the `add` slice. The 590s+ whole-tree resolve is still the practical wall. None of these moved."), + li(text: "**LANDED — Route-A last mile (2026-06-25..28, #5777/#5873; re-verified cool-ant-875 2026-07-01).** `regen_stage0 --emit-fresh` → faithful assembled crate → `cargo build` debug+release is **0 errors** (`route_a_emit_fresh_cargo_green_test` witness). `dsl_compile_clean` still only proves well-typed emit (not built); the execution witness is the receipt. **Still open:** Track B / Stage C (no real-digest match; comparison substrate operator-pending, merry-crab-687). Track T (TypeScript) proven only on the `add` slice. The 590s+ whole-tree resolve is still the practical wall."), li(text: "**Tracked elsewhere (not a self-host milestone):** the CI-fleet resource problem (session over-allocation, CI-floor under-sharding, resolve-cache) → `compute-envelope-model.md`; the std fork census → `dsl-v2-defork-audit.md`. The session-spawn cap *was* fixed operationally 2026-06-23 (per-session RAM reservation 31g→4g, ~30 sessions/host) — an infra fix, orthogonal to this track."), ]), h2(text: "0. State of play (what's done, what's open)"), ul(items: [ li(text: "**Front-end — DONE, proven at scale.** `src/v2/` is 100% `.dag` (698 modules, 0 `.rs`; all Rust is the `src/v1` seed, ~154k lines). Full pipeline present: `01_tokenize → 02_parse → 03_resolve/name_resolve/ingest → 04_infer → 05_emit/eval → 06_translate → 07_target_carriers`. The historical blockers are fixed and merged: parse-perf (#5093 ParseTable memo, #3661), resolve/infer cost (#5258 the O(2^depth) double-resolve fix, #5266, #5146), cross-file names (#5271 Route C Phase B, #5154 filepath→QualifiedName). gap-4 (let-stmt in match arm) merged #5369; whole-tree parse-regression scanner added #5406. *Nuance:* per-file parse is fast, but a **combined `dsl`+`src/v2` whole-tree resolve is still heavy (590s+)** — \"no perf wall\" means the fixed blockers, not an instant full-tree resolve."), - li(text: "**Emit / Route A — runs whole-tree, but the emitted crate doesn't build yet.** `gunbc compile --source-root … --target rust` exists and the CI `dsl_compile_clean` gate runs it over `[src/v2, dsl]`, gating all of batch-2. **But the gate only proves the tree is well-typed** (emit runs to completion, writes `$OUT`, then `rm -rf $OUT`). It does **not** `cargo build` the emitted whole-tree crate. Only the emit-host MVP smokes compile tiny fixtures. **The green build of the emitted crate is the open Route-A last mile.**"), + li(text: "**Emit / Route A — whole-tree emit + faithful `--emit-fresh` crate builds green (#5777/#5873).** `gunbc compile --source-root … --target rust` exists and the CI `dsl_compile_clean` gate runs it over `[src/v2, dsl]`, gating batch-2 (well-typed emit only — writes `$OUT`, then `rm -rf $OUT`). The **cargo-green** receipt is `regen_stage0 --emit-fresh ` → `cargo build` (debug+release), proven by `route_a_emit_fresh_cargo_green_test`."), li(text: "**Fixed-point proof — fail-closed (not achieved).** `self_host.dag`'s `self_host_fixed_point_validate` **unconditionally returns `Rejected`** (`self_host_runner_not_realized`) — the honest contract until Stage C. `self_host_fixed_point_digests_match` (`==` over `content_hash`) is realized but de-risked only on fixture stages. The whole-compiler fixed point over real digests does not yet run."), li(text: "**Emitter — genuinely multi-target.** One `fold_node` catamorphism in `06_translate.dag`; emit selects a target's `target_model_edge_translation_rules` and walks the same rows **backward** (`grammar_relation_row_reverse_parse_selection`). 14 targets in `src/v2/extdeps/languages/` (rust, python, go, bash, dag, cpp, typescript, kotlin, swift, java, lean, ptx, verilog, …), 5 in `dsl`. A new target is **data rows, never a new emitter**."), ]), @@ -34,11 +34,11 @@ fn v2_self_hosting_body() -> List { p(text: "Get the v2-emitted Rust compiler to build and reproduce itself."), ol(items: [ li(text: "Emit whole tree `--target rust` — **done** (well-typed under CI gate)."), - li(text: "`cargo build` the emitted crate green — **open** (the last mile)."), + li(text: "`cargo build` the emitted crate green — **done** (#5777/#5873; `regen_stage0 --emit-fresh` witness)."), li(text: "`regen_stage0` from the emitted crate; replace the hand-Rust seed."), li(text: "Flip the lockstep / fixed-point gate from fail-closed to asserting the real `content_hash` digest match (Stage C)."), ]), - p(text: "Unmerged work: branch `emitter/seed-green-integration @ 239ff284d5` (**not in main**) carries 6 commits toward a green regen — import-completeness (E0425), List→host-`Vec`, Int-as-generic-arg→`i64`, `regen_stage0` patch, + 2 integration commits. PR **#5325 is CLOSED, not merged.** Recent emitter slices on main: #5413 (length→count, phantom-marker derives, Measure-alias E0560 peel, E0308 Box-deref cluster); MachineWidth is **#5397** (E0107), a separate PR."), + p(text: "**Route-A cargo-green landed on main** (#5777 emitter fixes → 0 rustc errors; #5873 two-generation regen cutover + `regen --verify` CI gate). Branch `emitter/seed-green-integration` content is absorbed — the branch is stale vs `main` and can be retired. PR **#5325** remains closed (superseded by #5873)."), h3(text: "Purity: no stage0 hand-edits (the requirement, and the enforcement gap)"), quote(blocks: [ p(text: "**UPDATE 2026-06-23 (#5639): this gap has now FIRED** — the seed has measurably drifted from the `.dag` (~764 regen errors, stale copy-lists). The \"erosion\" warned about below is no longer hypothetical. Owner + fix in the *Δ since 2026-06-21* block above."), From 2088a278cef260351b6344edd03dc0350fee57a3 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 17:21:16 +0000 Subject: [PATCH 46/51] fix(docs): regen v2-self-hosting.md from plan authority v2_self_hosting.dag is enrolled in PlanArtifact (generated_artifact registry); committed docs/plans/v2-self-hosting.md must match artifact_generate. Regen via main_wet after cargo-green bullet sync. Co-authored-by: Cursor --- docs/plans/v2-self-hosting.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/plans/v2-self-hosting.md b/docs/plans/v2-self-hosting.md index d4bf9049af7..727670a0a76 100644 --- a/docs/plans/v2-self-hosting.md +++ b/docs/plans/v2-self-hosting.md @@ -16,13 +16,13 @@ The state-of-play below was verified 2026-06-21. What moved in the two days sinc - **IMPROVED — the gap now has an owner and a construction-first fix.** The reconciliation endgame is **bright-stag-owned**: a model-first *single-authority* kill — **derive** the hand-maintained copy-lists FROM the emitted-module authority so the emitted↔hand drift becomes **unwritable** (the `invert-hand-maintained` move), with crisp-carp's `regen-verify` floor gate as the weaker post-hoc backstop layered on top. roadmap **`5-regen-verify` pulled forward**. cool-carp owns the *immediate* reconcile (fix the copy-lists + re-seed the 4 + verify clean) ahead of the construction fix. - **IMPROVED — sequencing crystallized (emitter-first).** Order is now fixed: emitter-correctness settles (jolly-cat's Route-A lane; the corpus-emit surface measured at **~12,600 `E0308`**) → **single regen cutover** (bright-stag reconciliation) → `regen-verify` green → §7 fixpoint provable. Cutting over mid-emitter-churn re-drifts immediately, so the cutover is the *closing* step, not concurrent. This refines *Forced precondition order* step 3 below (it now has an owner + an ordering). - **DECIDED — open question #1 (reopen direction).** Resolved to **(a)**: finish the Route-A green bootstrap (continue `emitter/seed-green-integration`, do **not** restart into a pure-`.dag` coherence reset). Anchored; do not re-litigate. -- **UNTOUCHED (still the wall, unchanged since 2026-06-21):** the Route-A last mile — the emitted crate still does **not** `cargo build` green (the `dsl_compile_clean` gate still only proves *well-typed*, not *built*). Track B / Stage C is still fail-closed (no real-digest match; comparison substrate still operator-pending, merry-crab-687). Track T (TypeScript) is still proven only on the `add` slice. The 590s+ whole-tree resolve is still the practical wall. None of these moved. +- **LANDED — Route-A last mile (2026-06-25..28, #5777/#5873; re-verified cool-ant-875 2026-07-01).** `regen_stage0 --emit-fresh` → faithful assembled crate → `cargo build` debug+release is **0 errors** (`route_a_emit_fresh_cargo_green_test` witness). `dsl_compile_clean` still only proves well-typed emit (not built); the execution witness is the receipt. **Still open:** Track B / Stage C (no real-digest match; comparison substrate operator-pending, merry-crab-687). Track T (TypeScript) proven only on the `add` slice. The 590s+ whole-tree resolve is still the practical wall. - **Tracked elsewhere (not a self-host milestone):** the CI-fleet resource problem (session over-allocation, CI-floor under-sharding, resolve-cache) → `compute-envelope-model.md`; the std fork census → `dsl-v2-defork-audit.md`. The session-spawn cap *was* fixed operationally 2026-06-23 (per-session RAM reservation 31g→4g, ~30 sessions/host) — an infra fix, orthogonal to this track. ## 0. State of play (what's done, what's open) - **Front-end — DONE, proven at scale.** `src/v2/` is 100% `.dag` (698 modules, 0 `.rs`; all Rust is the `src/v1` seed, ~154k lines). Full pipeline present: `01_tokenize → 02_parse → 03_resolve/name_resolve/ingest → 04_infer → 05_emit/eval → 06_translate → 07_target_carriers`. The historical blockers are fixed and merged: parse-perf (#5093 ParseTable memo, #3661), resolve/infer cost (#5258 the O(2^depth) double-resolve fix, #5266, #5146), cross-file names (#5271 Route C Phase B, #5154 filepath→QualifiedName). gap-4 (let-stmt in match arm) merged #5369; whole-tree parse-regression scanner added #5406. *Nuance:* per-file parse is fast, but a **combined `dsl`+`src/v2` whole-tree resolve is still heavy (590s+)** — "no perf wall" means the fixed blockers, not an instant full-tree resolve. -- **Emit / Route A — runs whole-tree, but the emitted crate doesn't build yet.** `gunbc compile --source-root … --target rust` exists and the CI `dsl_compile_clean` gate runs it over `[src/v2, dsl]`, gating all of batch-2. **But the gate only proves the tree is well-typed** (emit runs to completion, writes `$OUT`, then `rm -rf $OUT`). It does **not** `cargo build` the emitted whole-tree crate. Only the emit-host MVP smokes compile tiny fixtures. **The green build of the emitted crate is the open Route-A last mile.** +- **Emit / Route A — whole-tree emit + faithful `--emit-fresh` crate builds green (#5777/#5873).** `gunbc compile --source-root … --target rust` exists and the CI `dsl_compile_clean` gate runs it over `[src/v2, dsl]`, gating batch-2 (well-typed emit only — writes `$OUT`, then `rm -rf $OUT`). The **cargo-green** receipt is `regen_stage0 --emit-fresh ` → `cargo build` (debug+release), proven by `route_a_emit_fresh_cargo_green_test`. - **Fixed-point proof — fail-closed (not achieved).** `self_host.dag`'s `self_host_fixed_point_validate` **unconditionally returns `Rejected`** (`self_host_runner_not_realized`) — the honest contract until Stage C. `self_host_fixed_point_digests_match` (`==` over `content_hash`) is realized but de-risked only on fixture stages. The whole-compiler fixed point over real digests does not yet run. - **Emitter — genuinely multi-target.** One `fold_node` catamorphism in `06_translate.dag`; emit selects a target's `target_model_edge_translation_rules` and walks the same rows **backward** (`grammar_relation_row_reverse_parse_selection`). 14 targets in `src/v2/extdeps/languages/` (rust, python, go, bash, dag, cpp, typescript, kotlin, swift, java, lean, ptx, verilog, …), 5 in `dsl`. A new target is **data rows, never a new emitter**. @@ -33,11 +33,11 @@ The state-of-play below was verified 2026-06-21. What moved in the two days sinc Get the v2-emitted Rust compiler to build and reproduce itself. 1. Emit whole tree `--target rust` — **done** (well-typed under CI gate). -2. `cargo build` the emitted crate green — **open** (the last mile). +2. `cargo build` the emitted crate green — **done** (#5777/#5873; `regen_stage0 --emit-fresh` witness). 3. `regen_stage0` from the emitted crate; replace the hand-Rust seed. 4. Flip the lockstep / fixed-point gate from fail-closed to asserting the real `content_hash` digest match (Stage C). -Unmerged work: branch `emitter/seed-green-integration @ 239ff284d5` (**not in main**) carries 6 commits toward a green regen — import-completeness (E0425), List→host-`Vec`, Int-as-generic-arg→`i64`, `regen_stage0` patch, + 2 integration commits. PR **#5325 is CLOSED, not merged.** Recent emitter slices on main: #5413 (length→count, phantom-marker derives, Measure-alias E0560 peel, E0308 Box-deref cluster); MachineWidth is **#5397** (E0107), a separate PR. +**Route-A cargo-green landed on main** (#5777 emitter fixes → 0 rustc errors; #5873 two-generation regen cutover + `regen --verify` CI gate). Branch `emitter/seed-green-integration` content is absorbed — the branch is stale vs `main` and can be retired. PR **#5325** remains closed (superseded by #5873). ### Purity: no stage0 hand-edits (the requirement, and the enforcement gap) From 94a7c4e3b2fa86c8af8f3b8c70ebf20d1c4313ac Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 17:35:56 +0000 Subject: [PATCH 47/51] fix(docs): finish v2-self-hosting plan sync for #5873 wiring Address cursor REQUEST_CHANGES: regen-verify is wired via RegenVerifyGate (#5873, not closed #5325); forced-precondition step 1 marks Track A cargo-green done in lockstep with Track A bullet 2. Regen committed .md from .dag authority. Co-authored-by: Cursor --- docs/plans/v2-self-hosting.md | 8 ++++---- dsl/gunbc/plans/v2_self_hosting.dag | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/plans/v2-self-hosting.md b/docs/plans/v2-self-hosting.md index 727670a0a76..ad4a5c86f33 100644 --- a/docs/plans/v2-self-hosting.md +++ b/docs/plans/v2-self-hosting.md @@ -46,10 +46,10 @@ Get the v2-emitted Rust compiler to build and reproduce itself. The requirement — **v2 emits its own seed; no human stage0 patches** — is *modeled, currently unmet, and un-enforced.* `src/v2/workflow/bootstrap.dag` is the authority and states it exactly ("seed→stage0→stage1→stage2, fixpt stage1==stage2 … seed used once; v2 is never in the loop again", DESIGN §7), including the trust machinery to retire the seed (`SeedHonestyDischarge`, `DiverseCompilationAgreement`/`IndependentCompilerPair` = Diverse Double-Compiling, the Thompson trusting-trust defense). But: - **The seed is hand-maintained today.** `regen_stage0.rs` carries `HAND_MAINTAINED_STAGE0_FILES` + `patch_*` (e.g. `patch_bootstrap_dag_collect`) that compensate for emitter gaps — each a "stage0 hand-edit standing in for a thing v2 should emit itself," honestly marked with a dissolve-on pointing at the emitter fix. (Gotcha: regen has pre-existing codegen drift, so focused PRs hand-edit the `.rs` seed mirror rather than commit a full regen — itself a symptom of the gap.) -- **The no-drift gate is real but not wired.** `regen_stage0 --verify` (`verify_stage0_matches` — "committed stage0 matches fresh self-compile") exists, but a grep of the CI floor (`src/v2/workflow`, `dsl/tools`, `dsl/gunbc`, `dsl/test`) finds it nowhere. The `Stage0LockstepGate` that would wire it in is the content of **closed/unmerged #5325**. So hand-drift goes silently uncaught — erosion by one more honest-looking `patch_*` at a time. +- **The no-drift gate is wired (#5873).** `regen_stage0 --verify` runs in the CI floor via `RegenVerifyGate` → `regen_verify_gate_passes` (`src/v2/workflow/ci_floor_plan.dag`). It enforces no drift on **generated** `GENERATED_STAGE0_FILES`; `HAND_MAINTAINED_STAGE0_FILES` are copied through by design. Closed #5325's `Stage0LockstepGate` was superseded by #5873. **Still open:** dissolve `patch_*` / hand-maintained copies so the emitter owns the whole seed (roadmap `5-dissolve-patches`). - **bootstrap.dag is 🟡 scaffold** — structural wiring only, placeholder hashes (dissolve-on T-15/T-20 `content_hash` supplying real per-stage merkle digests), so it does not yet *prove* convergence. -**This gate is the keystone for both the purity requirement and a trustworthy cutover.** It is what makes "no stage0 hand-edits" enforceable; without it the requirement can only erode. +**The regen-verify gate is the keystone for a trustworthy cutover** — it now runs in CI (#5873), but hand-maintained seed copies and `patch_*` remain until `5-dissolve-patches` lands. ### Track B — the fixed-point proof (Stage C) @@ -69,9 +69,9 @@ So "delete stage0" decomposes — `src/v1` also provides the **CLI bins** (`clai **Forced precondition order (each gates the next):** -1. Whole-tree emit → `cargo build` green (Track A last mile). +1. Whole-tree emit → `cargo build` green — **done** (#5777/#5873; `regen_stage0 --emit-fresh` witness). 2. Real fixed point: `self_host_fixed_point_digests_match` over real `content_hash` (Track B / Stage C; dissolve the placeholder hashes, T-15/T-20). -3. `regen_stage0 --verify` green **and wired into CI** (the `Stage0LockstepGate`, closed #5325) + all `patch_*` / `HAND_MAINTAINED_STAGE0_FILES` dissolved so the emitter emits the whole seed. **This is the step that actually retires "stage0 hand-edits"** and makes the cutover trustworthy. *(Owner + ordering, per #5639: the single regen **cutover** is bright-stag-owned — derive the copy-lists from the emitted-module authority so the drift is unwritable — and lands **after** the emitter largely settles (jolly-cat's emitter-correctness lane), since each emitter fix shifts what a regen produces. crisp-carp's `regen-verify` floor gate is the backstop. roadmap `5-regen-verify` pulled forward.)* +3. `regen_stage0 --verify` wired into CI — **done** (#5873 `RegenVerifyGate`) + all `patch_*` / `HAND_MAINTAINED_STAGE0_FILES` dissolved (**open**, roadmap `5-dissolve-patches`) so the emitter emits the whole seed. **This is the step that actually retires "stage0 hand-edits"** and makes the cutover trustworthy. *(Owner + ordering, per #5639: the single regen **cutover** is bright-stag-owned — derive the copy-lists from the emitted-module authority so the drift is unwritable — and lands **after** the emitter largely settles, since each emitter fix shifts what a regen produces.)* 4. Seed-honesty discharge (ideally via Diverse Double-Compiling). 5. Then collapse `src/v1` to the pinned reproducible seed and delete its compiler logic **incrementally** — verify by execution, not assumption. diff --git a/dsl/gunbc/plans/v2_self_hosting.dag b/dsl/gunbc/plans/v2_self_hosting.dag index c1781bece7c..a2b4b6bceaa 100644 --- a/dsl/gunbc/plans/v2_self_hosting.dag +++ b/dsl/gunbc/plans/v2_self_hosting.dag @@ -46,10 +46,10 @@ fn v2_self_hosting_body() -> List { p(text: "The requirement — **v2 emits its own seed; no human stage0 patches** — is *modeled, currently unmet, and un-enforced.* `src/v2/workflow/bootstrap.dag` is the authority and states it exactly (\"seed→stage0→stage1→stage2, fixpt stage1==stage2 … seed used once; v2 is never in the loop again\", DESIGN §7), including the trust machinery to retire the seed (`SeedHonestyDischarge`, `DiverseCompilationAgreement`/`IndependentCompilerPair` = Diverse Double-Compiling, the Thompson trusting-trust defense). But:"), ul(items: [ li(text: "**The seed is hand-maintained today.** `regen_stage0.rs` carries `HAND_MAINTAINED_STAGE0_FILES` + `patch_*` (e.g. `patch_bootstrap_dag_collect`) that compensate for emitter gaps — each a \"stage0 hand-edit standing in for a thing v2 should emit itself,\" honestly marked with a dissolve-on pointing at the emitter fix. (Gotcha: regen has pre-existing codegen drift, so focused PRs hand-edit the `.rs` seed mirror rather than commit a full regen — itself a symptom of the gap.)"), - li(text: "**The no-drift gate is real but not wired.** `regen_stage0 --verify` (`verify_stage0_matches` — \"committed stage0 matches fresh self-compile\") exists, but a grep of the CI floor (`src/v2/workflow`, `dsl/tools`, `dsl/gunbc`, `dsl/test`) finds it nowhere. The `Stage0LockstepGate` that would wire it in is the content of **closed/unmerged #5325**. So hand-drift goes silently uncaught — erosion by one more honest-looking `patch_*` at a time."), + li(text: "**The no-drift gate is wired (#5873).** `regen_stage0 --verify` runs in the CI floor via `RegenVerifyGate` → `regen_verify_gate_passes` (`src/v2/workflow/ci_floor_plan.dag`). It enforces no drift on **generated** `GENERATED_STAGE0_FILES`; `HAND_MAINTAINED_STAGE0_FILES` are copied through by design. Closed #5325's `Stage0LockstepGate` was superseded by #5873. **Still open:** dissolve `patch_*` / hand-maintained copies so the emitter owns the whole seed (roadmap `5-dissolve-patches`)."), li(text: "**bootstrap.dag is 🟡 scaffold** — structural wiring only, placeholder hashes (dissolve-on T-15/T-20 `content_hash` supplying real per-stage merkle digests), so it does not yet *prove* convergence."), ]), - p(text: "**This gate is the keystone for both the purity requirement and a trustworthy cutover.** It is what makes \"no stage0 hand-edits\" enforceable; without it the requirement can only erode."), + p(text: "**The regen-verify gate is the keystone for a trustworthy cutover** — it now runs in CI (#5873), but hand-maintained seed copies and `patch_*` remain until `5-dissolve-patches` lands."), h3(text: "Track B — the fixed-point proof (Stage C)"), p(text: "`candidate_generation.dag` (`generate_stage_candidate_from_ingest`) drives `assemble_program_from_ingest → infer → translate`, capturing the emitted **Node** before `serialize_target` — the input Stage C needs. Comparison substrate (emitted Node vs emitted bytes) is operator-pending (merry-crab-687). When it lands, the fail-closed runner flips to `Accepted` + real-digest match. Proven **per realization** (Rust first; TypeScript once its target rows are complete)."), h3(text: "Track T — TypeScript as a first-class realization"), @@ -60,9 +60,9 @@ fn v2_self_hosting_body() -> List { p(text: "So \"delete stage0\" decomposes — `src/v1` also provides the **CLI bins** (`claim_executor`, `regen_stage0`, `yaml_check`, …), the **CI floor runner**, the **host-effect transports**, and the **evaluator that runs `.dag`**. Each must be v2-emitted or pinned *before* it can go; a big-bang `rm -rf src/v1` after a green fixed point would take out the execution substrate, not just the redundant compiler."), p(text: "**Forced precondition order (each gates the next):**"), ol(items: [ - li(text: "Whole-tree emit → `cargo build` green (Track A last mile)."), + li(text: "Whole-tree emit → `cargo build` green — **done** (#5777/#5873; `regen_stage0 --emit-fresh` witness)."), li(text: "Real fixed point: `self_host_fixed_point_digests_match` over real `content_hash` (Track B / Stage C; dissolve the placeholder hashes, T-15/T-20)."), - li(text: "`regen_stage0 --verify` green **and wired into CI** (the `Stage0LockstepGate`, closed #5325) + all `patch_*` / `HAND_MAINTAINED_STAGE0_FILES` dissolved so the emitter emits the whole seed. **This is the step that actually retires \"stage0 hand-edits\"** and makes the cutover trustworthy. *(Owner + ordering, per #5639: the single regen **cutover** is bright-stag-owned — derive the copy-lists from the emitted-module authority so the drift is unwritable — and lands **after** the emitter largely settles (jolly-cat's emitter-correctness lane), since each emitter fix shifts what a regen produces. crisp-carp's `regen-verify` floor gate is the backstop. roadmap `5-regen-verify` pulled forward.)*"), + li(text: "`regen_stage0 --verify` wired into CI — **done** (#5873 `RegenVerifyGate`) + all `patch_*` / `HAND_MAINTAINED_STAGE0_FILES` dissolved (**open**, roadmap `5-dissolve-patches`) so the emitter emits the whole seed. **This is the step that actually retires \"stage0 hand-edits\"** and makes the cutover trustworthy. *(Owner + ordering, per #5639: the single regen **cutover** is bright-stag-owned — derive the copy-lists from the emitted-module authority so the drift is unwritable — and lands **after** the emitter largely settles, since each emitter fix shifts what a regen produces.)*"), li(text: "Seed-honesty discharge (ideally via Diverse Double-Compiling)."), li(text: "Then collapse `src/v1` to the pinned reproducible seed and delete its compiler logic **incrementally** — verify by execution, not assumption."), ]), From c2d531890b9b9be98cd6aac6921639f3455d08f4 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 17:38:13 +0000 Subject: [PATCH 48/51] feat(plans): land TypeScript gap census as generated Plan (Lane C step A) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Discriminating audit-first record: 9 VEP source-string GREEN families, 2 FAIL-CLOSED, 8 FAIL-OPEN (#13–#20) with named witness/authority sites. Clarifies bar (b) vs bar (c) — tsc/emit_host oracle red even for add (#19). Enrolled in plan_registry; regen docs/plans/typescript-gap-census.md via main_wet. Co-authored-by: Cursor --- docs/plans/typescript-gap-census.md | 75 ++++++++++++++++++++ dsl/gunbc/plan_registry_batch_g.dag | 4 +- dsl/gunbc/plans/typescript_gap_census.dag | 83 +++++++++++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 docs/plans/typescript-gap-census.md create mode 100644 dsl/gunbc/plans/typescript_gap_census.dag diff --git a/docs/plans/typescript-gap-census.md b/docs/plans/typescript-gap-census.md new file mode 100644 index 00000000000..15e47534a03 --- /dev/null +++ b/docs/plans/typescript-gap-census.md @@ -0,0 +1,75 @@ +# TypeScript first-class gap census — discriminating construct audit (Lane C / Track T) + +**Status:** audit-first discriminating census · **approved 2026-07-01** (loyal-bee-794) · linked from `ROADMAP.md` `5-ts-first-class` · companion to `v2-self-hosting.md` Track T. **This file is the authority;** `docs/plans/typescript-gap-census.md` is generated (PlanArtifact). + +**Method:** enumerate construct families `src/v2` actually uses (compiler substrate behaviors in `src/v2/compiler/*` + TargetModel emit surfaces in `src/v2/extdeps/languages/typescript.dag`). For each family report three independent bars: (a) grammar-inverse row enrolled on the committed TargetModel node, (b) VEP / pipeline emits the expected **TypeScript source string** (witness PASS), (c) **`tsc` / emit_host accepts the output** (consumer green-by-execution). Every FAIL names a witness or authority site — not a stub count. + +> **Two-bar clarification (parent reframe 2026-07-01).** The GREEN column below is **bar (b) only** — VEP produces the expected TS source string. Bar (c) — `tsc` actually compiles the emitted output — is **UNMET even for `add`**: `typescript_descriptor_node_ts_node_run_add_holds` (`src/v2/test/claim/manual/typescript_descriptor_node_run_test.dag`) and `emit_host_gate_passes` (`dsl/tools/emit_host_gate.dag`) both **FAIL wet** in execution. A construct is not genuinely first-class until bar (c) is green. **Do not stack breadth on a red tsc foundation.** + +--- + +## 1. Baseline (merged on main, not stub PRs) + +- #5695 — Char atom-realization + green typed-fn emit +- #5701 — FieldAccess + RecordConstruct + `tsc --noEmit` oracle (source-string witnesses; bar (c) still red — see #19) +- #5704 — operators by inhabitance (test-catalog only, not default TargetModel) +- #5938 — collection-method grammar rows +- ~55 `typescript_*` / `ts_*` test fns under `src/v2/test/claim/` (manual + execution trees) + +## 2. Census table + +### VEP source-string GREEN (bar (b) witness PASS) + +1. **#1 fn add** — grammar-inverse row + full infer→emit pipeline. Witness: `add_body_ts_emit_add_fn_accepts_holds`, `typescript_add_emit_add_fn_accepts_holds` (`add_body_emit_typescript_test.dag`, `typescript_add_emit_translate_test.dag`). +2. **#2 field access** — VEP. Witness: `ts_field_access_emit_source_holds` → `"o.x"` (`typescript_field_access_emit_test.dag`). +3. **#3 record construct** — VEP. Witness: `ts_record_construct_emit_source_holds` (`typescript_record_construct_emit_test.dag`). +4. **#4 bind let IIFE** — VEP. Witness: `ts_bind_let_iife_emit_exact_holds` (`typescript_bind_let_iife_emit_test.dag`). +5. **#5 closure (value-producing)** — VEP. Witness: `ts_closure_emit_by_execution_exact_holds` (`typescript_closure_emit_by_execution_test.dag`). +6. **#6 enum / disj union** — VEP. Witness: `ts_enum_union_emit_by_execution_exact_holds` (`typescript_enum_union_emit_by_execution_test.dag`). +7. **#7 module import** — VEP. Witness: `ts_import_emit_by_execution_exact_holds` (`typescript_import_emit_by_execution_test.dag`). +8. **#8 effect apply** — VEP. Witness: `ts_effect_io_emit_holds` (`typescript_effect_io_emit_test.dag`). +9. **#9 fold_call body via translate** — VEP. Witness: `fold_call_closure_emit_keystone_holds` (`fold_call_closure_emit_test.dag`). +10. **#10 operators (arith/cmp)** — VEP with **ad-hoc test catalog only** (`add_body_ts_emit_catalog_minus_discriminates`, `add_body_ts_emit_missing_catalog_rejects`). Default `ts_operator_realizations_catalog_node()` enrolls **OpAdd only** (`typescript.dag:640`) — see #16. + +### FAIL-CLOSED (emit explicitly Rejected — named) + +1. **#11 loop in statement-sequenced block mode** — `ts_loop_statement_sequenced_fails_closed_holds` (`typescript_bind_let_iife_emit_test.dag`; also `typescript_closure_emit_by_execution_test.dag`). `.dag` loop emits; TS `StatementSequenced` mode rejects. +2. **#12 closure in statement-sequenced block mode** — `ts_closure_statement_sequenced_fails_closed_holds` (same files). + +### FAIL-OPEN (compiler-scale; no green bar (b)+(c) on default model today) + +1. **#13 match / coproduct dispatch** — `match_form.match_token = ^ts_token_unwired_match` (`typescript.dag:623`); no TS match witness; compiler uses `Match` heavily (`05_eval.dag`). +2. **#14 bind-in scoping** — `let_form.in_token = ^ts_token_unwired_bind_in` (`typescript.dag:606`). +3. **#15 loop form wiring** — `loop_form.loop_token = ^ts_token_unwired_loop` (`typescript.dag:609`). +4. **#16 default operator catalog** — `ts_operator_realizations_catalog_node()` rows = `[ts_add_operator_realization_row()]` only (`typescript.dag:640–641`). Algebra ops miss on default model (`add_body_ts_emit_missing_catalog_rejects`). +5. **#17 grammar-inverse rows beyond add** — committed `ts_mvp1_translation_rules_node()` has **1** child (`fn_add`); witness bundle `ts_mvp1_translation_rules_witness()` expects **3** (add + type_alias + pr3) (`typescript.dag:1381–1414`). +6. **#18 branch dispatch** — compiler uses `Branch` (`04_infer` / `05_eval`); zero TS emit witnesses. +7. **#19 tsc-green / emit_host oracle** — §5 spec-without-execution crack. Sole consumer path: `ts_host_transport_mvp1_descriptor` + `emit_host_gate.dag`. **`typescript_descriptor_node_ts_node_run_add_holds` FAIL** (wet `claim_batch`); **`emit_host_gate_passes` FAIL** (wet). Bar (c) red even for add. +8. **#20 whole `src/v2` → TS** — no module; Route-A tsc analogue not started (terminal slice E). + +## 3. Discriminating counts + +- **VEP source-string GREEN families:** 9 (#1–#9; #10 green only with ad-hoc catalog) +- **FAIL-CLOSED:** 2 (#11–#12) +- **FAIL-OPEN compiler-scale gaps:** 8 (#13–#20) +- **tsc-green (bar c):** 0/N wet — add fixture attempted, red in execution (#19) +- **Grammar-inverse rows:** 1 committed / 3 in witness bundle / ~15 wave2a productions defined + +## 4. Size call + +**LARGE multi-slice** — not a single row PR. Cheap tranche = grammar-row extensions (#17) + operator catalog derivation onto default TargetModel if row-only (#16). Load-bearing tranche = Match (#13) + loop/bind forms (#14–#15) + Branch (#18) — **HOLD for parent sign** before authoring TargetModel surfaces. Whole-tree tsc (#20) is terminal after per-construct gaps close. + +## 5. Sequencing (revised 2026-07-01) + +1. **A. Land this census** (this plan) — audit-first record, generated md. +2. **A2. tsc-green oracle REAL on existing VEP-green slices (#19 pulled forward)** — per-construct `tsc` acceptance on #1–#9 before stacking breadth. Converts string-green families into compile-green. Highest-value foundation work. +3. **B. Cheap row extensions (#17)** — enroll type_alias + pr3 rows into committed `ts_mvp1_translation_rules_node`; rows only, no new TargetModel surface. +4. **C. Operator catalog (#16)** — proceed **only** if genuinely row-derivation onto the default model; if it needs a new TargetModel surface → load-bearing → sign first. +5. **D. HOLD for parent sign:** Match (#13) + loop/bind (#14–#15) + Branch (#18) — compiler-scale TargetModel surfaces. +6. **E. Whole-tree Route-A tsc (#20)** — terminal. + +**Priority note:** Lane C is language-breadth; operator retains burn-down sequencing call. Proceed A → A2 → B meanwhile; HOLD D for both parent sign and operator priority. + +## Dissolution trigger (DESIGN §6) + +Delete this census once every FAIL-OPEN row (#13–#20) is closed with execution-grounded witnesses and bar (c) tsc-green holds on the default TargetModel — the audit record is superseded by the substrate facts it enumerated. diff --git a/dsl/gunbc/plan_registry_batch_g.dag b/dsl/gunbc/plan_registry_batch_g.dag index 357ec2b8f25..e9925ca9901 100644 --- a/dsl/gunbc/plan_registry_batch_g.dag +++ b/dsl/gunbc/plan_registry_batch_g.dag @@ -9,6 +9,7 @@ import gunbc.plans.host_effect_orchestration { host_effect_orchestration_plan } import gunbc.plans.ci_floor_fractal_gantt { ci_floor_fractal_gantt_plan } import gunbc.plans.representation_minimization { representation_minimization_plan } import gunbc.plans.reference_grounding_migration { reference_grounding_migration_plan } +import gunbc.plans.typescript_gap_census { typescript_gap_census_plan } data batch_g_plans: List = [ ci_humming_plan, @@ -18,5 +19,6 @@ data batch_g_plans: List = [ host_effect_orchestration_plan, ci_floor_fractal_gantt_plan, representation_minimization_plan, - reference_grounding_migration_plan + reference_grounding_migration_plan, + typescript_gap_census_plan ] diff --git a/dsl/gunbc/plans/typescript_gap_census.dag b/dsl/gunbc/plans/typescript_gap_census.dag new file mode 100644 index 00000000000..b419a1160cf --- /dev/null +++ b/dsl/gunbc/plans/typescript_gap_census.dag @@ -0,0 +1,83 @@ +module gunbc.plans.typescript_gap_census + +import gunbc.plan { Plan, DissolutionTrigger, HasTrigger } +import std.markdown { MarkdownBlock, ThematicBreak } +import gunbc.plans.md_helpers { h2, h3, p, li, ul, ol, quote } + +fn typescript_gap_census_body() -> List { + [ + p(text: "**Status:** audit-first discriminating census · **approved 2026-07-01** (loyal-bee-794) · linked from `ROADMAP.md` `5-ts-first-class` · companion to `v2-self-hosting.md` Track T. **This file is the authority;** `docs/plans/typescript-gap-census.md` is generated (PlanArtifact)."), + p(text: "**Method:** enumerate construct families `src/v2` actually uses (compiler substrate behaviors in `src/v2/compiler/*` + TargetModel emit surfaces in `src/v2/extdeps/languages/typescript.dag`). For each family report three independent bars: (a) grammar-inverse row enrolled on the committed TargetModel node, (b) VEP / pipeline emits the expected **TypeScript source string** (witness PASS), (c) **`tsc` / emit_host accepts the output** (consumer green-by-execution). Every FAIL names a witness or authority site — not a stub count."), + quote(blocks: [ + p(text: "**Two-bar clarification (parent reframe 2026-07-01).** The GREEN column below is **bar (b) only** — VEP produces the expected TS source string. Bar (c) — `tsc` actually compiles the emitted output — is **UNMET even for `add`**: `typescript_descriptor_node_ts_node_run_add_holds` (`src/v2/test/claim/manual/typescript_descriptor_node_run_test.dag`) and `emit_host_gate_passes` (`dsl/tools/emit_host_gate.dag`) both **FAIL wet** in execution. A construct is not genuinely first-class until bar (c) is green. **Do not stack breadth on a red tsc foundation.**"), + ]), + ThematicBreak, + h2(text: "1. Baseline (merged on main, not stub PRs)"), + ul(items: [ + li(text: "#5695 — Char atom-realization + green typed-fn emit"), + li(text: "#5701 — FieldAccess + RecordConstruct + `tsc --noEmit` oracle (source-string witnesses; bar (c) still red — see #19)"), + li(text: "#5704 — operators by inhabitance (test-catalog only, not default TargetModel)"), + li(text: "#5938 — collection-method grammar rows"), + li(text: "~55 `typescript_*` / `ts_*` test fns under `src/v2/test/claim/` (manual + execution trees)"), + ]), + h2(text: "2. Census table"), + h3(text: "VEP source-string GREEN (bar (b) witness PASS)"), + ol(items: [ + li(text: "**#1 fn add** — grammar-inverse row + full infer→emit pipeline. Witness: `add_body_ts_emit_add_fn_accepts_holds`, `typescript_add_emit_add_fn_accepts_holds` (`add_body_emit_typescript_test.dag`, `typescript_add_emit_translate_test.dag`)."), + li(text: "**#2 field access** — VEP. Witness: `ts_field_access_emit_source_holds` → `\"o.x\"` (`typescript_field_access_emit_test.dag`)."), + li(text: "**#3 record construct** — VEP. Witness: `ts_record_construct_emit_source_holds` (`typescript_record_construct_emit_test.dag`)."), + li(text: "**#4 bind let IIFE** — VEP. Witness: `ts_bind_let_iife_emit_exact_holds` (`typescript_bind_let_iife_emit_test.dag`)."), + li(text: "**#5 closure (value-producing)** — VEP. Witness: `ts_closure_emit_by_execution_exact_holds` (`typescript_closure_emit_by_execution_test.dag`)."), + li(text: "**#6 enum / disj union** — VEP. Witness: `ts_enum_union_emit_by_execution_exact_holds` (`typescript_enum_union_emit_by_execution_test.dag`)."), + li(text: "**#7 module import** — VEP. Witness: `ts_import_emit_by_execution_exact_holds` (`typescript_import_emit_by_execution_test.dag`)."), + li(text: "**#8 effect apply** — VEP. Witness: `ts_effect_io_emit_holds` (`typescript_effect_io_emit_test.dag`)."), + li(text: "**#9 fold_call body via translate** — VEP. Witness: `fold_call_closure_emit_keystone_holds` (`fold_call_closure_emit_test.dag`)."), + li(text: "**#10 operators (arith/cmp)** — VEP with **ad-hoc test catalog only** (`add_body_ts_emit_catalog_minus_discriminates`, `add_body_ts_emit_missing_catalog_rejects`). Default `ts_operator_realizations_catalog_node()` enrolls **OpAdd only** (`typescript.dag:640`) — see #16."), + ]), + h3(text: "FAIL-CLOSED (emit explicitly Rejected — named)"), + ol(items: [ + li(text: "**#11 loop in statement-sequenced block mode** — `ts_loop_statement_sequenced_fails_closed_holds` (`typescript_bind_let_iife_emit_test.dag`; also `typescript_closure_emit_by_execution_test.dag`). `.dag` loop emits; TS `StatementSequenced` mode rejects."), + li(text: "**#12 closure in statement-sequenced block mode** — `ts_closure_statement_sequenced_fails_closed_holds` (same files)."), + ]), + h3(text: "FAIL-OPEN (compiler-scale; no green bar (b)+(c) on default model today)"), + ol(items: [ + li(text: "**#13 match / coproduct dispatch** — `match_form.match_token = ^ts_token_unwired_match` (`typescript.dag:623`); no TS match witness; compiler uses `Match` heavily (`05_eval.dag`)."), + li(text: "**#14 bind-in scoping** — `let_form.in_token = ^ts_token_unwired_bind_in` (`typescript.dag:606`)."), + li(text: "**#15 loop form wiring** — `loop_form.loop_token = ^ts_token_unwired_loop` (`typescript.dag:609`)."), + li(text: "**#16 default operator catalog** — `ts_operator_realizations_catalog_node()` rows = `[ts_add_operator_realization_row()]` only (`typescript.dag:640–641`). Algebra ops miss on default model (`add_body_ts_emit_missing_catalog_rejects`)."), + li(text: "**#17 grammar-inverse rows beyond add** — committed `ts_mvp1_translation_rules_node()` has **1** child (`fn_add`); witness bundle `ts_mvp1_translation_rules_witness()` expects **3** (add + type_alias + pr3) (`typescript.dag:1381–1414`)."), + li(text: "**#18 branch dispatch** — compiler uses `Branch` (`04_infer` / `05_eval`); zero TS emit witnesses."), + li(text: "**#19 tsc-green / emit_host oracle** — §5 spec-without-execution crack. Sole consumer path: `ts_host_transport_mvp1_descriptor` + `emit_host_gate.dag`. **`typescript_descriptor_node_ts_node_run_add_holds` FAIL** (wet `claim_batch`); **`emit_host_gate_passes` FAIL** (wet). Bar (c) red even for add."), + li(text: "**#20 whole `src/v2` → TS** — no module; Route-A tsc analogue not started (terminal slice E)."), + ]), + h2(text: "3. Discriminating counts"), + ul(items: [ + li(text: "**VEP source-string GREEN families:** 9 (#1–#9; #10 green only with ad-hoc catalog)"), + li(text: "**FAIL-CLOSED:** 2 (#11–#12)"), + li(text: "**FAIL-OPEN compiler-scale gaps:** 8 (#13–#20)"), + li(text: "**tsc-green (bar c):** 0/N wet — add fixture attempted, red in execution (#19)"), + li(text: "**Grammar-inverse rows:** 1 committed / 3 in witness bundle / ~15 wave2a productions defined"), + ]), + h2(text: "4. Size call"), + p(text: "**LARGE multi-slice** — not a single row PR. Cheap tranche = grammar-row extensions (#17) + operator catalog derivation onto default TargetModel if row-only (#16). Load-bearing tranche = Match (#13) + loop/bind forms (#14–#15) + Branch (#18) — **HOLD for parent sign** before authoring TargetModel surfaces. Whole-tree tsc (#20) is terminal after per-construct gaps close."), + h2(text: "5. Sequencing (revised 2026-07-01)"), + ol(items: [ + li(text: "**A. Land this census** (this plan) — audit-first record, generated md."), + li(text: "**A2. tsc-green oracle REAL on existing VEP-green slices (#19 pulled forward)** — per-construct `tsc` acceptance on #1–#9 before stacking breadth. Converts string-green families into compile-green. Highest-value foundation work."), + li(text: "**B. Cheap row extensions (#17)** — enroll type_alias + pr3 rows into committed `ts_mvp1_translation_rules_node`; rows only, no new TargetModel surface."), + li(text: "**C. Operator catalog (#16)** — proceed **only** if genuinely row-derivation onto the default model; if it needs a new TargetModel surface → load-bearing → sign first."), + li(text: "**D. HOLD for parent sign:** Match (#13) + loop/bind (#14–#15) + Branch (#18) — compiler-scale TargetModel surfaces."), + li(text: "**E. Whole-tree Route-A tsc (#20)** — terminal."), + ]), + p(text: "**Priority note:** Lane C is language-breadth; operator retains burn-down sequencing call. Proceed A → A2 → B meanwhile; HOLD D for both parent sign and operator priority."), + ] +} + +data typescript_gap_census_plan: Plan = Plan { + slug: "typescript-gap-census", + title: "TypeScript first-class gap census — discriminating construct audit (Lane C / Track T)", + body: typescript_gap_census_body(), + dissolution: HasTrigger { + text: "Delete this census once every FAIL-OPEN row (#13–#20) is closed with execution-grounded witnesses and bar (c) tsc-green holds on the default TargetModel — the audit record is superseded by the substrate facts it enumerated." + } +} From 0ff1955b4e28881a8b339a8b5ab5b496764b6ff5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 17:41:10 +0000 Subject: [PATCH 49/51] WIP: Section 5 self-host execution manager: Lane A drive the emitted rust cra --- .githooks/pre-push | 1 + 1 file changed, 1 insertion(+) diff --git a/.githooks/pre-push b/.githooks/pre-push index 8f3d3dc9169..20fcfd0add3 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -83,6 +83,7 @@ fresh_artifact_path() { docs/plans/ci-floor-fractal-gantt.md*) return 0 ;; docs/plans/representation-minimization.md*) return 0 ;; docs/plans/reference-grounding-migration.md*) return 0 ;; + docs/plans/typescript-gap-census.md*) return 0 ;; dsl/**) return 0 ;; src/v2/**) return 0 ;; esac From 6efaf21943cb21e7fa5dd361d98066634cc8a2ab Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 17:52:37 +0000 Subject: [PATCH 50/51] fix(docs): name .dag authority in typescript gap census plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address cursor REQUEST_CHANGES (#34390): status line no longer says "This file is the authority" in generated .md — names typescript_gap_census.dag explicitly (DESIGN §3/§6). Regen committed projection via main_wet. Co-authored-by: Cursor --- docs/plans/typescript-gap-census.md | 2 +- dsl/gunbc/plans/typescript_gap_census.dag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plans/typescript-gap-census.md b/docs/plans/typescript-gap-census.md index 15e47534a03..8dde5a08093 100644 --- a/docs/plans/typescript-gap-census.md +++ b/docs/plans/typescript-gap-census.md @@ -1,6 +1,6 @@ # TypeScript first-class gap census — discriminating construct audit (Lane C / Track T) -**Status:** audit-first discriminating census · **approved 2026-07-01** (loyal-bee-794) · linked from `ROADMAP.md` `5-ts-first-class` · companion to `v2-self-hosting.md` Track T. **This file is the authority;** `docs/plans/typescript-gap-census.md` is generated (PlanArtifact). +**Status:** audit-first discriminating census · **approved 2026-07-01** (loyal-bee-794) · linked from `ROADMAP.md` `5-ts-first-class` · companion to `v2-self-hosting.md` Track T. **`dsl/gunbc/plans/typescript_gap_census.dag` is the authority** (DESIGN §6); `docs/plans/typescript-gap-census.md` is its generated projection (PlanArtifact). **Method:** enumerate construct families `src/v2` actually uses (compiler substrate behaviors in `src/v2/compiler/*` + TargetModel emit surfaces in `src/v2/extdeps/languages/typescript.dag`). For each family report three independent bars: (a) grammar-inverse row enrolled on the committed TargetModel node, (b) VEP / pipeline emits the expected **TypeScript source string** (witness PASS), (c) **`tsc` / emit_host accepts the output** (consumer green-by-execution). Every FAIL names a witness or authority site — not a stub count. diff --git a/dsl/gunbc/plans/typescript_gap_census.dag b/dsl/gunbc/plans/typescript_gap_census.dag index b419a1160cf..05e10792ff9 100644 --- a/dsl/gunbc/plans/typescript_gap_census.dag +++ b/dsl/gunbc/plans/typescript_gap_census.dag @@ -6,7 +6,7 @@ import gunbc.plans.md_helpers { h2, h3, p, li, ul, ol, quote } fn typescript_gap_census_body() -> List { [ - p(text: "**Status:** audit-first discriminating census · **approved 2026-07-01** (loyal-bee-794) · linked from `ROADMAP.md` `5-ts-first-class` · companion to `v2-self-hosting.md` Track T. **This file is the authority;** `docs/plans/typescript-gap-census.md` is generated (PlanArtifact)."), + p(text: "**Status:** audit-first discriminating census · **approved 2026-07-01** (loyal-bee-794) · linked from `ROADMAP.md` `5-ts-first-class` · companion to `v2-self-hosting.md` Track T. **`dsl/gunbc/plans/typescript_gap_census.dag` is the authority** (DESIGN §6); `docs/plans/typescript-gap-census.md` is its generated projection (PlanArtifact)."), p(text: "**Method:** enumerate construct families `src/v2` actually uses (compiler substrate behaviors in `src/v2/compiler/*` + TargetModel emit surfaces in `src/v2/extdeps/languages/typescript.dag`). For each family report three independent bars: (a) grammar-inverse row enrolled on the committed TargetModel node, (b) VEP / pipeline emits the expected **TypeScript source string** (witness PASS), (c) **`tsc` / emit_host accepts the output** (consumer green-by-execution). Every FAIL names a witness or authority site — not a stub count."), quote(blocks: [ p(text: "**Two-bar clarification (parent reframe 2026-07-01).** The GREEN column below is **bar (b) only** — VEP produces the expected TS source string. Bar (c) — `tsc` actually compiles the emitted output — is **UNMET even for `add`**: `typescript_descriptor_node_ts_node_run_add_holds` (`src/v2/test/claim/manual/typescript_descriptor_node_run_test.dag`) and `emit_host_gate_passes` (`dsl/tools/emit_host_gate.dag`) both **FAIL wet** in execution. A construct is not genuinely first-class until bar (c) is green. **Do not stack breadth on a red tsc foundation.**"), From 750149cf6f3dbd348b0425c30e663ad280b64c76 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 1 Jul 2026 19:12:53 +0000 Subject: [PATCH 51/51] fix(docs): bind typescript-gap-census into doc graph MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI failed doc_graph_has_no_orphan_docs — new PlanArtifact md had no reachability root. Add bind: provenance on typescript_gap_census.dag (mirror commit_workflow / accelerator_demo_plan pattern). Co-authored-by: Cursor --- dsl/gunbc/plans/typescript_gap_census.dag | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dsl/gunbc/plans/typescript_gap_census.dag b/dsl/gunbc/plans/typescript_gap_census.dag index 05e10792ff9..cdbf08319b3 100644 --- a/dsl/gunbc/plans/typescript_gap_census.dag +++ b/dsl/gunbc/plans/typescript_gap_census.dag @@ -73,6 +73,8 @@ fn typescript_gap_census_body() -> List { ] } +data typescript_gap_census_plan_doc_provenance: String = "bind: docs/plans/typescript-gap-census.md" + data typescript_gap_census_plan: Plan = Plan { slug: "typescript-gap-census", title: "TypeScript first-class gap census — discriminating construct audit (Lane C / Track T)",