From 0ec353324a5f0df8f7dafaa5923a3d08d4e00a58 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:09:52 +0000 Subject: [PATCH 01/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/04_infer.dag | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 }, From 85f155deeb11eabf0f9684d1e9f8b01295bb10f4 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:20:26 +0000 Subject: [PATCH 02/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/05_emit_rust.dag | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 399633b943c..3ca36a0d2fd 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, @@ -4815,15 +4816,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) { From dbe90105f14548d9fc6552ea7c1ef26fb2fc79ce Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:30:31 +0000 Subject: [PATCH 03/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/05_emit_rust.dag | 70 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 3ca36a0d2fd..8d5e9451b9b 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -3111,6 +3111,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 @@ -3129,7 +3169,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}") } } @@ -6309,7 +6358,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: decl } => + if decl.connective == Conj { + let pnames = decl.params |> map(p => generic_param_name_at(n: p, source_indices: si)) + let unused = struct_unused_param_names(generic_param_names: pnames, children: decl.children, source_indices: si) + if unused |> count > 0 { + [concat(" ", rust_phantom_field_name(), ": std::marker::PhantomData,")] + } else { [] } + } 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 From e28b5e44fae0ef91be3a0d311b60cf64e4a42557 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:41:32 +0000 Subject: [PATCH 04/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/05_emit_rust.dag | 14 +- src/v1/stage0/src/compiler_tests.rs | 6 +- src/v1/stage0/src/extdeps_cargo.rs | 124 +- src/v1/stage0/src/extdeps_cargo_version.rs | 12 +- .../stage0/src/extdeps_languages_dag_emit.rs | 32 +- .../src/extdeps_languages_dag_syntax.rs | 118 +- .../stage0/src/extdeps_languages_go_emit.rs | 28 +- .../src/extdeps_languages_python_emit.rs | 28 +- .../src/extdeps_languages_python_types.rs | 3 + .../stage0/src/extdeps_languages_rust_emit.rs | 30 +- .../src/extdeps_languages_rust_syntax.rs | 78 +- .../src/extdeps_languages_rust_types.rs | 8 + src/v1/stage0/src/extdeps_version_semver.rs | 23 +- src/v1/stage0/src/lib.rs | 16 +- src/v1/stage0/src/main.rs | 6 - src/v1/stage0/src/std_algebra.rs | 38 +- src/v1/stage0/src/std_coercion.rs | 8 +- src/v1/stage0/src/std_computation.rs | 9 +- src/v1/stage0/src/std_constructors.rs | 9 +- src/v1/stage0/src/std_effects.rs | 58 +- src/v1/stage0/src/std_emit_model.rs | 6 +- src/v1/stage0/src/std_error_primitives.rs | 3 + src/v1/stage0/src/std_graph.rs | 4 +- src/v1/stage0/src/std_http_path.rs | 10 +- src/v1/stage0/src/std_induction.rs | 19 +- src/v1/stage0/src/std_integer.rs | 40 +- src/v1/stage0/src/std_lens_verdict.rs | 6 +- src/v1/stage0/src/std_machine_constraints.rs | 8 +- src/v1/stage0/src/std_magnitude.rs | 3 +- src/v1/stage0/src/std_measure.rs | 57 +- src/v1/stage0/src/std_node.rs | 8 +- src/v1/stage0/src/std_realization_schedule.rs | 45 +- src/v1/stage0/src/std_serialization.rs | 17 +- src/v1/stage0/src/std_syntax.rs | 36 + src/v1/stage0/src/std_termination.rs | 4 + src/v1/stage0/src/std_types.rs | 101 +- src/v1/stage0/src/v1_compiler_artifact.rs | 14 + src/v1/stage0/src/v1_compiler_coercion.rs | 8 +- src/v1/stage0/src/v1_compiler_compile.rs | 101 +- src/v1/stage0/src/v1_compiler_complexity.rs | 144 +- src/v1/stage0/src/v1_compiler_emit.rs | 79 +- .../src/v1_compiler_emit_core_support.rs | 4 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 13 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 15 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 2954 +++++++++-------- src/v1/stage0/src/v1_compiler_infer.rs | 483 ++- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 4 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 5 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 7 + src/v1/stage0/src/v1_compiler_infer_lookup.rs | 54 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 35 - .../stage0/src/v1_compiler_infer_patterns.rs | 37 +- .../stage0/src/v1_compiler_infer_resolve.rs | 78 +- .../stage0/src/v1_compiler_infer_service.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 6 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 74 +- src/v1/stage0/src/v1_compiler_languages.rs | 16 +- src/v1/stage0/src/v1_compiler_ownership.rs | 39 +- src/v1/stage0/src/v1_compiler_parse.rs | 187 +- src/v1/stage0/src/v1_compiler_resolve.rs | 25 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- .../stage0/src/v1_compiler_stage0_crates.rs | 11 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 44 +- src/v1/stage0/src/v1_compiler_trace.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 5 - src/v1/stage0/src/v1_std_core.rs | 175 +- 67 files changed, 2994 insertions(+), 2650 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 8d5e9451b9b..f48151cce42 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -6365,13 +6365,13 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St // 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: decl } => - if decl.connective == Conj { - let pnames = decl.params |> map(p => generic_param_name_at(n: p, source_indices: si)) - let unused = struct_unused_param_names(generic_param_names: pnames, children: decl.children, source_indices: si) - if unused |> count > 0 { - [concat(" ", rust_phantom_field_name(), ": std::marker::PhantomData,")] - } else { [] } + 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 => [] } diff --git a/src/v1/stage0/src/compiler_tests.rs b/src/v1/stage0/src/compiler_tests.rs index fc07fce7ded..fe59340b25a 100644 --- a/src/v1/stage0/src/compiler_tests.rs +++ b/src/v1/stage0/src/compiler_tests.rs @@ -50,11 +50,7 @@ mod compiler_tests { .unwrap() .to_string_lossy() .to_string(); - // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules; - // exclude them so the self_* whole-tree module scans don't try to parse - // them as modules and panic. The only .dag under src/v1/**/tests/ is the - // fixture, so this skips exactly it (#5124 added the fixture; the cargo-test - // CI gate surfaced the panic). No real module lives under a tests/ dir. + // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules. if rel.contains("/tests/") { continue; } diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index 793c4c9abe1..12340c9e698 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -3,7 +3,12 @@ use self::CargoDepSource::*; use self::CargoTarget::*; +use self::RustEdition::*; use self::TestHarness::*; +pub use crate::extdeps_cargo_version::{ + CargoPackageVersion, CargoToolVersionFloor, CargoVersionRequirement, +}; +pub use crate::std_types::FilePathParts; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -13,11 +18,50 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum RustEdition { + Edition2015, + Edition2018, + Edition2021, + Edition2024, +} + +pub fn rust_edition_str(edition: RustEdition) -> String { + match edition { + RustEdition::Edition2015 => "2015".to_string(), + RustEdition::Edition2018 => "2018".to_string(), + RustEdition::Edition2021 => "2021".to_string(), + RustEdition::Edition2024 => "2024".to_string(), + } +} + +pub fn default_rust_edition() -> RustEdition { + thread_local! { + static CACHED: RustEdition = { + RustEdition::Edition2021 + }; + } + CACHED.with(|c: &RustEdition| c.clone()) +} + +pub fn min_cargo_version() -> SemVerConstraint { + thread_local! { + static CACHED: SemVerConstraint = { + serde_json::from_value(serde_json::json!(">= 1.56")) + .expect("valid data definition") + }; + } + CACHED.with(|c: &SemVerConstraint| c.clone()) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoPackage { pub name: String, - pub version: String, - pub edition: String, + pub version: Box, + pub edition: RustEdition, pub path: String, } @@ -25,7 +69,7 @@ pub struct CargoPackage { #[serde(tag = "_variant")] pub enum CargoDepSource { RegistryDep { - version: String, + version: Box, features: Rc>, }, LocalPathDep { @@ -60,6 +104,64 @@ impl CargoTarget { } } +pub fn cargo_target_source_path( + target: Rc, + package_name: String, +) -> Rc { + match (*target).clone() { + CargoTarget::Lib => Rc::new(FilePathParts { + segments: Rc::new(vec!["src".to_string(), "lib.rs".to_string()]), + }), + CargoTarget::Bin { name: name, .. } => { + if (name.clone() == package_name) { + Rc::new(FilePathParts { + segments: Rc::new(vec!["src".to_string(), "main.rs".to_string()]), + }) + } else { + Rc::new(FilePathParts { + segments: Rc::new(vec![ + "src".to_string(), + "bin".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }) + } + } + CargoTarget::CargoTest { name: name, .. } => Rc::new(FilePathParts { + segments: Rc::new(vec![ + "tests".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }), + CargoTarget::Example { name: name, .. } => Rc::new(FilePathParts { + segments: Rc::new(vec![ + "examples".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }), + CargoTarget::Bench { name: name, .. } => Rc::new(FilePathParts { + segments: Rc::new(vec![ + "benches".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }), + } +} + +pub fn rust_module_candidate_paths(stem: String) -> Rc>> { + Rc::new(vec![ + Rc::new(FilePathParts { + segments: Rc::new(vec![ + "src".to_string(), + v1_rt::concat(stem.clone(), ".rs".to_string()), + ]), + }), + Rc::new(FilePathParts { + segments: Rc::new(vec!["src".to_string(), stem.clone(), "mod.rs".to_string()]), + }), + ]) +} + pub type CargoProfile = String; pub fn canonical_profiles() -> Rc> { @@ -86,15 +188,6 @@ pub enum TestHarness { NoHarness, } -pub fn default_edition() -> String { - thread_local! { - static CACHED: String = { - "2021".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn default_profile() -> String { thread_local! { static CACHED: String = { @@ -103,3 +196,10 @@ pub fn default_profile() -> String { } CACHED.with(|c: &String| c.clone()) } + +pub struct Edition2015; +pub struct Edition2018; +pub struct Edition2021; +pub struct Edition2024; +pub struct Harness; +pub struct NoHarness; diff --git a/src/v1/stage0/src/extdeps_cargo_version.rs b/src/v1/stage0/src/extdeps_cargo_version.rs index d20dfe8d70e..96d8331a9f2 100644 --- a/src/v1/stage0/src/extdeps_cargo_version.rs +++ b/src/v1/stage0/src/extdeps_cargo_version.rs @@ -17,27 +17,27 @@ pub type CargoVersionRequirement = SemVerConstraint; pub type CargoToolVersionFloor = SemVerConstraint; -pub fn default_stage0_package_version() -> Rc> { +pub fn default_stage0_package_version() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "0.1.0".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn render_cargo_package_version_field(version: CargoPackageVersion) -> Rc> { +pub fn render_cargo_package_version_field(version: CargoPackageVersion) -> String { v1_rt::concat( v1_rt::concat("version = \"".to_string(), version), "\"".to_string(), ) } -pub fn render_cargo_version_requirement_toml(req: CargoVersionRequirement) -> Rc> { +pub fn render_cargo_version_requirement_toml(req: CargoVersionRequirement) -> String { v1_rt::concat(v1_rt::concat("\"".to_string(), req), "\"".to_string()) } -pub fn render_cargo_package_header_prefix(name: Rc>) -> Rc> { +pub fn render_cargo_package_header_prefix(name: String) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat("[package]\nname = \"".to_string(), name), diff --git a/src/v1/stage0/src/extdeps_languages_dag_emit.rs b/src/v1/stage0/src/extdeps_languages_dag_emit.rs index 53b714ba0d2..531f36a0b9a 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_emit.rs @@ -14,13 +14,13 @@ pub fn dag_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "true".to_string()); - __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "none".to_string()); - __m.insert("and".to_string(), "&&".to_string()); - __m.insert("or".to_string(), "||".to_string()); - __m.insert("not".to_string(), "!".to_string()); - __m.insert("div".to_string(), "/".to_string()); + __m.insert("true", "true".to_string()); + __m.insert("false", "false".to_string()); + __m.insert("null", "none".to_string()); + __m.insert("and", "&&".to_string()); + __m.insert("or", "||".to_string()); + __m.insert("not", "!".to_string()); + __m.insert("div", "/".to_string()); Rc::new(__m) }; } @@ -31,15 +31,15 @@ pub fn dag_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "List<{0}>".to_string()); - __m.insert("set".to_string(), "Set<{0}>".to_string()); - __m.insert("non_empty_list".to_string(), "NonEmptyList<{0}>".to_string()); - __m.insert("non_empty_set".to_string(), "NonEmptySet<{0}>".to_string()); - __m.insert("optional".to_string(), "{0}?".to_string()); - __m.insert("map".to_string(), "Map<{0}, {1}>".to_string()); - __m.insert("free_monoid".to_string(), "List<{0}>".to_string()); - __m.insert("partial_function".to_string(), "Map<{0}, {1}>".to_string()); - __m.insert("boolean_algebra".to_string(), "Bool".to_string()); + __m.insert("list", "List<{0}>".to_string()); + __m.insert("set", "Set<{0}>".to_string()); + __m.insert("non_empty_list", "NonEmptyList<{0}>".to_string()); + __m.insert("non_empty_set", "NonEmptySet<{0}>".to_string()); + __m.insert("optional", "{0}?".to_string()); + __m.insert("map", "Map<{0}, {1}>".to_string()); + __m.insert("free_monoid", "List<{0}>".to_string()); + __m.insert("partial_function", "Map<{0}, {1}>".to_string()); + __m.insert("boolean_algebra", "Bool".to_string()); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs index aa38fb08090..db8d00681bf 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs @@ -108,14 +108,14 @@ pub fn dag_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert("true", Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert("false", Rc::new(LiteralValue::LitBool { value: false, })); - __m.insert("none".to_string(), Rc::new(LiteralValue::LitNull)); - __m.insert("null".to_string(), Rc::new(LiteralValue::LitNull)); + __m.insert("none", Rc::new(LiteralValue::LitNull)); + __m.insert("null", Rc::new(LiteralValue::LitNull)); Rc::new(__m) }; } @@ -126,41 +126,41 @@ pub fn dag_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("module".to_string(), true); - __m.insert("import".to_string(), true); - __m.insert("type".to_string(), true); - __m.insert("fn".to_string(), true); - __m.insert("func".to_string(), true); - __m.insert("resource".to_string(), true); - __m.insert("service".to_string(), true); - __m.insert("data".to_string(), true); - __m.insert("interface".to_string(), true); - __m.insert("pipeline".to_string(), true); - __m.insert("profile".to_string(), true); - __m.insert("pattern".to_string(), true); - __m.insert("let".to_string(), true); - __m.insert("return".to_string(), true); - __m.insert("match".to_string(), true); - __m.insert("if".to_string(), true); - __m.insert("then".to_string(), true); - __m.insert("else".to_string(), true); - __m.insert("for".to_string(), true); - __m.insert("in".to_string(), true); - __m.insert("where".to_string(), true); - __m.insert("with".to_string(), true); - __m.insert("true".to_string(), true); - __m.insert("false".to_string(), true); - __m.insert("none".to_string(), true); - __m.insert("null".to_string(), true); - __m.insert("acquire".to_string(), true); - __m.insert("release".to_string(), true); - __m.insert("capability".to_string(), true); - __m.insert("operation".to_string(), true); - __m.insert("input".to_string(), true); - __m.insert("output".to_string(), true); - __m.insert("idempotent".to_string(), true); - __m.insert("readonly".to_string(), true); - __m.insert("hermetic".to_string(), true); + __m.insert("module", true); + __m.insert("import", true); + __m.insert("type", true); + __m.insert("fn", true); + __m.insert("func", true); + __m.insert("resource", true); + __m.insert("service", true); + __m.insert("data", true); + __m.insert("interface", true); + __m.insert("pipeline", true); + __m.insert("profile", true); + __m.insert("pattern", true); + __m.insert("let", true); + __m.insert("return", true); + __m.insert("match", true); + __m.insert("if", true); + __m.insert("then", true); + __m.insert("else", true); + __m.insert("for", true); + __m.insert("in", true); + __m.insert("where", true); + __m.insert("with", true); + __m.insert("true", true); + __m.insert("false", true); + __m.insert("none", true); + __m.insert("null", true); + __m.insert("acquire", true); + __m.insert("release", true); + __m.insert("capability", true); + __m.insert("operation", true); + __m.insert("input", true); + __m.insert("output", true); + __m.insert("idempotent", true); + __m.insert("readonly", true); + __m.insert("hermetic", true); Rc::new(__m) }; } @@ -171,12 +171,12 @@ pub fn dag_non_name_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), true); - __m.insert("false".to_string(), true); - __m.insert("none".to_string(), true); - __m.insert("null".to_string(), true); - __m.insert("acquire".to_string(), true); - __m.insert("release".to_string(), true); + __m.insert("true", true); + __m.insert("false", true); + __m.insert("none", true); + __m.insert("null", true); + __m.insert("acquire", true); + __m.insert("release", true); Rc::new(__m) }; } @@ -292,20 +292,20 @@ pub fn v3_supported_dag_operators() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("||".to_string(), true); - __m.insert("&&".to_string(), true); - __m.insert("==".to_string(), true); - __m.insert("!=".to_string(), true); - __m.insert("<".to_string(), true); - __m.insert(">".to_string(), true); - __m.insert("<=".to_string(), true); - __m.insert(">=".to_string(), true); - __m.insert("+".to_string(), true); - __m.insert("-".to_string(), true); - __m.insert("*".to_string(), true); - __m.insert("/".to_string(), true); - __m.insert("|>".to_string(), true); - __m.insert(".".to_string(), true); + __m.insert("||", true); + __m.insert("&&", true); + __m.insert("==", true); + __m.insert("!=", true); + __m.insert("<", true); + __m.insert(">", true); + __m.insert("<=", true); + __m.insert(">=", true); + __m.insert("+", true); + __m.insert("-", true); + __m.insert("*", true); + __m.insert("/", true); + __m.insert("|>", true); + __m.insert(".", true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_go_emit.rs b/src/v1/stage0/src/extdeps_languages_go_emit.rs index 1ea6c48a70c..d70276eeb64 100644 --- a/src/v1/stage0/src/extdeps_languages_go_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_go_emit.rs @@ -15,13 +15,13 @@ pub fn go_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "true".to_string()); - __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "nil".to_string()); - __m.insert("and".to_string(), "&&".to_string()); - __m.insert("or".to_string(), "||".to_string()); - __m.insert("not".to_string(), "!".to_string()); - __m.insert("div".to_string(), "/".to_string()); + __m.insert("true", "true".to_string()); + __m.insert("false", "false".to_string()); + __m.insert("null", "nil".to_string()); + __m.insert("and", "&&".to_string()); + __m.insert("or", "||".to_string()); + __m.insert("not", "!".to_string()); + __m.insert("div", "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn go_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "[]{0}".to_string()); - __m.insert("set".to_string(), "map[{0}]struct{}".to_string()); - __m.insert("optional".to_string(), "*{0}".to_string()); - __m.insert("map".to_string(), "map[{0}]{1}".to_string()); - __m.insert("free_monoid".to_string(), "[]{0}".to_string()); - __m.insert("partial_function".to_string(), "map[{0}]{1}".to_string()); - __m.insert("boolean_algebra".to_string(), "bool".to_string()); + __m.insert("list", "[]{0}".to_string()); + __m.insert("set", "map[{0}]struct{}".to_string()); + __m.insert("optional", "*{0}".to_string()); + __m.insert("map", "map[{0}]{1}".to_string()); + __m.insert("free_monoid", "[]{0}".to_string()); + __m.insert("partial_function", "map[{0}]{1}".to_string()); + __m.insert("boolean_algebra", "bool".to_string()); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_python_emit.rs b/src/v1/stage0/src/extdeps_languages_python_emit.rs index 383495ab200..b9f572e1896 100644 --- a/src/v1/stage0/src/extdeps_languages_python_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_python_emit.rs @@ -15,13 +15,13 @@ pub fn python_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "True".to_string()); - __m.insert("false".to_string(), "False".to_string()); - __m.insert("null".to_string(), "None".to_string()); - __m.insert("and".to_string(), "and".to_string()); - __m.insert("or".to_string(), "or".to_string()); - __m.insert("not".to_string(), "not ".to_string()); - __m.insert("div".to_string(), "//".to_string()); + __m.insert("true", "True".to_string()); + __m.insert("false", "False".to_string()); + __m.insert("null", "None".to_string()); + __m.insert("and", "and".to_string()); + __m.insert("or", "or".to_string()); + __m.insert("not", "not ".to_string()); + __m.insert("div", "//".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn python_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "list[{0}]".to_string()); - __m.insert("set".to_string(), "set[{0}]".to_string()); - __m.insert("optional".to_string(), "Optional[{0}]".to_string()); - __m.insert("map".to_string(), "dict[{0}, {1}]".to_string()); - __m.insert("free_monoid".to_string(), "list[{0}]".to_string()); - __m.insert("partial_function".to_string(), "dict[{0}, {1}]".to_string()); - __m.insert("boolean_algebra".to_string(), "bool".to_string()); + __m.insert("list", "list[{0}]".to_string()); + __m.insert("set", "set[{0}]".to_string()); + __m.insert("optional", "Optional[{0}]".to_string()); + __m.insert("map", "dict[{0}, {1}]".to_string()); + __m.insert("free_monoid", "list[{0}]".to_string()); + __m.insert("partial_function", "dict[{0}, {1}]".to_string()); + __m.insert("boolean_algebra", "bool".to_string()); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index 113a676ad25..29759774f9e 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -258,3 +258,6 @@ pub fn python_cast_syntax() -> Rc { } CACHED.with(|c: &Rc| c.clone()) } + +pub struct DynamicType; +pub struct AnnotatedType; diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index 1892d93af82..77ab9b3334f 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -15,13 +15,13 @@ pub fn rust_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "true".to_string()); - __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "None".to_string()); - __m.insert("and".to_string(), "&&".to_string()); - __m.insert("or".to_string(), "||".to_string()); - __m.insert("not".to_string(), "!".to_string()); - __m.insert("div".to_string(), "/".to_string()); + __m.insert("true", "true".to_string()); + __m.insert("false", "false".to_string()); + __m.insert("null", "None".to_string()); + __m.insert("and", "&&".to_string()); + __m.insert("or", "||".to_string()); + __m.insert("not", "!".to_string()); + __m.insert("div", "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn rust_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "Vec<{0}>".to_string()); - __m.insert("set".to_string(), "std::collections::BTreeSet<{0}>".to_string()); - __m.insert("optional".to_string(), "Option<{0}>".to_string()); - __m.insert("map".to_string(), "HashMap<{0}, {1}>".to_string()); - __m.insert("free_monoid".to_string(), "Vec<{0}>".to_string()); - __m.insert("partial_function".to_string(), "HashMap<{0}, {1}>".to_string()); - __m.insert("boolean_algebra".to_string(), "bool".to_string()); + __m.insert("list", "Vec<{0}>".to_string()); + __m.insert("set", "std::collections::BTreeSet<{0}>".to_string()); + __m.insert("optional", "Option<{0}>".to_string()); + __m.insert("map", "HashMap<{0}, {1}>".to_string()); + __m.insert("free_monoid", "Vec<{0}>".to_string()); + __m.insert("partial_function", "HashMap<{0}, {1}>".to_string()); + __m.insert("boolean_algebra", "bool".to_string()); Rc::new(__m) }; } @@ -497,7 +497,7 @@ pub fn rt_bridge_function_names() -> Rc> { Rc::new({ let mut __result = Vec::new(); for f in rt_function_registry().iter().cloned() { - if (f.name.clone().as_str() != f.bridge_name.clone().as_str()) { + if (f.name.clone() != f.bridge_name.clone()) { __result.push(f); } } diff --git a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs index a9ef8cc021c..2851575009e 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs @@ -113,10 +113,10 @@ pub fn rust_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert("true", Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert("false", Rc::new(LiteralValue::LitBool { value: false, })); Rc::new(__m) @@ -129,43 +129,43 @@ pub fn rust_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("fn".to_string(), true); - __m.insert("struct".to_string(), true); - __m.insert("enum".to_string(), true); - __m.insert("type".to_string(), true); - __m.insert("trait".to_string(), true); - __m.insert("impl".to_string(), true); - __m.insert("const".to_string(), true); - __m.insert("static".to_string(), true); - __m.insert("mod".to_string(), true); - __m.insert("use".to_string(), true); - __m.insert("let".to_string(), true); - __m.insert("mut".to_string(), true); - __m.insert("return".to_string(), true); - __m.insert("match".to_string(), true); - __m.insert("if".to_string(), true); - __m.insert("else".to_string(), true); - __m.insert("for".to_string(), true); - __m.insert("in".to_string(), true); - __m.insert("while".to_string(), true); - __m.insert("loop".to_string(), true); - __m.insert("break".to_string(), true); - __m.insert("continue".to_string(), true); - __m.insert("pub".to_string(), true); - __m.insert("self".to_string(), true); - __m.insert("super".to_string(), true); - __m.insert("crate".to_string(), true); - __m.insert("as".to_string(), true); - __m.insert("where".to_string(), true); - __m.insert("ref".to_string(), true); - __m.insert("move".to_string(), true); - __m.insert("async".to_string(), true); - __m.insert("await".to_string(), true); - __m.insert("dyn".to_string(), true); - __m.insert("unsafe".to_string(), true); - __m.insert("extern".to_string(), true); - __m.insert("true".to_string(), true); - __m.insert("false".to_string(), true); + __m.insert("fn", true); + __m.insert("struct", true); + __m.insert("enum", true); + __m.insert("type", true); + __m.insert("trait", true); + __m.insert("impl", true); + __m.insert("const", true); + __m.insert("static", true); + __m.insert("mod", true); + __m.insert("use", true); + __m.insert("let", true); + __m.insert("mut", true); + __m.insert("return", true); + __m.insert("match", true); + __m.insert("if", true); + __m.insert("else", true); + __m.insert("for", true); + __m.insert("in", true); + __m.insert("while", true); + __m.insert("loop", true); + __m.insert("break", true); + __m.insert("continue", true); + __m.insert("pub", true); + __m.insert("self", true); + __m.insert("super", true); + __m.insert("crate", true); + __m.insert("as", true); + __m.insert("where", true); + __m.insert("ref", true); + __m.insert("move", true); + __m.insert("async", true); + __m.insert("await", true); + __m.insert("dyn", true); + __m.insert("unsafe", true); + __m.insert("extern", true); + __m.insert("true", true); + __m.insert("false", true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_rust_types.rs b/src/v1/stage0/src/extdeps_languages_rust_types.rs index eb83a073861..7daf897f12a 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_types.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_types.rs @@ -216,3 +216,11 @@ pub fn serde_rename_template() -> String { } CACHED.with(|c: &String| c.clone()) } + +pub struct Owned; +pub struct SharedRef; +pub struct MutRef; +pub struct RawPtr; +pub struct BoxPtr; +pub struct RcPtr; +pub struct ArcPtr; diff --git a/src/v1/stage0/src/extdeps_version_semver.rs b/src/v1/stage0/src/extdeps_version_semver.rs index 9091502c1d9..44a9c9a0703 100644 --- a/src/v1/stage0/src/extdeps_version_semver.rs +++ b/src/v1/stage0/src/extdeps_version_semver.rs @@ -141,16 +141,14 @@ pub fn semver_compare(a: Rc, b: Rc) -> Ordering { } } -pub fn semver_identifier_label(id: Rc) -> Rc> { +pub fn semver_identifier_label(id: Rc) -> String { match (*id).clone() { - SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => { - crate::v2_std_text::host_string_text_from_rust_host(format!("{}", v.clone())) - } + SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => format!("{}", v.clone()), SemVerIdentifier::SemVerAlphanumericIdentifier { label: s, .. } => s.clone(), } } -pub fn semver_identifiers_label(ids: Rc>>) -> Rc> { +pub fn semver_identifiers_label(ids: Rc>>) -> String { Rc::new({ let mut __result = Vec::new(); for id in ids.iter().cloned() { @@ -161,22 +159,15 @@ pub fn semver_identifiers_label(ids: Rc>>) -> Rc) -> Rc> { +pub fn semver_version_label(v: Rc) -> String { { let core = v1_rt::concat( - crate::v2_std_text::host_string_text_from_rust_host((v.major.clone()).to_string()), + (v.major.clone()).to_string(), v1_rt::concat( ".".to_string(), v1_rt::concat( - crate::v2_std_text::host_string_text_from_rust_host( - (v.minor.clone()).to_string(), - ), - v1_rt::concat( - ".".to_string(), - crate::v2_std_text::host_string_text_from_rust_host( - (v.patch.clone()).to_string(), - ), - ), + (v.minor.clone()).to_string(), + v1_rt::concat(".".to_string(), (v.patch.clone()).to_string()), ), ), ); diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index 7383cb17be5..1c9d2294e11 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -15,6 +15,7 @@ pub mod cli_run; pub mod coproduct_reflection; pub mod extdeps_cargo; +pub mod extdeps_cargo_version; pub mod extdeps_languages_dag_emit; pub mod extdeps_languages_dag_syntax; pub mod extdeps_languages_dag_types; @@ -28,9 +29,10 @@ pub mod extdeps_languages_rust_emit; pub mod extdeps_languages_rust_syntax; pub mod extdeps_languages_rust_types; pub mod extdeps_shape_transport_policy_project; +pub mod extdeps_version; +pub mod extdeps_version_semver; pub mod fact_cardinality_census; pub mod import_resolution_project; -pub mod languages_consumer_census; pub mod layering_imports_project; pub mod module_path_index; pub mod recorded_fixture; @@ -39,14 +41,26 @@ pub mod rest_transport_facts; pub mod std_algebra; pub mod std_coercion; pub mod std_computation; +pub mod std_constructors; pub mod std_effects; pub mod std_emit_model; pub mod std_error_primitives; pub mod std_graph; pub mod std_http_path; pub mod std_induction; +pub mod std_integer; pub mod std_iteration; +pub mod std_lens_verdict; +pub mod std_list; +pub mod std_logic; +pub mod std_machine_constraints; +pub mod std_magnitude; +pub mod std_measure; +pub mod std_nat; pub mod std_node; +pub mod std_pareto; +pub mod std_realization_schedule; +pub mod std_serialization; pub mod std_syntax; pub mod std_termination; pub mod std_types; diff --git a/src/v1/stage0/src/main.rs b/src/v1/stage0/src/main.rs index 5817bef1c05..52ee2e54b0b 100644 --- a/src/v1/stage0/src/main.rs +++ b/src/v1/stage0/src/main.rs @@ -44,8 +44,6 @@ enum Commands { #[arg(long, default_value = "rust")] target: String, }, - /// Run repo CI from CiSpec (delegates to dsl/tools/gunbc_ci.dag) - Ci, /// Execute a .dag program directly (interpreter) Run { /// Source root directories (searched recursively for .dag files) @@ -386,10 +384,6 @@ fn main() { } } - Commands::Ci {} => { - cli_run::handle_ci(); - } - Commands::Run { source_roots, function, diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index e4beb0a704e..ff9a47c3c49 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -55,6 +55,12 @@ pub struct AbelianGroup { pub inverse: Rc T>, } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct GroupCompletion(pub std::marker::PhantomData); + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct FieldOfFractions(pub std::marker::PhantomData); + #[derive(Clone)] pub struct Semiring { pub add: Rc T>, @@ -278,13 +284,13 @@ pub fn kernel_algebra_profile() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("Int".to_string(), AlgebraProfile::OrderedRingProfile); - __m.insert("Float".to_string(), AlgebraProfile::ApproximateFieldProfile); - __m.insert("Bool".to_string(), AlgebraProfile::BooleanAlgebraProfile); - __m.insert("String".to_string(), AlgebraProfile::FreeMonoidScalarProfile); - __m.insert("List".to_string(), AlgebraProfile::FreeMonoidCollectionProfile); - __m.insert("Set".to_string(), AlgebraProfile::BooleanAlgebraCollectionProfile); - __m.insert("Map".to_string(), AlgebraProfile::PartialFunctionProfile); + __m.insert("Int", AlgebraProfile::OrderedRingProfile); + __m.insert("Float", AlgebraProfile::ApproximateFieldProfile); + __m.insert("Bool", AlgebraProfile::BooleanAlgebraProfile); + __m.insert("String", AlgebraProfile::FreeMonoidScalarProfile); + __m.insert("List", AlgebraProfile::FreeMonoidCollectionProfile); + __m.insert("Set", AlgebraProfile::BooleanAlgebraCollectionProfile); + __m.insert("Map", AlgebraProfile::PartialFunctionProfile); Rc::new(__m) }; } @@ -1416,3 +1422,21 @@ pub fn algebra_type_param_names(profile: AlgebraProfile) -> Rc> { AlgebraProfile::PartialFunctionProfile => Rc::new(vec!["K".to_string(), "V".to_string()]), } } + +pub struct Less; +pub struct Equal; +pub struct Greater; +pub struct OrderedRingProfile; +pub struct ApproximateFieldProfile; +pub struct BooleanAlgebraProfile; +pub struct BooleanAlgebraCollectionProfile; +pub struct FreeMonoidScalarProfile; +pub struct FreeMonoidCollectionProfile; +pub struct PartialFunctionProfile; +pub struct ShrinkEffect; +pub struct ProjectionEffect; +pub struct IdentityEffect; +pub struct ShapeConstant; +pub struct ShapeLinearScan; +pub struct ShapeIterateBody; +pub struct ShapeSortBody; diff --git a/src/v1/stage0/src/std_coercion.rs b/src/v1/stage0/src/std_coercion.rs index 861c5852c1a..4a100a0218e 100644 --- a/src/v1/stage0/src/std_coercion.rs +++ b/src/v1/stage0/src/std_coercion.rs @@ -63,8 +63,8 @@ pub fn dag_can_cast(source_type: String, target_type: String) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((r.from_type.clone().as_str() == source_type.clone().as_str()) - && (r.to_type.clone().as_str() == target_type.clone().as_str())) + if ((r.from_type.clone() == source_type.clone()) + && (r.to_type.clone() == target_type.clone())) { __found = true; break; @@ -78,9 +78,7 @@ pub fn is_dag_cast_domain_type(name: String) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((r.from_type.clone().as_str() == name.clone().as_str()) - || (r.to_type.clone().as_str() == name.clone().as_str())) - { + if ((r.from_type.clone() == name.clone()) || (r.to_type.clone() == name.clone())) { __found = true; break; } diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 2337843f5b2..89e297efc72 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -233,7 +233,7 @@ pub fn algebra_profile_to_dimension(profile: AlgebraProfile) -> Option Option { - if (type_name.clone().as_str() == "Node".to_string().as_str()) { + if (type_name.clone() == "Node".to_string()) { Some(IterationDimension::TreeDescent) } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { @@ -242,3 +242,10 @@ pub fn type_iteration_dimension(type_name: String) -> Option } } } + +pub struct Fold; +pub struct Descend; +pub struct Repeat; +pub struct TreeDescent; +pub struct CollectionFold; +pub struct ArithmeticRepeat; diff --git a/src/v1/stage0/src/std_constructors.rs b/src/v1/stage0/src/std_constructors.rs index e9409846f87..243c28a84ef 100644 --- a/src/v1/stage0/src/std_constructors.rs +++ b/src/v1/stage0/src/std_constructors.rs @@ -11,11 +11,14 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type Product = Product; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Product(pub std::marker::PhantomData<()>); -pub type Coproduct = Coproduct; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Coproduct(pub std::marker::PhantomData<()>); -pub type Phantom = Phantom; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Phantom(pub std::marker::PhantomData<()>); #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, diff --git a/src/v1/stage0/src/std_effects.rs b/src/v1/stage0/src/std_effects.rs index 1e870d01f38..df954565fcc 100644 --- a/src/v1/stage0/src/std_effects.rs +++ b/src/v1/stage0/src/std_effects.rs @@ -11,8 +11,9 @@ use self::ModifierAgreement::*; use crate::std_http_path::PathTemplateParseResult::{MalformedPathTemplate, ParsedPathTemplate}; pub use crate::std_http_path::{has_path_params, last_path_param, parse_path_template}; pub use crate::std_http_path::{PathTemplate, PathTemplateParseResult}; -pub use crate::std_types::HttpMethod; +pub use crate::std_realization_schedule::string_list_eq; use crate::std_types::HttpMethod::{DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT}; +pub use crate::std_types::{HttpMethod, List}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -95,18 +96,18 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { } } -pub fn key_source_eq(a: Rc, b: Rc) -> bool { - match (*a).clone() { - KeySource::PathParam { param: pa, .. } => match (*b).clone() { - KeySource::PathParam { param: pb, .. } => (pa.clone().as_str() == pb.clone().as_str()), +pub fn key_source_eq(left: Rc, right: Rc) -> bool { + match (*left).clone() { + KeySource::PathParam { param: pa, .. } => match (*right).clone() { + KeySource::PathParam { param: pb, .. } => (pa.clone() == pb.clone()), _ => false, }, - KeySource::InputField { field: fa, .. } => match (*b).clone() { - KeySource::InputField { field: fb, .. } => (fa.clone().as_str() == fb.clone().as_str()), + KeySource::InputField { field: fa, .. } => match (*right).clone() { + KeySource::InputField { field: fb, .. } => (fa.clone() == fb.clone()), _ => false, }, - KeySource::CompositeKey { fields: fa, .. } => match (*b).clone() { - KeySource::CompositeKey { fields: fb, .. } => (fa.clone() == fb.clone()), + KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { + KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa.clone(), fb.clone()), _ => false, }, } @@ -307,16 +308,14 @@ pub fn check_modifier_vs_derivation( } else { if (declared_idempotent.clone() && !derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { - CreateCause::PostAlways => Rc::new(ModifierAgreement::DerivationUnknown { - reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared" - .to_string(), - }), - CreateCause::CreateIfAbsent { .. } => Rc::new(ModifierAgreement::Disagrees { - reason: "derivation says non-idempotent but modifier declares idempotent" - .to_string(), - }), - }, + EffectShape::CreateEffect { ref cause, .. } => { + let CreateCause::PostAlways = cause.as_ref() else { + unreachable!() + }; + Rc::new(ModifierAgreement::DerivationUnknown { + reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared".to_string(), +}) + } _ => Rc::new(ModifierAgreement::Disagrees { reason: "derivation says non-idempotent but modifier declares idempotent" .to_string(), @@ -325,15 +324,18 @@ pub fn check_modifier_vs_derivation( } else { if (!declared_idempotent.clone() && derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { - CreateCause::CreateIfAbsent { .. } => { - Rc::new(ModifierAgreement::Disagrees { - reason: "create-if-absent has proven identity but modifier declares non-idempotent" - .to_string(), - }) - } - CreateCause::PostAlways => Rc::new(ModifierAgreement::Agrees), - }, + EffectShape::CreateEffect { ref cause, .. } => { + let CreateCause::CreateIfAbsent { + key_source: key_source, + .. + } = cause.as_ref() + else { + unreachable!() + }; + Rc::new(ModifierAgreement::Disagrees { + reason: "create-if-absent has proven identity but modifier declares non-idempotent".to_string(), +}) + } _ => Rc::new(ModifierAgreement::Agrees), } } else { diff --git a/src/v1/stage0/src/std_emit_model.rs b/src/v1/stage0/src/std_emit_model.rs index 5bd6eebf3a1..7723800d50e 100644 --- a/src/v1/stage0/src/std_emit_model.rs +++ b/src/v1/stage0/src/std_emit_model.rs @@ -2,6 +2,7 @@ // Source module: std.emit_model use self::PlaceholderConvention::*; +pub use crate::std_serialization::DeclarationRef; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -11,8 +12,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type DeclarationRef = String; - #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, )] @@ -37,3 +36,6 @@ pub struct MethodTemplateContract { pub wraps_result: bool, pub placeholder_convention: PlaceholderConvention, } + +pub struct IndexedArgs; +pub struct NamedArg; diff --git a/src/v1/stage0/src/std_error_primitives.rs b/src/v1/stage0/src/std_error_primitives.rs index e0c45702a3b..b6cf7b7a27a 100644 --- a/src/v1/stage0/src/std_error_primitives.rs +++ b/src/v1/stage0/src/std_error_primitives.rs @@ -29,3 +29,6 @@ pub enum DivError { DivideByZero, Overflow, } + +pub struct DivideByZero; +pub struct Overflow; diff --git a/src/v1/stage0/src/std_graph.rs b/src/v1/stage0/src/std_graph.rs index 0a335410820..5d20b69f286 100644 --- a/src/v1/stage0/src/std_graph.rs +++ b/src/v1/stage0/src/std_graph.rs @@ -66,7 +66,7 @@ pub fn build_call_graph_from_proof_edges( for e in Rc::new({ let mut __result = Vec::new(); for e in edges.iter().cloned() { - if (e.caller.clone().as_str() != e.callee.clone().as_str()) { + if (e.caller.clone() != e.callee.clone()) { __result.push(e); } } @@ -292,7 +292,7 @@ pub fn is_valid_proof(proof: Rc, edges: Rc>> let has_self_cycle = { let mut __found = false; for e in non_descending.clone().iter().cloned() { - if (e.caller.clone().as_str() == e.callee.clone().as_str()) { + if (e.caller.clone() == e.callee.clone()) { __found = true; break; } diff --git a/src/v1/stage0/src/std_http_path.rs b/src/v1/stage0/src/std_http_path.rs index f5dd9a50bec..94fd4468f89 100644 --- a/src/v1/stage0/src/std_http_path.rs +++ b/src/v1/stage0/src/std_http_path.rs @@ -70,7 +70,7 @@ pub fn parse_path_template(raw: String) -> Rc { .iter() .cloned() { - if (s.clone().as_str() != "".to_string().as_str()) { + if (s.clone() != "".to_string()) { __result.push(s); } } @@ -227,28 +227,28 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let prefix_tokens = if (prefix.clone().as_str() != "".to_string().as_str()) { + let prefix_tokens = if (prefix.clone() != "".to_string()) { Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { text: prefix.clone(), })]) } else { Rc::new(vec![]) }; - let param_tokens = if (param_name.clone().as_str() != "".to_string().as_str()) { + let param_tokens = if (param_name.clone() != "".to_string()) { Rc::new(vec![Rc::new(UrlPathToken::ParamToken { name: param_name.clone(), })]) } else { Rc::new(vec![]) }; - let suffix_tokens = if (suffix.clone().as_str() != "".to_string().as_str()) { + let suffix_tokens = if (suffix.clone() != "".to_string()) { Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { text: suffix.clone(), })]) } else { Rc::new(vec![]) }; - if (((param_name.clone().as_str() == "".to_string().as_str()) + if (((param_name.clone() == "".to_string()) || v1_rt::contains(suffix.clone(), "{".to_string())) || v1_rt::contains(suffix.clone(), "}".to_string())) { diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index 5fecbc40044..3457a8f1cb8 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -84,11 +84,11 @@ pub fn recursion_shape_eq(a: RecursionShape, b: RecursionShape) -> bool { } pub fn inductive_field_eq(a: Rc, b: Rc) -> bool { - (((((a.type_name.clone().as_str() == b.type_name.clone().as_str()) - && (a.variant_name.clone().as_str() == b.variant_name.clone().as_str())) - && (a.field_name.clone().as_str() == b.field_name.clone().as_str())) + (((((a.type_name.clone() == b.type_name.clone()) + && (a.variant_name.clone() == b.variant_name.clone())) + && (a.field_name.clone() == b.field_name.clone())) && recursion_shape_eq(a.shape.clone(), b.shape.clone())) - && (a.element_type.clone().as_str() == b.element_type.clone().as_str())) + && (a.element_type.clone() == b.element_type.clone())) } pub fn inductive_field_to_dimension( @@ -193,10 +193,7 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) param: pb, factor: fac_b, .. - } => { - ((pa.clone().as_str() == pb.clone().as_str()) - && shrink_factor_eq(fac_a.clone(), fac_b.clone())) - } + } => ((pa.clone() == pb.clone()) && shrink_factor_eq(fac_a.clone(), fac_b.clone())), _ => false, }, SubValueRelation::PreservedValue => match (*b).clone() { @@ -1102,3 +1099,9 @@ pub fn bellman_ford_bound() -> Rc { pub fn floyd_warshall_bound() -> Rc { cost_poly("V".to_string(), 3) } + +pub struct DirectRecursion; +pub struct ListRecursion; +pub struct OptionalRecursion; +pub struct SetRecursion; +pub struct MapValueRecursion; diff --git a/src/v1/stage0/src/std_integer.rs b/src/v1/stage0/src/std_integer.rs index ba1296928e7..4172d1f193b 100644 --- a/src/v1/stage0/src/std_integer.rs +++ b/src/v1/stage0/src/std_integer.rs @@ -13,33 +13,49 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type Int8 = crate::std_machine_constraints::Compose; +pub type Int8 = + crate::std_machine_constraints::Compose; -pub type Int16 = crate::std_machine_constraints::Compose; +pub type Int16 = + crate::std_machine_constraints::Compose; -pub type Int32 = crate::std_machine_constraints::Compose; +pub type Int32 = + crate::std_machine_constraints::Compose; -pub type Int64 = crate::std_machine_constraints::Compose; +pub type Int64 = + crate::std_machine_constraints::Compose; -pub type Int128 = crate::std_machine_constraints::Compose; +pub type Int128 = + crate::std_machine_constraints::Compose; -pub type UInt8 = crate::std_machine_constraints::Compose; +pub type UInt8 = + crate::std_machine_constraints::Compose; -pub type UInt16 = crate::std_machine_constraints::Compose; +pub type UInt16 = + crate::std_machine_constraints::Compose; -pub type UInt32 = crate::std_machine_constraints::Compose; +pub type UInt32 = + crate::std_machine_constraints::Compose; -pub type UInt64 = crate::std_machine_constraints::Compose; +pub type UInt64 = + crate::std_machine_constraints::Compose; -pub type UInt128 = crate::std_machine_constraints::Compose; +pub type UInt128 = + crate::std_machine_constraints::Compose; pub type Int = Rc>>; pub type UInt = Nat; -pub type IntPlatform = crate::std_machine_constraints::Compose; +pub type IntPlatform = crate::std_machine_constraints::Compose< + Int, + crate::std_machine_constraints::MachineWidth, +>; -pub type UIntPlatform = crate::std_machine_constraints::Compose; +pub type UIntPlatform = crate::std_machine_constraints::Compose< + UInt, + crate::std_machine_constraints::MachineWidth, +>; pub type NonNegativeInt = Nat; diff --git a/src/v1/stage0/src/std_lens_verdict.rs b/src/v1/stage0/src/std_lens_verdict.rs index 18fcf31e98d..6b17a792825 100644 --- a/src/v1/stage0/src/std_lens_verdict.rs +++ b/src/v1/stage0/src/std_lens_verdict.rs @@ -15,10 +15,10 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum LensVerdictLocus { - ModuleWholeFile { module_name: Rc> }, + ModuleWholeFile { module_name: String }, } impl LensVerdictLocus { - pub fn module_name(&self) -> Rc> { + pub fn module_name(&self) -> String { match self { LensVerdictLocus::ModuleWholeFile { module_name: __val, .. @@ -29,7 +29,7 @@ impl LensVerdictLocus { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct LensVerdictDiagnostic { - pub reason: Rc>, + pub reason: String, pub at: Rc, } diff --git a/src/v1/stage0/src/std_machine_constraints.rs b/src/v1/stage0/src/std_machine_constraints.rs index da534ba34c5..ea8dd6edf88 100644 --- a/src/v1/stage0/src/std_machine_constraints.rs +++ b/src/v1/stage0/src/std_machine_constraints.rs @@ -11,4 +11,10 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type PointerWidth = PointerWidth; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct MachineWidth(pub std::marker::PhantomData); + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct PointerWidth(pub std::marker::PhantomData<()>); + +pub type Compose = Phantom; diff --git a/src/v1/stage0/src/std_magnitude.rs b/src/v1/stage0/src/std_magnitude.rs index d59e2d0a7ed..f923d48ec6b 100644 --- a/src/v1/stage0/src/std_magnitude.rs +++ b/src/v1/stage0/src/std_magnitude.rs @@ -10,4 +10,5 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type Magnitude = Magnitude; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Magnitude(pub std::marker::PhantomData<()>); diff --git a/src/v1/stage0/src/std_measure.rs b/src/v1/stage0/src/std_measure.rs index fc11b1971d3..54822d2ae06 100644 --- a/src/v1/stage0/src/std_measure.rs +++ b/src/v1/stage0/src/std_measure.rs @@ -28,6 +28,8 @@ pub enum Quantity { Count, Currency, Power, + Temperature, + RotationalSpeed, ElectricPotential, ElectricCurrent, Resistance, @@ -83,14 +85,29 @@ pub fn scale_exponent(s: Scale) -> i64 { } } -pub fn memory_scale_factor_bytes(s: Scale) -> Nat { +pub fn gibibyte_scale_factor_bytes() -> Nat { + 1073741824 +} + +pub fn memory_scale_factor_bytes(s: Scale) -> Option { match s { - Scale::One => 1, - Scale::Kibi => 1024, - Scale::Mebi => 1048576, - Scale::Gibi => 1073741824, - Scale::Tebi => 1099511627776, - _ => 1, + Scale::One => Some(1), + Scale::Kibi => Some(1024), + Scale::Mebi => Some(1048576), + Scale::Gibi => Some(gibibyte_scale_factor_bytes()), + Scale::Tebi => Some(1099511627776), + Scale::Atto => None, + Scale::Femto => None, + Scale::Pico => None, + Scale::Nano => None, + Scale::Micro => None, + Scale::Milli => None, + Scale::Kilo => None, + Scale::Mega => None, + Scale::Giga => None, + Scale::Tera => None, + Scale::Peta => None, + Scale::Exa => None, } } @@ -122,7 +139,7 @@ pub fn gibibyte_count(g: Gibibyte) -> Nat { } pub fn gibibyte_to_byte_size(g: Gibibyte) -> ByteSize { - byte_size((gibibyte_count(g) * memory_scale_factor_bytes(Scale::Gibi))) + byte_size((gibibyte_count(g) * gibibyte_scale_factor_bytes())) } pub type BitWidth = Rc>; @@ -133,6 +150,10 @@ pub type HardwareThreadCount = Rc>; pub type Watt = Rc>; +pub type Celsius = Rc>; + +pub type RevolutionsPerMinute = Rc>; + pub fn watt(count: Nat) -> Watt { Watt { count: count } } @@ -141,9 +162,25 @@ pub fn watt_count(w: Watt) -> Nat { compile_error!("field access missing reconcile summary for 'count'") } +pub fn celsius(count: i64) -> Celsius { + Celsius { count: count } +} + +pub fn celsius_count(c: Celsius) -> i64 { + compile_error!("field access missing reconcile summary for 'count'") +} + +pub fn rpm(count: Nat) -> RevolutionsPerMinute { + RevolutionsPerMinute { count: count } +} + +pub fn rpm_count(r: RevolutionsPerMinute) -> Nat { + compile_error!("field access missing reconcile summary for 'count'") +} + pub type MoneyAmount = Rc>; -pub type MoneyAmountMicro = MoneyAmount; +pub type MoneyAmountMicro = MoneyAmount; pub fn money_amount_micro(count: Nat) -> MoneyAmountMicro { MoneyAmountMicro { count: count } @@ -195,6 +232,8 @@ pub struct Frequency; pub struct Count; pub struct Currency; pub struct Power; +pub struct Temperature; +pub struct RotationalSpeed; pub struct ElectricPotential; pub struct ElectricCurrent; pub struct Resistance; diff --git a/src/v1/stage0/src/std_node.rs b/src/v1/stage0/src/std_node.rs index 7ca1fbee5f6..ea6f2590918 100644 --- a/src/v1/stage0/src/std_node.rs +++ b/src/v1/stage0/src/std_node.rs @@ -105,10 +105,10 @@ pub fn compiler_recursive_types() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("Node".to_string(), true); - __m.insert("InferredNode".to_string(), true); - __m.insert("MatchPattern".to_string(), true); - __m.insert("MethodSemantics".to_string(), true); + __m.insert("Node", true); + __m.insert("InferredNode", true); + __m.insert("MatchPattern", true); + __m.insert("MethodSemantics", true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/std_realization_schedule.rs b/src/v1/stage0/src/std_realization_schedule.rs index 488dce36b7d..b393812624e 100644 --- a/src/v1/stage0/src/std_realization_schedule.rs +++ b/src/v1/stage0/src/std_realization_schedule.rs @@ -70,16 +70,16 @@ pub struct RealizationObjective { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ScheduleWitnessEntry { - pub entry: Rc>, - pub function: Rc>, + pub entry: String, + pub function: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum Runnable { RunnableSingleClaim { - entry: Rc>, - function: Rc>, + entry: String, + function: String, }, RunnableDiscoveryBatch { source_roots: Rc>, @@ -99,24 +99,19 @@ pub struct RealizationPlan { pub total: Rc>, } -pub fn runnable_step_label(r: Rc) -> Rc> { +pub fn runnable_step_label(r: Rc) -> String { match (*r).clone() { Runnable::RunnableSingleClaim { function: f, .. } => f.clone(), Runnable::RunnableDiscoveryBatch { .. } => "__discovery_corpus__".to_string(), } } -pub fn schedule_batch_contains_label( - batch: Rc>>, - target: Rc>, -) -> bool { +pub fn schedule_batch_contains_label(batch: Rc>>, target: String) -> bool { batch .iter() .cloned() .fold(false, |acc: bool, r: Rc| { - (acc || (crate::v2_std_text::host_string_text_to_rust_host(runnable_step_label( - r.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(target.clone()))) + (acc || (runnable_step_label(r.clone()) == target.clone())) }) } @@ -124,12 +119,12 @@ pub fn schedule_batch_contains_label( #[serde(tag = "_variant")] pub enum ScheduleLensViolation { EmptySchedule, - CompileGateNotFirst { expected: Rc> }, + CompileGateNotFirst { expected: String }, CorpusBeforeCompile, SingleBatchOnly, } impl ScheduleLensViolation { - pub fn expected(&self) -> Rc> { + pub fn expected(&self) -> String { match self { ScheduleLensViolation::EmptySchedule => panic!("no expected on unit variant"), ScheduleLensViolation::CompileGateNotFirst { @@ -141,18 +136,18 @@ impl ScheduleLensViolation { } } -pub fn schedule_lens_module() -> Rc> { +pub fn schedule_lens_module() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "std.realization_schedule".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn schedule_lens_violation_diagnostic( kind: Rc, - compile_gate_fn: Rc>, + compile_gate_fn: String, ) -> Rc { { let at = Rc::new(LensVerdictLocus::ModuleWholeFile { @@ -183,7 +178,7 @@ pub fn schedule_lens_violation_diagnostic( pub fn schedule_lens_verdict_for_ci_floor( plan: Rc>, - compile_gate_fn: Rc>, + compile_gate_fn: String, ) -> Rc { if (plan.schedule.clone().length() == 0) { Rc::new(LensVerdict::Violation { @@ -263,10 +258,7 @@ pub fn schedule_generates_same_batch_count( } pub fn schedule_witness_entry_eq(a: Rc, b: Rc) -> bool { - ((crate::v2_std_text::host_string_text_to_rust_host(a.entry.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(b.entry.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(a.function.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(b.function.clone()))) + ((a.entry.clone() == b.entry.clone()) && (a.function.clone() == b.function.clone())) } pub fn string_list_eq(mut left: Rc>, mut right: Rc>) -> bool { @@ -340,12 +332,7 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { entry: re, function: rf, .. - } => { - ((crate::v2_std_text::host_string_text_to_rust_host(le.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(re.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(lf.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(rf.clone()))) - } + } => ((le.clone() == re.clone()) && (lf.clone() == rf.clone())), Runnable::RunnableDiscoveryBatch { .. } => false, }, Runnable::RunnableDiscoveryBatch { diff --git a/src/v1/stage0/src/std_serialization.rs b/src/v1/stage0/src/std_serialization.rs index 0fe9773c060..84dfcbfce2e 100644 --- a/src/v1/stage0/src/std_serialization.rs +++ b/src/v1/stage0/src/std_serialization.rs @@ -13,7 +13,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type DeclarationRef = Rc>; +pub type DeclarationRef = String; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] @@ -21,16 +21,9 @@ pub enum VariantNaming { AsAuthored, SnakeCase, ScreamingSnakeCase, - StripPrefixAndSnakeCase { - prefix: Rc>, - }, - StripSuffixAndSnakeCase { - suffix: Rc>, - }, - StripPrefixSuffixAndSnakeCase { - prefix: Rc>, - suffix: Rc>, - }, + StripPrefixAndSnakeCase { prefix: String }, + StripSuffixAndSnakeCase { suffix: String }, + StripPrefixSuffixAndSnakeCase { prefix: String, suffix: String }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -40,7 +33,7 @@ pub enum VariantEncoding { naming: Rc, }, InternallyTaggedObject { - tag_field: Rc>, + tag_field: String, naming: Rc, }, UntaggedVariant, diff --git a/src/v1/stage0/src/std_syntax.rs b/src/v1/stage0/src/std_syntax.rs index 019ae09f706..1e280cc963c 100644 --- a/src/v1/stage0/src/std_syntax.rs +++ b/src/v1/stage0/src/std_syntax.rs @@ -156,3 +156,39 @@ pub struct SyntaxSpec { pub keyword_literals: Rc>>, pub keyword_set: Rc>, } + +pub struct Add; +pub struct Sub; +pub struct Mul; +pub struct Div; +pub struct Mod; +pub struct Eq; +pub struct Ne; +pub struct Lt; +pub struct Gt; +pub struct Le; +pub struct Ge; +pub struct And; +pub struct Or; +pub struct NullCoalesce; +pub struct ExprBody; +pub struct BlockBody; +pub struct TypeBody; +pub struct ValueBody; +pub struct NoBody; +pub struct ServiceBody; +pub struct ResourceBody; +pub struct FuncForm; +pub struct StructForm; +pub struct EnumForm; +pub struct TypeAliasForm; +pub struct ModuleForm; +pub struct OtherForm; +pub struct AlgAdd; +pub struct AlgMul; +pub struct AlgReciprocal; +pub struct AlgQuotient; +pub struct AlgRemainder; +pub struct AlgCompare; +pub struct AlgMeet; +pub struct AlgJoin; diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 3c3f23e0a92..46d3e739ca9 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -256,3 +256,7 @@ pub struct ProofEdge { pub callee: String, pub evidence: Rc>, } + +pub struct Strict; +pub struct NonIncreasing; +pub struct DescentUnknown; diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index 1500f5a4251..b6fa5fa4992 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -22,14 +22,14 @@ pub fn kernel_type_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("String".to_string(), true); - __m.insert("Int".to_string(), true); - __m.insert("Bool".to_string(), true); - __m.insert("Float".to_string(), true); - __m.insert("Secret".to_string(), true); - __m.insert("Json".to_string(), true); - __m.insert("Unit".to_string(), true); - __m.insert("Bytes".to_string(), true); + __m.insert("String", true); + __m.insert("Int", true); + __m.insert("Bool", true); + __m.insert("Float", true); + __m.insert("Secret", true); + __m.insert("Json", true); + __m.insert("Unit", true); + __m.insert("Bytes", true); Rc::new(__m) }; } @@ -47,10 +47,10 @@ pub fn container_type_arity() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), 1); - __m.insert("Set".to_string(), 1); - __m.insert("Map".to_string(), 2); - __m.insert("Witness".to_string(), 1); + __m.insert("List", 1); + __m.insert("Set", 1); + __m.insert("Map", 2); + __m.insert("Witness", 1); Rc::new(__m) }; } @@ -69,7 +69,7 @@ pub fn container_expected_arity(name: String) -> Option { } pub fn container_param_names_for(kind_name: String) -> Rc> { - if (kind_name.clone().as_str() == "Witness".to_string().as_str()) { + if (kind_name.clone() == "Witness".to_string()) { Rc::new(vec!["T".to_string()]) } else { match v1_rt::map_get(&kernel_algebra_profile(), kind_name.clone()) { @@ -123,7 +123,7 @@ pub fn ordered_element_collections() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), true); + __m.insert("List", true); Rc::new(__m) }; } @@ -138,18 +138,18 @@ pub fn container_template_algebra_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), "FreeMonoid".to_string()); - __m.insert("list".to_string(), "FreeMonoid".to_string()); - __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("Map".to_string(), "PartialFunction".to_string()); - __m.insert("map".to_string(), "PartialFunction".to_string()); - __m.insert("FreeMonoid".to_string(), "FreeMonoid".to_string()); - __m.insert("free_monoid".to_string(), "FreeMonoid".to_string()); - __m.insert("BooleanAlgebra".to_string(), "BooleanAlgebra".to_string()); - __m.insert("boolean_algebra".to_string(), "BooleanAlgebra".to_string()); - __m.insert("PartialFunction".to_string(), "PartialFunction".to_string()); - __m.insert("partial_function".to_string(), "PartialFunction".to_string()); + __m.insert("List", "FreeMonoid".to_string()); + __m.insert("list", "FreeMonoid".to_string()); + __m.insert("Set", "BooleanAlgebra".to_string()); + __m.insert("set", "BooleanAlgebra".to_string()); + __m.insert("Map", "PartialFunction".to_string()); + __m.insert("map", "PartialFunction".to_string()); + __m.insert("FreeMonoid", "FreeMonoid".to_string()); + __m.insert("free_monoid", "FreeMonoid".to_string()); + __m.insert("BooleanAlgebra", "BooleanAlgebra".to_string()); + __m.insert("boolean_algebra", "BooleanAlgebra".to_string()); + __m.insert("PartialFunction", "PartialFunction".to_string()); + __m.insert("partial_function", "PartialFunction".to_string()); Rc::new(__m) }; } @@ -160,12 +160,12 @@ pub fn container_template_alias_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), "FreeMonoid".to_string()); - __m.insert("list".to_string(), "FreeMonoid".to_string()); - __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("Map".to_string(), "PartialFunction".to_string()); - __m.insert("map".to_string(), "PartialFunction".to_string()); + __m.insert("List", "FreeMonoid".to_string()); + __m.insert("list", "FreeMonoid".to_string()); + __m.insert("Set", "BooleanAlgebra".to_string()); + __m.insert("set", "BooleanAlgebra".to_string()); + __m.insert("Map", "PartialFunction".to_string()); + __m.insert("map", "PartialFunction".to_string()); Rc::new(__m) }; } @@ -201,12 +201,18 @@ pub enum Bool { False, } -pub type Json = serde_json::Value; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Json(pub std::marker::PhantomData<()>); -pub type Bytes = Vec; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Bytes(pub std::marker::PhantomData<()>); pub type Char = i64; +pub fn list_length(items: Rc>) -> i64 { + items.iter().cloned().fold(0, |acc: i64, _: T| (acc + 1)) +} + pub type CommitSha = String; pub type Sha256 = String; @@ -468,7 +474,7 @@ pub struct Document { } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct TextFile { +pub struct DocumentFile { pub path: String, pub document: Rc, } @@ -532,3 +538,28 @@ pub struct DocSource { pub path: FilePath, pub kind: DocSourceKind, } + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ReferenceModel(pub std::marker::PhantomData); + +pub struct True; +pub struct False; +pub struct Pure; +pub struct Transport; +pub struct SubDag; +pub struct Env; +pub struct Template; +pub struct Generated; +pub struct Static; +pub struct Xs; +pub struct S; +pub struct M; +pub struct L; +pub struct Xl; +pub struct GET; +pub struct POST; +pub struct PUT; +pub struct PATCH; +pub struct DELETE; +pub struct HEAD; +pub struct OPTIONS; diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index 8b235a5ebfd..6550786741c 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -163,3 +163,17 @@ pub struct DagArtifact { pub diagnostics: Rc>, pub files: Rc>, } + +pub struct Rust; +pub struct Python; +pub struct Go; +pub struct Dag; +pub struct ServiceBinary; +pub struct Library; +pub struct Frontend; +pub struct GeneratedSupport; +pub struct DirectCall; +pub struct HttpJson; +pub struct MessageQueue; +pub struct Ffi; +pub struct FileProtocol; diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index d86d3d71511..6c8e64335a0 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -82,8 +82,8 @@ pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) Some(syntax) => { let mut __found = false; for r in syntax.cast_rules.clone().iter().cloned() { - if ((r.from_type.clone().as_str() == source_type.clone().as_str()) - && (r.to_type.clone().as_str() == target_type.clone().as_str())) + if ((r.from_type.clone() == source_type.clone()) + && (r.to_type.clone() == target_type.clone())) { __found = true; break; @@ -116,7 +116,7 @@ pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option Option>, ref_name: String) -> Rc>>) -> Rc let parse_results = parsed.parse_results.clone(); let newline_indices = parsed.newline_indices.clone(); let parse_diagnostics = collect_diagnostics(parse_results.clone()); - let has_parse_errors = parse_results - .iter() - .cloned() - .any(|p: Rc| p.error.clone() != None); + let has_parse_errors = { + let mut __found = false; + for p in parse_results.clone().iter().cloned() { + if (p.error.clone() != None) { + __found = true; + break; + } + } + __found + }; if has_parse_errors { Rc::new(FrontendResult { graph: None, @@ -2282,26 +2287,28 @@ pub fn front_end_sources(sources: Rc>>) -> Rc intern_table: parsed.intern_table.clone(), }) } else { - let modules = Rc::new({ - let mut __result = Vec::new(); - for p in parse_results.iter().cloned() { - __result.push(p.module.clone().clone().unwrap()); - } - __result - }); - let source_indices = newline_indices.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, si: Rc| { - v1_rt::rc_map_insert(acc, si.file.clone(), si.clone()) - }, - ); - let graph = resolve_modules(modules, source_indices); - Rc::new(FrontendResult { - graph: Some(graph.clone()), - diagnostics: v1_rt::concat(parse_diagnostics, graph.diagnostics.clone()), - newline_indices: newline_indices.clone(), - intern_table: parsed.intern_table.clone(), - }) + { + let modules = Rc::new({ + let mut __result = Vec::new(); + for p in parse_results.clone().iter().cloned() { + __result.push(p.module.clone().clone().unwrap()); + } + __result + }); + let source_indices = newline_indices.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, si: Rc| { + v1_rt::rc_map_insert(acc, si.file.clone(), si.clone()) + }, + ); + let graph = resolve_modules(modules, source_indices); + Rc::new(FrontendResult { + graph: Some(graph.clone()), + diagnostics: v1_rt::concat(parse_diagnostics, graph.diagnostics.clone()), + newline_indices: newline_indices.clone(), + intern_table: parsed.intern_table.clone(), + }) + } } } } @@ -2345,40 +2352,9 @@ pub fn compile_to_resolved(sources: Rc>>) -> Rc>>, -) -> Rc { - compile_to_resolved_with_options_gated(sources, default_compile_pipeline_options(), true) -} - -fn is_resolved_pipeline_typecheck_blocking( - diagnostic: Rc, - discovery_corpus_advisory_typecheck: bool, -) -> bool { - if !is_error_diagnostic(diagnostic.clone()) { - return false; - } - if discovery_corpus_advisory_typecheck { - is_discovery_corpus_blocking_diagnostic(diagnostic) - } else { - true - } -} - pub fn compile_to_resolved_with_options( sources: Rc>>, options: CompilePipelineOptions, -) -> Rc { - compile_to_resolved_with_options_gated(sources, options, false) -} - -fn compile_to_resolved_with_options_gated( - sources: Rc>>, - options: CompilePipelineOptions, - discovery_corpus_advisory_typecheck: bool, ) -> Rc { { let frontend = front_end_sources(sources); @@ -2463,10 +2439,7 @@ fn compile_to_resolved_with_options_gated( let type_errors = Rc::new({ let mut __result = Vec::new(); for d in typed_diags.clone().iter().cloned() { - if is_resolved_pipeline_typecheck_blocking( - d.diagnostic.clone(), - discovery_corpus_advisory_typecheck, - ) { + if is_error_diagnostic(d.diagnostic.clone()) { __result.push(d); } } diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index ae8d86f6d14..3eb380b8d46 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -409,8 +409,8 @@ pub fn parser_state_param( { let idx = pair.0.clone(); let param = pair.1.clone(); - if (authored_name_at(si.clone(), param_node_type_expr(param.clone())).as_str() - == "ParserState".to_string().as_str()) + if (authored_name_at(si.clone(), param_node_type_expr(param.clone())) + == "ParserState".to_string()) { Some(Rc::new(ParserStateParam { name: param_node_name_at(param.clone(), si.clone()), @@ -501,10 +501,10 @@ pub fn parser_state_arg_expr( let idx = pair.0.clone(); let arg_node = pair.1.clone(); let matches_state = if (arg_name_at(arg_node.clone(), si.clone()).as_deref() - != Some("".to_string().as_str())) + != Some("".to_string())) { (arg_name_at(arg_node.clone(), si.clone()).as_deref() - == Some(state_param.name.clone().as_str())) + == Some(state_param.name.clone())) } else { (idx.clone() == state_param.index.clone()) }; @@ -532,7 +532,7 @@ pub fn parser_state_expr_progress( binding_kind: _, .. } => { let name = expr_var_name_at(expr.clone(), si.clone()); - if (name.clone().as_str() == state_param.name.clone().as_str()) { + if (name.clone() == state_param.name.clone()) { DescentEvidence::NonIncreasing } else { match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { @@ -542,9 +542,7 @@ pub fn parser_state_expr_progress( } } ExprData::ExprFieldAccess { .. } => { - if (field_access_field_at(expr.clone(), si.clone()).as_str() - == "state".to_string().as_str()) - { + if (field_access_field_at(expr.clone(), si.clone()) == "state".to_string()) { match parser_state_base_var(expr.clone(), si.clone()) { Some(result_name) => { match v1_rt::map_get(&env.result_sources.clone(), result_name.clone()) { @@ -1161,9 +1159,7 @@ pub fn parser_record_field_value( for child in Rc::new({ let mut __result = Vec::new(); for child in expr.children.clone().iter().cloned() { - if (field_init_node_name_at(child.clone(), si.clone()).as_str() - == field_name.clone().as_str()) - { + if (field_init_node_name_at(child.clone(), si.clone()) == field_name.clone()) { __result.push(child); } } @@ -1573,7 +1569,7 @@ pub fn build_call_graph_from_parser_edges( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { + if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } } @@ -1609,7 +1605,7 @@ pub fn same_progress_subgraph_has_cycle( let has_self_cycle = { let mut __found = false; for edge in same_edges.clone().iter().cloned() { - if (edge.caller.clone().as_str() == edge.callee.clone().as_str()) { + if (edge.caller.clone() == edge.callee.clone()) { __found = true; break; } @@ -1623,7 +1619,7 @@ pub fn same_progress_subgraph_has_cycle( let same_cross_edges = Rc::new({ let mut __result = Vec::new(); for edge in same_edges.clone().iter().cloned() { - if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { + if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } } @@ -1751,7 +1747,7 @@ pub fn count_self_calls( let own = match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - if (f.as_str() == func_name.clone().as_str()) { + if (f == func_name.clone()) { 1 } else { 0 @@ -1789,11 +1785,7 @@ pub fn max_path_self_calls_with_cont( match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - let own = if (f.as_str() == func_name.clone().as_str()) { - 1 - } else { - 0 - }; + let own = if (f == func_name.clone()) { 1 } else { 0 }; let arg_calls = body.children .clone() @@ -2352,7 +2344,7 @@ pub fn descending_name_set_without_key( Rc::new(v1_rt::map_keys(&names)).iter().cloned().fold( v1_rt::rc_empty_map::(), |acc: Rc>, name: String| { - if (name.clone().as_str() == key.clone().as_str()) { + if (name.clone() == key.clone()) { acc.clone() } else { match v1_rt::map_get(&names, name.clone()) { @@ -2581,9 +2573,7 @@ pub fn has_arithmetic_descent( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let own_ok = if (expr_call_func_at(body.clone(), si.clone()).as_str() - == func_name.clone().as_str()) - { + let own_ok = if (expr_call_func_at(body.clone(), si.clone()) == func_name.clone()) { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -2643,7 +2633,7 @@ pub fn is_accessor_of_param( binding_kind: _, .. } => { let vname = expr_var_name_at(arg_value(arg_node.clone()), si.clone()); - ((vname.clone().as_str() == param_name.clone().as_str()) + ((vname.clone() == param_name.clone()) || set_has(vars.clone(), vname.clone())) } _ => false, @@ -2674,10 +2664,7 @@ pub fn is_children_of_param( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => { - (expr_var_name_at(base.clone(), si.clone()).as_str() - == param_name.as_str()) - } + } => (expr_var_name_at(base.clone(), si.clone()) == param_name), _ => false, }); } @@ -2831,10 +2818,7 @@ pub fn is_list_shrink_expr( && match (*method_receiver(expr.clone()).expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => { - (expr_var_name_at(method_receiver(expr.clone()), si).as_str() - == param_name.as_str()) - } + } => (expr_var_name_at(method_receiver(expr.clone()), si) == param_name), _ => false, }) && match method_arg_nodes(expr.clone()).first().cloned() { @@ -2933,7 +2917,7 @@ pub fn consuming_tokens_arg( Some(_) => acc.clone(), None => match arg_name_at(child.clone(), si.clone()) { Some(name) => { - if (name.clone().as_str() == "tokens".to_string().as_str()) { + if (name.clone() == "tokens".to_string()) { Some(arg_value(child.clone())) } else { None @@ -2956,12 +2940,11 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone().as_str() == param_name.clone().as_str()) - || set_has(vars, vname.clone())); + break ((vname.clone() == param_name.clone()) || set_has(vars, vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field.as_str() == param_name.clone().as_str()) { + if (field == param_name.clone()) { break true; } else { let base = field_access_base(expr.clone()); @@ -2970,7 +2953,7 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - break ((bname.clone().as_str() == param_name.clone().as_str()) + break ((bname.clone() == param_name.clone()) || set_has(vars, bname.clone())); } _ => { @@ -3113,7 +3096,7 @@ pub fn expr_contains_descent( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) + ((bname.clone() == param_name.clone()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3206,10 +3189,7 @@ pub fn is_if_option_descent( Some(eb) => match (*eb.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => { - (expr_var_name_at(eb.clone(), si.clone()).as_str() - == "none".to_string().as_str()) - } + } => (expr_var_name_at(eb.clone(), si.clone()) == "none".to_string()), ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, _ => false, @@ -3287,8 +3267,8 @@ pub fn is_match_option_descent( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(arm_b.clone(), si.clone()).as_str() - != param_name.clone().as_str()) + (expr_var_name_at(arm_b.clone(), si.clone()) + != param_name.clone()) } _ => true, } @@ -3406,8 +3386,7 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()).as_str() - == param_name.clone().as_str()) + (expr_var_name_at(inner.clone(), si.clone()) == param_name.clone()) } _ => false, }; @@ -3426,7 +3405,7 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) + ((bname.clone() == param_name.clone()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3516,7 +3495,7 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone().as_str() == param_name.clone().as_str()) + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3694,7 +3673,7 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) + ((bname.clone() == param_name.clone()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3749,7 +3728,7 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone().as_str() == param_name.clone().as_str()) + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3878,7 +3857,7 @@ pub fn all_self_calls_descend_inc( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_ok = if (callee.as_str() == func_name.clone().as_str()) { + let own_ok = if (callee == func_name.clone()) { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -4090,10 +4069,7 @@ pub fn matches_on_sub_value_field( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => { - (expr_var_name_at(base.clone(), si.clone()).as_str() - == param_name.as_str()) - } + } => (expr_var_name_at(base.clone(), si.clone()) == param_name), _ => false, }) } @@ -4174,7 +4150,7 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left.clone(), si).as_str() == param_name.as_str()) + ((expr_var_name_at(left.clone(), si) == param_name) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { @@ -4229,7 +4205,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (vname.clone() == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4294,14 +4270,14 @@ pub fn classify_self_call_evidence( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone().as_str() == param_name.clone().as_str())) + || (bname.clone() == param_name.clone())) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (field.as_str() == param_name.clone().as_str()) { + if (field == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4503,8 +4479,7 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()).as_str() - == param_name.clone().as_str()) + (expr_var_name_at(inner.clone(), si.clone()) == param_name.clone()) } _ => false, }; @@ -4523,7 +4498,7 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) + ((bname.clone() == param_name.clone()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -4625,7 +4600,7 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone().as_str() == param_name.clone().as_str()) + ((sname.clone() == param_name.clone()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -4754,7 +4729,7 @@ pub fn collect_evidence_incremental( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_evidence = if (callee.as_str() == func_name.clone().as_str()) { + let own_evidence = if (callee == func_name.clone()) { { let arg_evidence = body.children.clone().iter().cloned().fold( DescentEvidence::DescentUnknown, @@ -5794,7 +5769,7 @@ pub fn build_call_graph( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { + if (edge.caller.clone() != edge.callee.clone()) { __result.push(edge); } } @@ -5847,7 +5822,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (vname.clone() == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5901,14 +5876,14 @@ pub fn classify_scc_call_progress( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone().as_str() == param_name.clone().as_str())) + || (bname.clone() == param_name.clone())) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (field.as_str() == param_name.clone().as_str()) { + if (field == param_name.clone()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -6246,8 +6221,7 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()).as_str() - == param_name.clone().as_str()) + (expr_var_name_at(inner.clone(), si.clone()) == param_name.clone()) } _ => false, }; @@ -6266,7 +6240,7 @@ pub fn collect_scc_child_edges( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) + ((bname.clone() == param_name.clone()) || set_has(descent_vars.clone(), bname.clone())) } _ => false, @@ -6763,7 +6737,7 @@ let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pnam let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); -let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (pe.caller.clone().as_str() == name.clone().as_str()) { __result.push(pe); } } __result }); +let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (pe.caller.clone() == name.clone()) { __result.push(pe); } } __result }); let parser_edge_map = my_parser_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); let all_keys = v1_rt::concat(Rc::new(v1_rt::map_keys(&tree_edge_map)), Rc::new(v1_rt::map_keys(&parser_edge_map))); let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |acc: Rc>, k: String| v1_rt::rc_map_insert(acc, k.clone(), true)); @@ -6816,7 +6790,7 @@ let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for _ => false, } { __found = true; break; } } __found }) { __all = false; break; } } __all }); let descending_param = match self_evidence.clone().first().cloned() { - Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: String, rel: Rc| if (found.clone().as_str() != "".to_string().as_str()) { + Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: String, rel: Rc| if (found.clone() != "".to_string()) { found.clone() } else { match (*rel.clone()).clone() { @@ -6860,7 +6834,7 @@ Rc::new(vec![Rc::new(ProofEdge { } else { Rc::new(vec![]) }; -let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone().as_str() != name.clone().as_str()) { __result.push(m); } } __result }); +let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { @@ -6895,7 +6869,7 @@ pub fn scc_descending_param( .iter() .cloned() .fold("".to_string(), |found: String, name: String| { - if (found.clone().as_str() != "".to_string().as_str()) { + if (found.clone() != "".to_string()) { found.clone() } else { match v1_rt::map_get(&func_index, name.clone()) { @@ -6909,7 +6883,7 @@ pub fn scc_descending_param( Some(call_ev) => call_ev.clone().iter().cloned().fold( "".to_string(), |p: String, rel: Rc| { - if (p.clone().as_str() != "".to_string().as_str()) { + if (p.clone() != "".to_string()) { p.clone() } else { match (*rel.clone()).clone() { @@ -6966,7 +6940,7 @@ pub fn construct_scc_termination_proof( let cx_l2_param = scc_descending_param(members.clone(), func_index.clone(), si.clone()); let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { - param: if (cx_l2_param.clone().as_str() != "".to_string().as_str()) { + param: if (cx_l2_param.clone() != "".to_string()) { cx_l2_param.clone() } else { "scc".to_string() @@ -7531,7 +7505,7 @@ pub fn resolve_lambda_arg( let f_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_arg_nodes.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() == "f".to_string().as_str()) { + if (authored_name_at(si.clone(), a.clone()) == "f".to_string()) { __result.push(a); } } @@ -8292,8 +8266,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { name.clone(), short.clone(), ), - suffix: if (acc.suffix.clone().as_str() == "".to_string().as_str()) - { + suffix: if (acc.suffix.clone() == "".to_string()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(" where ".to_string(), short.clone()), @@ -8414,14 +8387,14 @@ pub fn classify_complexity(expr: Rc) -> String { pub fn collect_size_vars_from_size(size: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { - if (c.clone().as_str() == "__expr".to_string().as_str()) { + if (c.clone() == "__expr".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![c.clone()]) } } SizeExpr::SizeVar { name: n, .. } => { - if (n.clone().as_str() == "__k".to_string().as_str()) { + if (n.clone() == "__k".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![n.clone()]) @@ -9477,7 +9450,7 @@ pub fn max_path_descending( .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own = if (callee.as_str() == fn_name.clone().as_str()) { + let own = if (callee == fn_name.clone()) { match de.clone() { Some(evidence) => { match evidence.clone().get(param_index.clone() as usize).cloned() { @@ -9915,3 +9888,6 @@ pub fn build_complexity_report( }) } } + +pub struct Proven; +pub struct Conservative; diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 9471d8bd69f..e428c2b2203 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -192,7 +192,7 @@ pub fn derive_module_imports( ImportTrigger::TypeUsageTrigger { type_name: t, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (n.clone().as_str() == t.clone().as_str()) { + if (n.clone() == t.clone()) { __found = true; break; } @@ -204,7 +204,7 @@ pub fn derive_module_imports( ImportTrigger::ContainerUsageTrigger { container: c, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (n.clone().as_str() == c.clone().as_str()) { + if (n.clone() == c.clone()) { __found = true; break; } @@ -228,7 +228,7 @@ pub fn derive_module_imports( .iter() .cloned() { - if (path.clone().as_str() != "".to_string().as_str()) { + if (path.clone() != "".to_string()) { __result.push(path); } } @@ -512,7 +512,7 @@ pub fn emit_simple_string_interp( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (a.clone() != "".to_string()) { __result.push(a); } } @@ -652,7 +652,7 @@ pub fn typed_named_arg_matches( if (n.clone() == None) { false } else { - (n.clone().unwrap().as_str() == name.as_str()) + (n.clone().unwrap() == name) } } } @@ -1187,7 +1187,7 @@ pub fn emit_bin_op_symbol( } pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> String { - if (kind.clone().as_str() == "optional".to_string().as_str()) { + if (kind.clone() == "optional".to_string()) { apply_type_template1(target_optional_template(target.clone()), inner) } else { match coerce_container_template(target.clone(), kind.clone()) { @@ -1333,8 +1333,7 @@ pub fn render_node_type( { let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { - ((tn.clone().as_str() != "".to_string().as_str()) - && (tn.clone().as_str() == var_id.clone().as_str())) + ((tn.clone() != "".to_string()) && (tn.clone() == var_id.clone())) } _ => false, }; @@ -1388,7 +1387,7 @@ pub fn render_node_type( ret_str.clone(), ), None => { - if (ret_str.clone().as_str() == "".to_string().as_str()) { + if (ret_str.clone() == "".to_string()) { { let void_template = v1_rt::replace( repr.template.clone(), @@ -1530,8 +1529,7 @@ pub fn render_node_type( }; if has_template { { - let base = if (snake.clone().as_str() == "map".to_string().as_str()) - { + let base = if (snake.clone() == "map".to_string()) { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { emit_container(snake.clone(), "_".to_string(), target.clone()) @@ -1575,8 +1573,8 @@ pub fn render_node_type( } if ((n.children.clone().len() as i64) == 0) { { - let bare_is_map = (is_container_type(tn.clone()) - && (to_snake(tn.clone()).as_str() == "map".to_string().as_str())); + let bare_is_map = + (is_container_type(tn.clone()) && (to_snake(tn.clone()) == "map".to_string())); let bare_is_collection = (is_declared_container_alias_spelling(tn.clone()) && !bare_is_map.clone()); let has_container_template = match container_template_algebra(to_snake(tn.clone())) @@ -1632,7 +1630,7 @@ pub fn render_node_type( ) } } else { - if (tn.clone().as_str() == tuple_type_name().as_str()) { + if (tn.clone() == tuple_type_name()) { render_tuple_parts(Rc::new(vec![]), target.clone()) } else { coerce_primitive_type(target.clone(), tn.clone()) @@ -1726,7 +1724,7 @@ pub fn render_node_type( } __result }); - if (tn.clone().as_str() == tuple_type_name().as_str()) { + if (tn.clone() == tuple_type_name()) { { let multi_tuple_str = render_tuple_parts(child_strs.clone(), target.clone()); return multi_tuple_str; @@ -2089,10 +2087,10 @@ pub fn emit_unified_operation_method( let op_text = authored_name(env.clone(), op_node.clone()); let params_str = emit_params_shared(op_node.params.clone(), target.clone(), si.clone()); let sp = service_self_param(spec.clone()); - let all_params = if (sp.clone().as_str() == "".to_string().as_str()) { + let all_params = if (sp.clone() == "".to_string()) { params_str.clone() } else { - if (params_str.clone().as_str() == "".to_string().as_str()) { + if (params_str.clone() == "".to_string()) { sp.clone() } else { v1_rt::concat( @@ -2540,7 +2538,7 @@ pub fn emit_shared_tco_expr( let si = frame.scope.clone().type_env.clone().source_indices.clone(); match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si).as_str() == fn_name.as_str()) { + if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), @@ -3252,7 +3250,7 @@ pub fn emit_unified_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let bs = language_spec(target.clone()).block_syntax.clone(); - if (bs.block_close.clone().as_str() == "".to_string().as_str()) { + if (bs.block_close.clone() == "".to_string()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrut_str), @@ -3594,8 +3592,7 @@ pub fn is_tco_candidate( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() - == func_name.clone().as_str()) + (expr_call_func_at(texpr.clone(), source_indices.clone()) == func_name.clone()) } ExprData::ExprReturn => is_tco_candidate( return_value(texpr.clone()), @@ -3674,9 +3671,7 @@ pub fn suffix_escape_collides_with_reserved_chain( &name, (name_len.clone() - suffix_len.clone()), name_len.clone(), - ) - .as_str() - != suffix.clone().as_str()) + ) != suffix.clone()) { break false; } else { @@ -3684,7 +3679,7 @@ pub fn suffix_escape_collides_with_reserved_chain( if { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (r.clone().as_str() == base.clone().as_str()) { + if (r.clone() == base.clone()) { __found = true; break; } @@ -3713,7 +3708,7 @@ pub fn emit_suffix_escape_ident( let is_reserved = { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (r.clone().as_str() == converted.clone().as_str()) { + if (r.clone() == converted.clone()) { __found = true; break; } @@ -3746,7 +3741,7 @@ pub fn emit_ident(name: String, target: RenderTarget) -> String { let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (r.clone().as_str() == converted.clone().as_str()) { + if (r.clone() == converted.clone()) { __found = true; break; } @@ -3789,7 +3784,7 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (r.clone().as_str() == result.clone().as_str()) { + if (r.clone() == result.clone()) { __found = true; break; } @@ -3946,12 +3941,10 @@ pub fn emit_expr_var_shared( ) -> String { { let n = expr_var_name_at(expr, source_indices); - if (n.clone().as_str() == "none".to_string().as_str()) { + if (n.clone() == "none".to_string()) { emit_keyword("null".to_string(), target) } 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(), target) } else { emit_ident(n.clone(), target) @@ -4014,9 +4007,7 @@ pub fn emit_typed_cast_shared( } _ => "".to_string(), }; - if ((src_ty.clone().as_str() != "".to_string().as_str()) - && (src_ty.clone().as_str() == ty_str.clone().as_str())) - { + if ((src_ty.clone() != "".to_string()) && (src_ty.clone() == ty_str.clone())) { expr_str } else { if can_cast(target.clone(), src_ty.clone(), ty_str.clone()) { @@ -4800,7 +4791,7 @@ pub fn emit_typed_string_interp_unified( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (a.clone() != "".to_string()) { __result.push(a); } } @@ -5577,7 +5568,7 @@ pub fn emit_typed_match_unified( __result }); let arms_str = arm_strs.join(&"\n".to_string()); - if (bs.block_close.clone().as_str() == "".to_string().as_str()) { + if (bs.block_close.clone() == "".to_string()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrutinee_str), @@ -6023,7 +6014,7 @@ pub fn is_tco_identity_passthrough( match (*arg_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(arg_val.clone(), si).as_str() == param_name.as_str()), + } => (expr_var_name_at(arg_val.clone(), si) == param_name), _ => false, } } @@ -6105,3 +6096,15 @@ pub fn emit_typed_tco_reassign_shared( pub fn seed_bindings(key: String, value: String) -> Rc> { v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) } + +pub struct CapServiceEmit; +pub struct CapAsyncTransport; +pub struct CapTestGeneration; +pub struct CapDryRunMode; +pub struct CapRcOwnership; +pub struct ExprCatLeaf; +pub struct ExprCatCompound; +pub struct ExprCatControlFlow; +pub struct ExprCatBinding; +pub struct ExprCatService; +pub struct ExprCatNone; diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 35da76811db..e384a9d4951 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -551,7 +551,7 @@ pub fn has_mock_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5).as_str() == "mock_".to_string().as_str()) + (v1_rt::substring(&name, 0, 5) == "mock_".to_string()) } } @@ -651,7 +651,7 @@ pub fn is_type_alias_return_node( n: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, n).as_str() != "Unit".to_string().as_str()) + (authored_name_at(source_indices, n) != "Unit".to_string()) } pub fn is_service_item(item: Rc) -> bool { diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index fb593f98367..80ca723d392 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -135,12 +135,11 @@ pub fn emit_go(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); } @@ -154,7 +153,7 @@ pub fn emit_go(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (f.path.clone() != "".to_string()) { __result.push(f); } } @@ -484,7 +483,7 @@ pub fn emit_go_module( module_imports(m.clone()), si.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\n".to_string(), imports_str.clone()) @@ -1581,7 +1580,7 @@ pub fn emit_go_rest_call( v1_rt::concat( v1_rt::concat( Rc::new(vec![url_line, body_line, req_line]), - if (auth_line.clone().as_str() == "".to_string().as_str()) { + if (auth_line.clone() == "".to_string()) { Rc::new(vec![]) } else { Rc::new(vec![auth_line.clone()]) @@ -1829,7 +1828,7 @@ pub fn go_export_ident(name: String) -> String { if { let mut __found = false; for r in go_reserved().iter().cloned() { - if (r.clone().as_str() == result.clone().as_str()) { + if (r.clone() == result.clone()) { __found = true; break; } diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 6c00b21f8fb..ddb3cc3f4a9 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -123,12 +123,11 @@ pub fn emit_python(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); } @@ -142,7 +141,7 @@ pub fn emit_python(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (f.path.clone() != "".to_string()) { __result.push(f); } } @@ -371,7 +370,7 @@ pub fn emit_py_module( let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); - let imports_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()) @@ -500,7 +499,7 @@ pub fn emit_py_imports( Rc::new({ let mut __result = Vec::new(); for line in import_lines.iter().cloned() { - if (line.clone().as_str() != "".to_string().as_str()) { + if (line.clone() != "".to_string()) { __result.push(line); } } @@ -1291,7 +1290,7 @@ pub fn emit_py_headers_dict( } __result }); - let all_entries = if (auth_entry.clone().as_str() == "".to_string().as_str()) { + let all_entries = if (auth_entry.clone() == "".to_string()) { header_entries.join(&", ".to_string()) } else { v1_rt::concat(auth_entry.clone(), header_entries.join(&", ".to_string())) @@ -1471,7 +1470,7 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String __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()) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 8588f1532c4..fedbdc81610 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, @@ -36,16 +37,17 @@ pub use crate::v1_compiler_emit::{ pub use crate::v1_compiler_emit_core_support::{ apply_named_template, apply_type_template1, apply_type_template2, apply_type_template3, capitalize_first, escape_json_string, escape_string_literal_body, extract_test_projections, - has_mock_prefix, is_bare_leaf_item, is_data_def_item, is_function_item, is_resource_def_item, - is_service_def_item, is_service_item, is_type_alias_item, is_type_alias_return_node, - is_type_decl_item, is_type_def_item, is_upper, language_spec, make_indent, module_to_filename, + has_mock_prefix, is_data_def_item, is_function_item, is_resource_def_item, is_service_def_item, + is_service_item, is_type_alias_item, is_type_alias_return_node, is_type_decl_item, + is_type_def_item, is_upper, language_spec, make_indent, module_to_filename, sanitize_service_name, service_var_name, test_function_name, to_lower_char, to_pascal, to_screaming_snake, to_snake, to_string, to_string_helper, to_upper_char, unique_strings, }; 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::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ @@ -83,7 +85,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}; @@ -160,6 +161,18 @@ pub fn render_rust_type( Rc::new(vec![]), 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_type_without_applied_binding( @@ -192,6 +205,15 @@ pub fn render_rust_type_without_applied_binding( Rc::new(vec![]), 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::>>>(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -231,19 +253,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)) + && rust_emit_faithful_text_carrier(source_indices.clone())) + { + render_rust_text_carrier(shared_types) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) + } } } } @@ -255,16 +278,24 @@ 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")) + { + let mut __found = false; + for k in Rc::new(v1_rt::map_keys(&source_indices)).iter().cloned() { + if (v1_rt::contains(k.clone(), "/v1/".to_string()) + || v1_rt::contains(k.clone(), "src/v1".to_string())) + { + __found = true; + break; + } + } + __found + } } pub fn rust_emit_faithful_text_carrier( @@ -316,57 +347,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_seed_host_numeric_alias( + name: String, + source_indices: Rc>>, +) -> Option { + if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) + && rust_corpus_includes_v1_compiler(source_indices)) + { + Some("i64".to_string()) + } 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())) - { + 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()) + && rust_emit_faithful_text_carrier(source_indices)) + { + "FreeMonoid".to_string() + } else { + coerce_primitive_type(RenderTarget::Rust, name.clone()) + } } } @@ -399,10 +425,19 @@ pub fn render_rust_applied_type_arg( generic_param_names: Rc>, shared_types: Rc>, 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, + source_indices, + variant_to_enum, + env, + ), } } @@ -411,6 +446,8 @@ pub fn render_rust_applied_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { let base = rust_named_type_base( @@ -429,6 +466,8 @@ pub fn render_rust_applied_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), )); } __result @@ -461,6 +500,8 @@ pub fn render_rust_applied_type_shared( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { let rendered = render_rust_applied_type( @@ -468,6 +509,8 @@ pub fn render_rust_applied_type_shared( generic_param_names, shared_types.clone(), 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()) @@ -479,6 +522,8 @@ pub fn render_rust_decl_type( generic_param_names: Rc>, shared_types: Rc>, 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 +531,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()) @@ -503,6 +547,8 @@ pub fn render_rust_decl_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -511,7 +557,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 +566,87 @@ 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())) + && 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)) + && (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(), + 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(), + 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(), + source_indices.clone(), + ) + } } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - ) } } } @@ -589,21 +655,23 @@ 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( @@ -611,25 +679,44 @@ pub fn render_rust_fn_sig_type( generic_param_names: Rc>, shared_types: Rc>, 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())) + && rust_emit_faithful_text_carrier(source_indices.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, + source_indices.clone(), + variant_to_enum, + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + env.clone(), + ) + } + } + } } } @@ -646,25 +733,37 @@ 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, + 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, + 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, source_indices.clone()) + } } } @@ -689,7 +788,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 +797,96 @@ 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()) - { - render_rust_text_carrier(shared_types.clone()) - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier - } 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)) - { + } 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(), - ) + if ((name.clone() == "String".to_string()) + && rust_emit_faithful_text_carrier(source_indices.clone())) + { + render_rust_text_carrier(shared_types.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(), + 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 { + 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 = 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 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(), + 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(), source_indices.clone()) } } - } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -903,14 +1013,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 +1031,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 +1065,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 +1167,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 +1237,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 +1263,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 +1280,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 +1310,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 +1321,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 +1332,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 +1343,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 +1363,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 +1383,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 +1437,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 +1448,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 +1481,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 +1674,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 +1685,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 +1714,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 +1745,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 +1766,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 +1828,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 +1893,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); } } @@ -2213,6 +2265,173 @@ pub fn emit_rust_init_block_stmts( } } +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 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()); + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + vname.clone(), + ), + ";".to_string(), + ) + }); + } + __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(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + vname.clone(), + ), + ";".to_string(), + )); + } + __result + }) + .join(&"\n".to_string()) +} + pub fn has_complex_variants(item: Rc) -> bool { if ((item.children.clone().len() as i64) == 0) { false @@ -2352,9 +2571,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); } @@ -2612,12 +2830,11 @@ 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); } @@ -2631,7 +2848,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 +2859,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 +2968,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() }; @@ -2892,7 +3108,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()) @@ -2922,7 +3138,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( @@ -3009,7 +3225,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( @@ -3070,19 +3286,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 { @@ -3284,10 +3500,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; @@ -3339,8 +3555,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; @@ -3382,8 +3598,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()))) @@ -3416,8 +3631,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()))) @@ -3499,7 +3713,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; } @@ -3594,7 +3808,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; } @@ -3648,8 +3862,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; } @@ -3823,7 +4036,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); } } @@ -3898,8 +4111,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())) { @@ -3924,7 +4136,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; } @@ -4021,7 +4233,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); @@ -4094,7 +4306,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; @@ -4132,7 +4344,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( @@ -4184,7 +4396,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; } @@ -4297,7 +4509,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; @@ -4388,7 +4600,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))) { @@ -4441,7 +4653,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; } @@ -4548,8 +4760,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()))) @@ -4596,28 +4808,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, @@ -4628,8 +4824,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 { @@ -4827,9 +5049,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( @@ -4878,91 +5098,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), - ), - v1_rt::concat( - v1_rt::concat("(pub ".to_string(), marker_ty), - ");".to_string(), + marker_ty, ), - ), - "".to_string(), - ) + ");".to_string(), + ) + } } pub fn is_emittable_parametric_type_alias_item( @@ -4992,37 +5221,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, + )))) } } } @@ -5050,7 +5263,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; } @@ -5192,7 +5405,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); } } @@ -5226,7 +5439,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; @@ -5248,7 +5461,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; } @@ -5273,7 +5486,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; @@ -5357,9 +5570,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); } @@ -5437,13 +5648,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![]) @@ -5463,9 +5674,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(), @@ -5476,9 +5685,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, }, } { @@ -5517,15 +5724,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) { @@ -5546,7 +5753,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); } } @@ -5557,7 +5764,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); } } @@ -5593,10 +5800,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(), @@ -5609,8 +5813,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(), @@ -5689,7 +5892,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; } @@ -5723,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 main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (l.clone() != "".to_string()) { __result.push(l); } } @@ -5732,7 +5935,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); } } @@ -5856,7 +6059,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(), @@ -5889,9 +6092,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 { { @@ -5916,17 +6117,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))) @@ -5965,9 +6163,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); } } @@ -6080,8 +6276,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); } @@ -6151,8 +6346,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(), @@ -6282,44 +6476,73 @@ 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(), + env.source_indices.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, + 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()) { @@ -6385,16 +6608,18 @@ pub fn emit_typed_item( ";".to_string(), ) } - } else if is_parametric_opaque_type_decl_item( - item.clone(), - env.source_indices.clone(), - ) { - emit_parametric_phantom_opaque_struct( + } else { + if is_parametric_opaque_type_decl_item( item.clone(), env.source_indices.clone(), - ) - } else { - "".to_string() + ) { + emit_parametric_phantom_opaque_struct( + item.clone(), + env.source_indices.clone(), + ) + } else { + "".to_string() + } } } } else { @@ -6527,9 +6752,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()); @@ -6580,12 +6803,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)) } } @@ -6706,11 +6928,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( @@ -6737,7 +6958,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( @@ -6750,6 +6971,76 @@ 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) { + match unused.clone().first().cloned() { + Some(u) => u.clone(), + None => "()".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, @@ -6772,9 +7063,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(), @@ -6826,7 +7115,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( @@ -6869,45 +7183,74 @@ 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(), + 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(), 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(), source_indices.clone()) } } - None => render_rust_type(n.clone(), shared_types, source_indices.clone()), + None => render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()), } } @@ -7079,7 +7422,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 @@ -7110,8 +7453,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); } @@ -7155,20 +7498,19 @@ pub fn emit_rust_field_definition( ) -> String { { 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 emitted = emit_ident(authored.clone(), RenderTarget::Rust); + 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( @@ -7238,7 +7580,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()) @@ -7280,7 +7622,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( @@ -7329,9 +7671,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; } @@ -7395,8 +7735,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); } @@ -7424,7 +7763,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; } @@ -7447,9 +7786,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); } } @@ -7606,8 +7943,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, @@ -7629,9 +7965,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, @@ -7644,67 +7978,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( @@ -7714,9 +8101,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 { @@ -7735,7 +8122,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) => { @@ -7798,7 +8185,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); } } @@ -7883,9 +8270,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, } } @@ -7920,8 +8305,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) => { @@ -8119,71 +8503,75 @@ 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 rust_emit_faithful_text_carrier(si.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(), 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(), + 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(), + 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( @@ -8194,49 +8582,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, - ) } } } @@ -8398,6 +8790,7 @@ pub fn emit_func_def( shared_types.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( @@ -8617,6 +9010,7 @@ pub fn emit_tco_params( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8628,6 +9022,7 @@ pub fn emit_tco_params( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8642,6 +9037,7 @@ pub fn emit_tco_param( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8652,7 +9048,8 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( @@ -8660,6 +9057,7 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8686,6 +9084,7 @@ pub fn emit_func_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8698,6 +9097,7 @@ pub fn emit_func_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8758,6 +9158,7 @@ pub fn emit_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8770,6 +9171,7 @@ pub fn emit_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8784,15 +9186,17 @@ pub fn render_rust_param_sig_type( generic_param_names: Rc>, shared_types: Rc>, 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, source_indices, + variant_to_enum, env, ) } @@ -8803,6 +9207,7 @@ pub fn emit_rust_param_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -8815,6 +9220,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8827,6 +9233,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8848,7 +9255,8 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - env, + variant_to_enum.clone(), + env.clone(), ) } } @@ -8859,6 +9267,7 @@ pub fn emit_param( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8869,7 +9278,8 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( @@ -8877,6 +9287,7 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8896,6 +9307,7 @@ pub fn emit_inferred( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -8905,6 +9317,7 @@ pub fn emit_inferred( generic_param_names, shared_types, source_indices, + variant_to_enum, env, ), ) @@ -8987,12 +9400,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(), @@ -9011,7 +9423,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()]) @@ -9042,7 +9454,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)) { @@ -9085,8 +9497,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( @@ -9227,7 +9638,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() @@ -9270,13 +9681,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, } } @@ -9334,7 +9744,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() @@ -9347,7 +9757,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( @@ -9359,7 +9769,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() { @@ -9390,8 +9800,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()); @@ -9594,25 +10004,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(), ); @@ -9623,15 +10032,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(), @@ -9639,26 +10046,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(), @@ -9729,7 +10135,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; } @@ -9765,8 +10171,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![]), @@ -9791,23 +10196,22 @@ pub fn analyze_rc_pattern( }; let ref_bound_fields = Rc::new({ let mut __result = Vec::new(); - for fb in fbs.clone().iter().cloned() { - __result.extend( - (*{ - 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() - }; + for fb in fbs.clone().iter().cloned() { + __result.extend( + (*{ + 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() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -9967,7 +10371,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() @@ -9980,7 +10384,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( @@ -9992,7 +10396,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() { @@ -10031,8 +10435,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()); @@ -10267,25 +10671,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(), ); @@ -10313,10 +10716,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() { @@ -10326,26 +10726,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(), @@ -10453,7 +10853,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(), @@ -10476,9 +10876,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()]) @@ -10563,7 +10961,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 { @@ -10638,117 +11036,6 @@ 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( name: String, binding_kind: Option>, @@ -10759,7 +11046,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 @@ -10772,8 +11059,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(), @@ -10800,14 +11086,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 { { @@ -10823,9 +11105,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() @@ -10915,14 +11197,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 { { @@ -10936,10 +11214,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() @@ -11050,9 +11327,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); } @@ -11189,7 +11464,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) @@ -11202,12 +11477,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) @@ -11254,7 +11529,7 @@ pub fn rust_empty_map_value_type_str( shared_types, source_indices, ); - if (rendered.clone().as_str() == "".to_string().as_str()) { + if (rendered.clone() == "".to_string()) { "".to_string() } else { rendered.clone() @@ -11283,9 +11558,7 @@ pub fn rust_empty_map_kv_type_str( shared_types.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(), @@ -11313,12 +11586,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())) } } @@ -11391,7 +11664,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(), @@ -11694,11 +11967,17 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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 raw = emit_typed_record_lit( tn.clone(), fs, parent_enum.clone(), - resolved_type(expr.clone()), + expanded_rt.clone(), registry, scope.clone(), depth, @@ -11715,15 +11994,26 @@ pub fn emit_rust_expr_record_lit( 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()) @@ -12158,7 +12448,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(), @@ -12326,7 +12616,7 @@ 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( @@ -12334,7 +12624,7 @@ pub fn emit_typed_call_expr( shared_types, 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(), @@ -12351,7 +12641,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( @@ -12395,7 +12685,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(); @@ -12439,7 +12729,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) { @@ -12537,7 +12827,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()); @@ -12565,38 +12855,17 @@ pub fn emit_typed_call( 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() { @@ -12615,10 +12884,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()); @@ -12793,8 +13062,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()) @@ -12850,12 +13118,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; @@ -12968,7 +13235,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( @@ -13407,10 +13674,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 { @@ -13459,7 +13725,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 { { @@ -13787,9 +14053,9 @@ 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()) { { @@ -13798,7 +14064,7 @@ pub fn emit_rust_fold_method_call( shared_types.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(), @@ -13811,13 +14077,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( @@ -13826,8 +14091,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( @@ -13948,7 +14212,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()) @@ -14435,9 +14699,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()); @@ -14675,9 +14937,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); } @@ -14774,7 +15034,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(), @@ -14788,7 +15048,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(), @@ -14799,7 +15059,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(), @@ -14813,9 +15073,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); } } @@ -14835,8 +15093,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(), @@ -14847,9 +15104,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(), @@ -14860,8 +15115,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(), @@ -14875,9 +15130,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(), @@ -14914,8 +15167,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(), @@ -15306,8 +15558,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( @@ -15317,10 +15569,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() @@ -15582,14 +15834,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 { @@ -15603,8 +15854,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 { @@ -15635,16 +15886,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() { @@ -15668,8 +15916,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, }, @@ -15891,7 +16139,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()) @@ -16144,9 +16392,9 @@ pub fn emit_typed_record_lit( }; 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())) + && (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())) { Some(rt_name.clone()) } else { @@ -16158,7 +16406,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() @@ -16177,8 +16425,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() { @@ -16218,8 +16465,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, }); @@ -16381,18 +16628,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(), + si.clone(), + ) { + Some(_) => true, + None => false, + }, None => false, }; (has_zv.clone() @@ -16416,10 +16658,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(), si.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![]), }, @@ -16435,7 +16674,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( @@ -16459,13 +16739,13 @@ pub fn rust_zero_value( type_name: String, source_indices: Rc>>, ) -> Option { - if (type_name.clone().as_str() == "Int".to_string().as_str()) { + 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 (type_name.clone() == "String".to_string()) { if rust_emit_faithful_text_carrier(source_indices) { Some( "crate::v2_std_algebra::freemonoid_empty::()" @@ -16534,7 +16814,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), + l_str, scope.type_env.clone().source_indices.clone(), ), ), @@ -16548,7 +16828,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), + r_str, scope.type_env.clone().source_indices.clone(), ), ), @@ -16581,7 +16861,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str.clone(), + l_str, scope .type_env .clone() @@ -16596,7 +16876,7 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str.clone(), + r_str, scope.type_env.clone().source_indices.clone(), ), ), @@ -16730,7 +17010,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); } } @@ -16916,9 +17196,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; @@ -17272,9 +17550,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; @@ -17561,8 +17837,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( @@ -17572,10 +17848,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() @@ -17645,10 +17921,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() { @@ -18020,7 +18293,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() { @@ -18045,7 +18318,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() @@ -18113,7 +18386,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()) }, @@ -18178,14 +18451,15 @@ pub fn emit_operation_method( Rc::new(vec![]), shared_types.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()) @@ -18520,7 +18794,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); } } @@ -18850,7 +19124,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()) } } @@ -18861,8 +19135,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); } @@ -18916,8 +19190,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; @@ -18935,8 +19209,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); } @@ -18955,7 +19229,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()) @@ -18973,7 +19247,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 { { @@ -18984,7 +19258,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, } } @@ -19035,7 +19309,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); } @@ -19151,7 +19425,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); } } @@ -19238,9 +19512,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( @@ -19248,7 +19521,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(), + source_indices, ), ), ").ok_or(\"missing field: ".to_string(), @@ -19258,7 +19531,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(), @@ -19267,7 +19540,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(), @@ -19276,7 +19549,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(), @@ -19434,8 +19707,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, }; @@ -19525,15 +19797,15 @@ pub fn emit_response_arm( 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); @@ -19588,7 +19860,7 @@ 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()) } } @@ -19614,8 +19886,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; @@ -19637,16 +19909,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(), source_indices.clone())), ") },".to_string()) }; v1_rt::concat( v1_rt::concat( @@ -19674,12 +19937,12 @@ pub fn emit_exit_arm( { 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( @@ -19692,22 +19955,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(), source_indices.clone())), ") },".to_string()) } } } @@ -20068,7 +20316,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() @@ -20095,13 +20343,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() @@ -20244,14 +20492,15 @@ pub fn emit_capability_method( Rc::new(vec![]), shared_types.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()) @@ -20349,8 +20598,8 @@ pub fn emit_data_def( shared_types.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(), @@ -20362,12 +20611,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( @@ -20669,38 +20916,35 @@ 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(), + scope + .type_env + .clone() + .source_indices + .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(), ) }); } @@ -20835,14 +21079,6 @@ pub fn emit_test_file( pub fn rust_test_signature_comment(projection: Rc) -> String { { - 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: projection.source_indices.clone(), - intern_table: empty_intern_table(), - }); let params_str = Rc::new({ let mut __result = Vec::new(); for p in projection.params.clone().iter().cloned() { @@ -20856,7 +21092,7 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { Rc::new(vec![]), v1_rt::rc_empty_set::(), projection.source_indices.clone(), - stub_env.clone(), + v1_rt::rc_empty_map::(), ), )); } @@ -20909,7 +21145,7 @@ 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() @@ -21011,8 +21247,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![ @@ -21112,8 +21348,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); } @@ -21323,9 +21559,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(), @@ -21898,11 +22131,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 { @@ -21973,7 +22213,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( @@ -22008,15 +22248,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 ec4d51a09a6..ab745a18038 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -163,8 +163,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 +546,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 +574,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 +750,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 +881,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 +902,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 +936,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 +947,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 +959,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 +1003,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 +1173,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 +1190,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 +1209,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 +1341,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 +1357,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 +1373,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 +1410,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 +1448,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 +1498,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 +1571,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 +1614,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 +1666,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 +1681,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 +1729,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 +1857,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 +2113,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 +2122,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 +2251,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 +2265,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 +2339,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 +2747,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 +3402,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 +3466,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 +3539,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 +4275,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 +5279,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 +5353,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 +5481,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 +5817,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 +5909,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 +6006,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 +6062,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 +6073,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 +6087,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 +6130,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 +6161,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 +6282,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 +6482,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 +6494,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 +6565,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 +6624,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 +6704,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 +6847,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 +6992,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 +7034,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 +7252,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 +7298,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 +7442,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 +7486,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 +7504,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 +7646,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 +7786,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 +7833,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 +7850,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 +7861,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 +7873,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 +7901,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 +8040,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 +8049,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 +8073,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 +8086,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 +8127,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 +8151,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 +8188,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 +8213,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 +8306,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 +8423,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 +8527,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 +8573,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 +8583,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 +8887,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 +8953,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 +9002,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 +9011,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 +9167,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 +9355,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 +9767,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 +9926,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 +9978,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 +10002,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 +10039,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 +10323,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 +10616,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 +11040,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 +11058,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 +11083,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 +11108,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 +11167,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 +11194,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 +11249,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 +11271,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( @@ -11826,7 +11748,7 @@ pub fn build_type_env( let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { __found = true; break; } @@ -11834,8 +11756,7 @@ pub fn build_type_env( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = if ((module_name_str.clone().as_str() - != "std.types".to_string().as_str()) + let std_types_parent_env = if ((module_name_str.clone() != "std.types".to_string()) && (imports_std_types == false)) { match v1_rt::map_get(&parent_index, "std.types".to_string()) { @@ -11868,7 +11789,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(), )) @@ -12443,7 +12364,7 @@ pub fn build_type_env_unresolved( let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (imp.module_path.clone() == "std.types".to_string()) { __found = true; break; } @@ -12451,17 +12372,15 @@ pub fn build_type_env_unresolved( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = if ((module_name_str.as_str() - != "std.types".to_string().as_str()) - && (imports_std_types == false)) - { - match v1_rt::map_get(&parent_index, "std.types".to_string()) { - Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let std_types_parent_env = + if ((module_name_str != "std.types".to_string()) && (imports_std_types == false)) { + match v1_rt::map_get(&parent_index, "std.types".to_string()) { + Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let imported_parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12485,7 +12404,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(), )) @@ -13399,8 +13318,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)) { @@ -13613,9 +13532,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, }) } diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index e06cb29b877..80801b55852 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -27,7 +27,7 @@ pub fn compute_in_graph_deps( let local = Rc::new({ let mut __result = Vec::new(); for d in deps.clone().iter().cloned() { - if ((d.clone().as_str() != name.clone().as_str()) + if ((d.clone() != name.clone()) && v1_rt::set_contains(&name_set, d.clone())) { __result.push(d); @@ -250,7 +250,7 @@ pub fn detect_type_cycles_kahn( Some(deps) => { let mut __found = false; for d in deps.clone().iter().cloned() { - if (d.clone().as_str() == name.clone().as_str()) { + if (d.clone() == name.clone()) { __found = true; break; } 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..46b10002315 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -453,9 +453,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 { diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 34a7f135c98..b71b0e74f5c 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -97,8 +97,8 @@ pub fn is_inductive_field( { let mut __found = false; for f in inductive_fields_for(env, type_name).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())) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 6f94f923962..f8f68621146 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -225,3 +225,10 @@ pub fn variant_locals_from_items( }, ) } + +pub struct FnItem; +pub struct FuncItem; +pub struct TypeItem; +pub struct DataItem; +pub struct ServiceItem; +pub struct OtherItem; diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 72331fe9761..8ecd32b5f56 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -57,8 +57,7 @@ pub fn is_type_variable(inferred: Rc) -> bool { } 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)] @@ -92,7 +91,7 @@ pub fn lookup_field_type_node( if is_optional { { let inner = with_required_cardinality(n.clone()); - if (field_name.clone().as_str() == "value".to_string().as_str()) { + if (field_name.clone() == "value".to_string()) { Some(inner) } else { match lookup_field_type_node(inner, field_name.clone(), source_indices.clone()) @@ -116,8 +115,7 @@ pub fn lookup_field_type_node( ) { Some(field_child) => { if (node_is_keyed_collection(n.clone(), source_indices.clone()) - && (field_name.clone().as_str() - == "lookup".to_string().as_str())) + && (field_name.clone() == "lookup".to_string())) { { let value_child = @@ -237,16 +235,15 @@ pub fn resolve_scrutinee_type_node_seen( let canonical = authored_name(env.clone(), normed.clone()); if (normed.inferred.clone() != None) { { - 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) - }; + let next_seen = if (canonical.clone() == "".to_string()) { + seen.clone() + } else { + v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) + }; match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - if ((((authored_name(env.clone(), target.clone()).as_str() - == canonical.clone().as_str()) + if ((((authored_name(env.clone(), target.clone()) + == canonical.clone()) && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) @@ -264,23 +261,21 @@ pub fn resolve_scrutinee_type_node_seen( } } } else { - if ((canonical.clone().as_str() != "".to_string().as_str()) + if ((canonical.clone() != "".to_string()) && emit_map_has(seen.clone(), canonical.clone())) { nominal_type_ref(canonical.clone()) } else { { - 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) - }; + let next_seen = if (canonical.clone() == "".to_string()) { + seen.clone() + } else { + v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) + }; match lookup_type_for(env.clone(), normed.clone()) { Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) - .as_str() - == canonical.clone().as_str()) + == canonical.clone()) && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) @@ -381,7 +376,7 @@ pub fn field_summary_for_type( let resolved = resolve_scrutinee_type_node(env.clone(), base_type); let normed = normalize_access_type_node(resolved.clone()); let normed_opt = (normed.return_cardinality.clone() == Cardinality::CardOptional); - if ((field.clone().as_str() == "value".to_string().as_str()) && normed_opt.clone()) { + if ((field.clone() == "value".to_string()) && normed_opt.clone()) { Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::OptionalUnwrap, value_shape: FieldValueShape::PlainValue, @@ -469,7 +464,7 @@ pub fn map_lookup_result_type( field: Rc, source_indices: Rc>>, ) -> Option> { - if (authored_name_at(source_indices.clone(), product).as_str() == "Map".to_string().as_str()) { + if (authored_name_at(source_indices.clone(), product) == "Map".to_string()) { match product_field_result_type(field) { Some(raw) => { if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { @@ -498,17 +493,14 @@ pub fn lookup_field_in_product( let matching = Rc::new({ let mut __result = Vec::new(); for c in product.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()).as_str() - == method_name.clone().as_str()) - { + if (authored_name_at(source_indices.clone(), c.clone()) == method_name.clone()) { __result.push(c); } } __result }); match matching.first().cloned() { - Some(field) => match if (method_name.clone().as_str() == "lookup".to_string().as_str()) - { + Some(field) => match if (method_name.clone() == "lookup".to_string()) { map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) } else { None @@ -583,9 +575,7 @@ pub fn lookup_structural_method( Rc::new({ let mut __result = Vec::new(); for t in templates.iter().cloned() { - if (t.name.clone().as_str() - == method_name.clone().as_str()) - { + if (t.name.clone() == method_name.clone()) { __result.push(t); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 2cbb1838368..0d601ca6166 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -192,11 +192,6 @@ pub fn builtin_function_registry() -> Rc>> { "extdeps_dead_param_count_for_operation".to_string(), int_type(), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "shell_materialize_argv_for_operation".to_string(), - list_of_element(string_type()), - ); let m = v1_rt::rc_map_insert( m.clone(), "extdeps_dead_param_count_for_path".to_string(), @@ -252,36 +247,6 @@ pub fn builtin_function_registry() -> Rc>> { "transport_script_literal_violation_count_for_path".to_string(), int_type(), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "layer_import_facts".to_string(), - list_of_type_variable("layer_import_fact_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "import_resolution_facts".to_string(), - list_of_type_variable("import_resolution_fact_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_coexistence_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_diverged_fork_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_is_coexistence".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_is_diverged_fork".to_string(), - bool_type(), - ); let m = v1_rt::rc_map_insert( m.clone(), "languages_consumer_census_data_decl_count".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 84910fc453a..09d2fd66b4b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -35,8 +35,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)] @@ -356,34 +355,33 @@ pub fn lookup_variant_in_type( } else { { let optional_cardinality_subject = (scrut_opt.clone() - && (authored_name_at(source_indices.clone(), scrut_node.clone()).as_str() - != "Optional".to_string().as_str())); + && (authored_name_at(source_indices.clone(), scrut_node.clone()) + != "Optional".to_string())); let witness_subject = (is_witness_type_name(authored_name_at( source_indices.clone(), scrut_node.clone(), )) && ((scrut_node.children.clone().len() as i64) == 1)); if (optional_cardinality_subject.clone() - && (variant_name.clone().as_str() == "Present".to_string().as_str())) + && (variant_name.clone() == "Present".to_string())) { node_lookup_resolved(synthesize_optional_present_variant( scrut_node.clone(), )) } else { if (optional_cardinality_subject.clone() - && (variant_name.clone().as_str() == "Absent".to_string().as_str())) + && (variant_name.clone() == "Absent".to_string())) { node_lookup_resolved(none_type()) } else { if (witness_subject.clone() - && (variant_name.clone().as_str() == "Holds".to_string().as_str())) + && (variant_name.clone() == "Holds".to_string())) { node_lookup_resolved(synthesize_witness_holds_variant( scrut_node.clone(), )) } else { if (witness_subject.clone() - && (variant_name.clone().as_str() - == "Violates".to_string().as_str())) + && (variant_name.clone() == "Violates".to_string())) { node_lookup_resolved(synthesize_witness_violates_variant( scrut_node.clone(), @@ -394,13 +392,10 @@ pub fn lookup_variant_in_type( source_indices.clone(), scrut_node.clone(), ); - let optional_coproduct_subject = - ((scrut_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 optional_coproduct_subject = ((scrut_name.clone() + == "Optional".to_string()) + && ((variant_name.clone() == "Present".to_string()) + || (variant_name.clone() == "Absent".to_string()))); let direct_match = find_child_named( scrut_node.clone(), variant_name.clone(), @@ -409,14 +404,12 @@ pub fn lookup_variant_in_type( let record_destructure = (((field_binding_count > 0) && (scrut_node.connective.clone() == Connective::Conj)) - && (scrut_name.clone().as_str() - == variant_name.clone().as_str())); + && (scrut_name.clone() == variant_name.clone())); let fallback = if record_destructure { node_lookup_resolved(scrut_node.clone()) } else { if (optional_coproduct_subject.clone() - && (variant_name.clone().as_str() - == "Present".to_string().as_str())) + && (variant_name.clone() == "Present".to_string())) { node_lookup_resolved( synthesize_optional_present_variant( @@ -425,8 +418,8 @@ pub fn lookup_variant_in_type( ) } else { if (optional_coproduct_subject.clone() - && (variant_name.clone().as_str() - == "Absent".to_string().as_str())) + && (variant_name.clone() + == "Absent".to_string())) { node_lookup_resolved(none_type()) } else { diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index c6f8c18b5e4..2647173a217 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -74,8 +74,8 @@ pub fn unit_variant_in_coproduct( if (acc.clone() != None) { acc.clone() } else { - if ((authored_name_at(env.source_indices.clone(), v.clone()).as_str() - == variant_name.clone().as_str()) + if ((authored_name_at(env.source_indices.clone(), v.clone()) + == variant_name.clone()) && is_unit_variant_node(v.clone())) { Some(v.clone()) @@ -188,9 +188,8 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if (((brand_name.clone().as_str() != "".to_string().as_str()) - && (brand_name.clone().as_str() - != authored_name_at(source_indices, structural.clone()).as_str())) + if (((brand_name.clone() != "".to_string()) + && (brand_name.clone() != authored_name_at(source_indices, structural.clone()))) && !is_declared_container_alias_spelling(brand_name.clone())) { with_authored_identity(identity, structural.clone()) @@ -232,9 +231,9 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S .resolved .clone() }; - if (((brand.clone().as_str() != "".to_string().as_str()) - && (brand.clone().as_str() - != authored_name_at(source_indices.clone(), structural.clone()).as_str())) + if (((brand.clone() != "".to_string()) + && (brand.clone() + != authored_name_at(source_indices.clone(), structural.clone()))) && !is_declared_container_alias_spelling(brand.clone())) { with_authored_identity(n.clone(), structural.clone()) @@ -346,8 +345,8 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { decl.clone() } else { if ((((n.children.clone().len() as i64) > 0) - && (n.name.clone().as_str() != "".to_string().as_str())) - && (n.name.clone().as_str() != brand.as_str())) + && (n.name.clone() != "".to_string())) + && (n.name.clone() != brand)) { match lookup_type_by_name(env.clone(), n.name.clone()) { Some(structural) => structural.clone(), @@ -417,8 +416,8 @@ pub fn substitute_type_slots( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.push( - if (authored_name_at(source_indices.clone(), child.clone()).as_str() - == decl_name.clone().as_str()) + if (authored_name_at(source_indices.clone(), child.clone()) + == decl_name.clone()) { { let substituted_args = Rc::new({ @@ -839,17 +838,14 @@ pub fn resolve_node_bounded( let field_rt = resolved_type( field_child.clone(), ); - let is_self_ref = ((authored_name( - env.clone(), - field_rt.clone(), - ) - .as_str() - == authored_name( + let is_self_ref = + ((authored_name( + env.clone(), + field_rt.clone(), + ) == authored_name( env.clone(), n.clone(), - ) - .as_str()) - && ((field_rt + )) && ((field_rt .children .clone() .len() @@ -2015,9 +2011,6 @@ pub fn resolve_expr_types( descent_evidence: de, .. } => { - // bind-once: resolve each arg child a SINGLE time, then split - // into resolved children + diagnostics. Resolving twice made a - // nested constructor literal O(2^depth). let arg_results = Rc::new({ let mut __result = Vec::new(); for arg_node in texpr.children.clone().iter().cloned() { @@ -2047,14 +2040,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.iter().cloned() { + for r in arg_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.iter().cloned() { + for r in arg_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2078,7 +2071,6 @@ pub fn resolve_expr_types( method_semantics: ms, .. } => { - // bind-once: resolve each child a SINGLE time (see ExprCall). let mc_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2144,14 +2136,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.iter().cloned() { + for r in mc_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.iter().cloned() { + for r in mc_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2171,7 +2163,6 @@ pub fn resolve_expr_types( }) } ExprData::ExprMatch => { - // bind-once: resolve each scrutinee/arm a SINGLE time (see ExprCall). let match_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2282,14 +2273,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in match_results.iter().cloned() { + for r in match_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in match_results.iter().cloned() { + for r in match_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2390,9 +2381,6 @@ pub fn resolve_expr_types( ExprData::ExprRecordLit { parent_enum: pe, .. } => { - // bind-once: resolve each field-init value a SINGLE time. This is - // the arm hit by deep nested constructor literals (Cons/record - // chains) — resolving twice per field was O(2^depth). let fi_results = Rc::new({ let mut __result = Vec::new(); for fi_node in texpr.children.clone().iter().cloned() { @@ -2418,14 +2406,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.iter().cloned() { + for r in fi_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.iter().cloned() { + for r in fi_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2559,7 +2547,6 @@ pub fn resolve_expr_types( }) } ExprData::ExprStringInterp => { - // bind-once: resolve each interpolation part a SINGLE time (see ExprCall). let part_results = Rc::new({ let mut __result = Vec::new(); for part_node in texpr.children.clone().iter().cloned() { @@ -2594,14 +2581,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in part_results.iter().cloned() { + for r in part_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in part_results.iter().cloned() { + for r in part_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2817,9 +2804,8 @@ pub fn fn_type_param_names( for p in Rc::new({ let mut __result = Vec::new(); for p in item.params.clone().iter().cloned() { - if (param_node_name_at(p.clone(), source_indices.clone()).as_str() - == authored_name_at(source_indices.clone(), param_node_type_expr(p.clone())) - .as_str()) + if (param_node_name_at(p.clone(), source_indices.clone()) + == authored_name_at(source_indices.clone(), param_node_type_expr(p.clone()))) { __result.push(p); } @@ -2866,7 +2852,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { .iter() .cloned() { - if (other.clone().as_str() == s.clone().as_str()) { + if (other.clone() == s.clone()) { __found = true; break; } @@ -3316,3 +3302,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }) }) } + +pub struct AliasParameterized; +pub struct AliasLeaf; +pub struct AliasPassthrough; diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index f4617b9f287..76923b77bc0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -223,7 +223,7 @@ let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.c Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), }).iter().cloned()); } __result }); -let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: String| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (s.clone().as_str() == svc.clone().as_str()) { __found = true; break; } } __found } { +let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: String| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (s.clone() == svc.clone()) { __found = true; break; } } __found } { svc_list.clone() } else { v1_rt::rc_list_push(svc_list.clone(), svc.clone()) @@ -331,7 +331,7 @@ pub fn check_service_method_call_node( let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.clone().iter().cloned() { - if (op.name.clone().as_str() == method.clone().as_str()) { + if (op.name.clone() == method.clone()) { __result.push(op); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index eb42df493d0..50aaab3357e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -139,7 +139,7 @@ pub fn func_reaches_self( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (e.caller.clone().as_str() == current.clone().as_str()) { + if (e.caller.clone() == current.clone()) { __result.push(e); } } @@ -155,7 +155,7 @@ pub fn func_reaches_self( { let mut __found = false; for c in callees.iter().cloned() { - if if (c.clone().as_str() == root.clone().as_str()) { + if if (c.clone() == root.clone()) { true } else { func_reaches_self( @@ -296,7 +296,7 @@ pub fn topo_resolve_loop( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (e.caller.clone().as_str() == fn_name.clone().as_str()) { + if (e.caller.clone() == fn_name.clone()) { __result.push(e); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 8f708772956..ed5a74b13f6 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -132,8 +132,7 @@ pub fn node_is_set_collection( source_indices: Rc>>, ) -> bool { (node_is_element_collection(n.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), n.clone()).as_str() - == "Set".to_string().as_str())) + && (authored_name_at(source_indices.clone(), n.clone()) == "Set".to_string())) } pub fn canonical_template_name( @@ -160,7 +159,7 @@ pub fn structural_carrier_template_name( n: Rc, source_indices: Rc>>, ) -> String { - if (n.name.clone().as_str() != "".to_string().as_str()) { + if (n.name.clone() != "".to_string()) { canonical_template_name( Rc::new(Node { name: n.name.clone(), @@ -1096,9 +1095,7 @@ pub fn unify_template( } ContainerSource::Named { name: n, .. } => n.clone(), }; - if (authored_name_at(source_indices.clone(), concrete.clone()).as_str() - != expected_name.as_str()) - { + if (authored_name_at(source_indices.clone(), concrete.clone()) != expected_name) { subst.clone() } else { match concrete.children.clone().first().cloned() { @@ -1661,8 +1658,8 @@ pub fn node_type_shape( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (authored_name_at(source_indices.clone(), rt.clone()).as_str() - != "None".to_string().as_str())) + && (authored_name_at(source_indices.clone(), rt.clone()) + != "None".to_string())) && (is_kernel_type(authored_name_at( source_indices.clone(), rt.clone(), @@ -1809,9 +1806,7 @@ pub fn node_type_compatible( node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { if (canonical_template_name(left.clone(), source_indices.clone()) - .as_str() - != canonical_template_name(right.clone(), source_indices.clone()) - .as_str()) + != canonical_template_name(right.clone(), source_indices.clone())) { break false; } else { @@ -1850,18 +1845,16 @@ pub fn node_type_compatible( if (((((canonical_template_name( left.clone(), source_indices.clone(), - ) - .as_str() - == canonical_template_name( - right.clone(), - source_indices.clone(), - ) - .as_str()) - && (authored_name_at(source_indices.clone(), left.clone()) - .as_str() - != authored_name_at(source_indices.clone(), right.clone()) - .as_str())) - && ((left.children.clone().len() as i64) == 1)) + ) == canonical_template_name( + right.clone(), + source_indices.clone(), + )) && (authored_name_at( + source_indices.clone(), + left.clone(), + ) != authored_name_at( + source_indices.clone(), + right.clone(), + ))) && ((left.children.clone().len() as i64) == 1)) && ((right.children.clone().len() as i64) == 1)) && (is_declared_container_alias_spelling(authored_name_at( source_indices.clone(), @@ -1924,13 +1917,10 @@ pub fn node_type_compatible( break (authored_name_at( source_indices.clone(), left.clone(), - ) - .as_str() - == authored_name_at( - source_indices.clone(), - right.clone(), - ) - .as_str()); + ) == authored_name_at( + source_indices.clone(), + right.clone(), + )); } } } @@ -1974,8 +1964,7 @@ pub fn prefer_specific_type( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); let right_is_optional = (right.return_cardinality.clone() == Cardinality::CardOptional); let same_kind = if (left_is_container.clone() && right_is_container) { - (left_norm_name.as_str() - == authored_name_at(source_indices.clone(), right.clone()).as_str()) + (left_norm_name == authored_name_at(source_indices.clone(), right.clone())) } else { if (left_is_optional.clone() && right_is_optional) { true @@ -2076,10 +2065,10 @@ pub fn node_type_equals_core( let left_name = authored_name_at(source_indices.clone(), left.clone()); let right_name = authored_name_at(source_indices.clone(), right.clone()); if (left_leaf.clone() && right_leaf.clone()) { - (left_name.as_str() == right_name.as_str()) + (left_name == right_name) } else { if (left_struct.clone() && right_struct.clone()) { - if (left_name.as_str() != right_name.as_str()) { + if (left_name != right_name) { false } else { if ((left.connective.clone() == Connective::Conj) @@ -2130,10 +2119,10 @@ pub fn node_type_equals_core( } } else { if (left_leaf.clone() && right_struct.clone()) { - (left_name.as_str() == right_name.as_str()) + (left_name == right_name) } else { if (left_struct.clone() && right_leaf.clone()) { - (left_name.as_str() == right_name.as_str()) + (left_name == right_name) } else { { let left_is_container = @@ -2141,7 +2130,7 @@ pub fn node_type_equals_core( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { - if (left_name.as_str() != right_name.as_str()) { + if (left_name != right_name) { false } else { match left.children.clone().first().cloned() { @@ -2338,8 +2327,8 @@ pub fn node_type_deps( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (authored_name_at(source_indices.clone(), rt.clone()).as_str() - != "None".to_string().as_str())) + && (authored_name_at(source_indices.clone(), rt.clone()) + != "None".to_string())) && (is_kernel_type(authored_name_at(source_indices.clone(), rt.clone())) == false)) } @@ -2411,7 +2400,7 @@ pub fn node_type_deps( } } else { if ((is_kernel_type(n_name.clone()) - || (n_name.clone().as_str() == "None".to_string().as_str())) + || (n_name.clone() == "None".to_string())) || (n.ident_span.clone() == None)) { Rc::new(vec![]) @@ -2472,7 +2461,7 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { if is_optional { with_required_cardinality(n.clone()) } else { - if ((n.name.clone().as_str() == "Optional".to_string().as_str()) + if ((n.name.clone() == "Optional".to_string()) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { @@ -2683,8 +2672,7 @@ pub fn for_each_element_type_node( if ((((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) == 0)) && ((normed.properties.clone().len() as i64) == 0)) - && (authored_name_at(source_indices, normed.clone()).as_str() - == "String".to_string().as_str())) + && (authored_name_at(source_indices, normed.clone()) == "String".to_string())) { string_type() } else { diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index 55bfc8d5028..48cc3ac7710 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -1282,7 +1282,7 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Rust => { let mut __found = false; for t in rust_string_types().iter().cloned() { - if (t.clone().as_str() == name.clone().as_str()) { + if (t.clone() == name.clone()) { __found = true; break; } @@ -1292,7 +1292,7 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Go => { let mut __found = false; for t in go_string_types().iter().cloned() { - if (t.clone().as_str() == name.clone().as_str()) { + if (t.clone() == name.clone()) { __found = true; break; } @@ -1302,7 +1302,7 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Python => { let mut __found = false; for t in python_string_types().iter().cloned() { - if (t.clone().as_str() == name.clone().as_str()) { + if (t.clone() == name.clone()) { __found = true; break; } @@ -1345,3 +1345,13 @@ pub fn wrap_shared_type(target: RenderTarget, inner: String) -> String { v1_rt::replace(tmpl, "{0}".to_string(), inner) } } + +pub struct SnakeCaseTestNames; +pub struct PascalCaseTestNames; +pub struct IfExpression; +pub struct ConditionalTernary; +pub struct IfStatement; +pub struct MatchExpression; +pub struct MatchStatementArmReturn; +pub struct PascalCase; +pub struct CamelCase; diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 881d0355c8b..6f6a1fd17f3 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -314,14 +314,12 @@ pub fn walk_expr( } ExprData::ExprCall { .. } => { let fname = expr_call_func_at(texpr.clone(), si.clone()); - if (fname.as_str() == "fold".to_string().as_str()) { + if (fname == "fold".to_string()) { { let init_arg = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - == "init".to_string().as_str()) - { + if (authored_name_at(si.clone(), a.clone()) == "init".to_string()) { __result.push(a); } } @@ -354,9 +352,7 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - != "init".to_string().as_str()) - { + if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { __result.push(a); } } @@ -382,15 +378,13 @@ pub fn walk_expr( let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let mname = expr_method_name_at(texpr.clone(), si.clone()); - if (mname.as_str() == "fold".to_string().as_str()) { + if (mname == "fold".to_string()) { { let recv_accum = walk_expr(accum, recv, false, si.clone()); let init_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - == "init".to_string().as_str()) - { + if (authored_name_at(si.clone(), a.clone()) == "init".to_string()) { __result.push(a); } } @@ -423,9 +417,7 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - != "init".to_string().as_str()) - { + if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { __result.push(a); } } @@ -931,9 +923,7 @@ pub fn summarize_fold_acc_uses( ExprData::ExprVar { binding_kind: _, .. } => { - if (expr_var_name_at(node.clone(), si.clone()).as_str() - == acc_name.clone().as_str()) - { + if (expr_var_name_at(node.clone(), si.clone()) == acc_name.clone()) { if inside_nested.clone() { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, @@ -956,10 +946,7 @@ pub fn summarize_fold_acc_uses( let is_direct = match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => { - (expr_var_name_at(base.clone(), si.clone()).as_str() - == acc_name.clone().as_str()) - } + } => (expr_var_name_at(base.clone(), si.clone()) == acc_name.clone()), _ => false, }; if is_direct { @@ -1085,7 +1072,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal.clone()).as_str() == acc_type_name.as_str()) + (authored_name_at(si, terminal.clone()) == acc_type_name) } _ => false, } @@ -1178,8 +1165,7 @@ pub fn analyze_single_fold( acc_param_name.clone(), si.clone(), ); - let eligible = ((cond_required - && (acc_type_name.clone().as_str() != "".to_string().as_str())) + let eligible = ((cond_required && (acc_type_name.clone() != "".to_string())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { site_key: (method_call.span.clone().start.clone()).to_string(), @@ -1246,3 +1232,8 @@ pub fn analyze_ownership( }) } } + +pub struct Consumed; +pub struct Read; +pub struct Threaded; +pub struct Projected; diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index e5170bf42d7..a58b1c11ef3 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -1146,7 +1146,7 @@ pub fn is_pipe_arrow_shape(shape: TokenShape) -> bool { pub fn tok_is_keyword(tok: Option>, kw: String) -> bool { match tok { - Some(t) => (is_keyword_shape(t.shape.clone()) && (t.text.clone().as_str() == kw.as_str())), + Some(t) => (is_keyword_shape(t.shape.clone()) && (t.text.clone() == kw)), None => false, } } @@ -1173,7 +1173,7 @@ pub fn tok_is_ident(tok: Option>) -> bool { pub fn tok_is_ident_text(tok: Option>, text: String) -> bool { match tok { - Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == text.as_str())), + Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone() == text)), None => false, } } @@ -1198,8 +1198,7 @@ pub fn drop_leading_type_modifier( pub fn drop_leading_test_marker(tokens: Rc>>) -> Rc>> { if (tok_is_ident_text(tokens.clone().first().cloned(), "test".to_string()) - && (tok_keyword_text(tokens.clone().get(1 as usize).cloned()).as_str() - != "".to_string().as_str())) + && (tok_keyword_text(tokens.clone().get(1 as usize).cloned()) != "".to_string())) { Rc::new( tokens @@ -1479,8 +1478,7 @@ pub fn expected_token_name(expected: Rc) -> String { pub fn token_matches_expected(token: Rc, expected: Rc) -> bool { match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => { - (is_keyword_shape(token.shape.clone()) - && (token.text.clone().as_str() == kw.clone().as_str())) + (is_keyword_shape(token.shape.clone()) && (token.text.clone() == kw.clone())) } ExpectedToken::ExpectLBrace => is_lbrace_shape(token.shape.clone()), ExpectedToken::ExpectRBrace => is_rbrace_shape(token.shape.clone()), @@ -1785,8 +1783,8 @@ pub fn parser_helper_state_arg_expr( let arg_node = pair.1.clone(); let matches_state = match arg_name_at(arg_node.clone(), source_indices.clone()) { Some(name) => { - ((name.clone().as_str() == "state".to_string().as_str()) - || (name.clone().as_str() == "tokens".to_string().as_str())) + ((name.clone() == "state".to_string()) + || (name.clone() == "tokens".to_string())) } None => (idx.clone() == 0), }; @@ -1807,8 +1805,8 @@ pub fn parser_progress_flag_var( match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), source_indices.clone()); - if ((field.clone().as_str() == "consumed".to_string().as_str()) - || (field.clone().as_str() == "changed".to_string().as_str())) + if ((field.clone() == "consumed".to_string()) + || (field.clone() == "changed".to_string())) { parser_result_base_var(expr.clone(), source_indices.clone()) } else { @@ -1820,13 +1818,13 @@ pub fn parser_progress_flag_var( } pub fn parser_helper_identity(callee: String) -> Option { - if (callee.clone().as_str() == "skip_newlines".to_string().as_str()) { + if (callee.clone() == "skip_newlines".to_string()) { Some(ParserHelperIdentity::ParserHelperSkipNewlines) } else { - if (callee.clone().as_str() == "skip_continuation_newlines".to_string().as_str()) { + if (callee.clone() == "skip_continuation_newlines".to_string()) { Some(ParserHelperIdentity::ParserHelperSkipContinuationNewlines) } else { - if (callee.clone().as_str() == "with".to_string().as_str()) { + if (callee.clone() == "with".to_string()) { Some(ParserHelperIdentity::ParserHelperWith) } else { None @@ -1891,7 +1889,7 @@ pub fn leaf_type_node(name: String, span: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: span.clone(), - ident_span: if (name.clone().as_str() == "".to_string().as_str()) { + ident_span: if (name.clone() == "".to_string()) { None } else { Some(span.clone()) @@ -2487,7 +2485,7 @@ pub fn find_item_form(forms: Rc>>, keyword: String) -> Option { - let min_val = if (r.arg_name.clone().as_str() == "min".to_string().as_str()) { + let min_val = if (r.arg_name.clone() == "min".to_string()) { Some(r.arg_value.clone()) } else { None }; - let max_val = if (r.arg_name.clone().as_str() == "max".to_string().as_str()) { + let max_val = if (r.arg_name.clone() == "max".to_string()) { Some(r.arg_value.clone()) } else { None @@ -4564,7 +4562,7 @@ pub fn parse_type_expr(tokens: Rc>>, ctx: Rc) -> Rc< }) } Some(TokenShape::ShKeyword) => { - if (tok.clone().unwrap().text.clone().as_str() == "fn".to_string().as_str()) { + if (tok.clone().unwrap().text.clone() == "fn".to_string()) { parse_callable_type_expr( Rc::new( tokens @@ -5173,7 +5171,7 @@ pub fn parse_optional_from_key( }; match sh { Some(TokenShape::ShIdent) => { - if (tok.clone().unwrap().text.clone().as_str() == "from".to_string().as_str()) { + if (tok.clone().unwrap().text.clone() == "from".to_string()) { { let tok2 = tokens.clone().get(1 as usize).cloned(); let sh2 = match tok2.clone() { @@ -5512,7 +5510,7 @@ pub fn parse_func_def(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> R let tokens = skip_newlines(tokens.clone()); let tok = tokens.clone().first().cloned(); let is_uses = match tok { - Some(t) => { - (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "uses".to_string().as_str())) - } + Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone() == "uses".to_string())), None => false, }; if is_uses { @@ -6355,7 +6350,7 @@ pub fn parse_service_entries( match sh { Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (id.clone().as_str() == "config".to_string().as_str()) { + if (id.clone() == "config".to_string()) { let r = expect( Rc::new( tokens @@ -6413,7 +6408,7 @@ pub fn parse_service_entries( continue; } } else { - if (id.clone().as_str() == "transport".to_string().as_str()) { + if (id.clone() == "transport".to_string()) { let r = parse_transport_binding( Rc::new( tokens @@ -6462,7 +6457,7 @@ pub fn parse_service_entries( } Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text.as_str() == "operation".to_string().as_str()) { + if (kw_text == "operation".to_string()) { let r = parse_operation_def(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ServiceBodyResult { @@ -6674,7 +6669,7 @@ pub fn parse_transport_binding( }; match sh { Some(TokenShape::ShIdent) => { - if (tok_text.clone().as_str() == "rest".to_string().as_str()) { + if (tok_text.clone() == "rest".to_string()) { { let r = expect( Rc::new( @@ -6725,7 +6720,7 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text.clone().as_str() == "shell".to_string().as_str()) { + if (tok_text.clone() == "shell".to_string()) { { let r = expect( Rc::new( @@ -6778,7 +6773,7 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text.clone().as_str() == "file".to_string().as_str()) { + if (tok_text.clone() == "file".to_string()) { { let r = expect( Rc::new( @@ -6950,52 +6945,49 @@ pub fn parse_rest_fields( EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; ctx = r3.ctx.clone(); - if (fname.clone().as_str() == transport_url_key().as_str()) { + if (fname.clone() == transport_url_key()) { { let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_method_key().as_str()) { + if (fname.clone() == transport_method_key()) { { let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_path_template_key().as_str()) { + if (fname.clone() == transport_path_template_key()) { { let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_query_key().as_str()) { + if (fname.clone() == transport_query_key()) { { let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_body_key().as_str()) { + if (fname.clone() == transport_body_key()) { { let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { - if (fname.clone().as_str() - == transport_response_format_key().as_str()) - { + if (fname.clone() == transport_response_format_key()) { { let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_headers_key().as_str()) - { + if (fname.clone() == transport_headers_key()) { let h = match (*r3.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { @@ -7074,7 +7066,7 @@ pub fn parse_shell_fields( err: r2.err.clone(), }); } - if (fname.clone().as_str() == "argv".to_string().as_str()) { + if (fname.clone() == "argv".to_string()) { let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectLBracket)); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7119,7 +7111,7 @@ pub fn parse_shell_fields( continue; } } else { - if (fname.clone().as_str() == transport_stdin_key().as_str()) { + if (fname.clone() == transport_stdin_key()) { let r3 = parse_expr(r2.tokens.clone(), ctx.clone()); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7239,9 +7231,7 @@ pub fn parse_file_fields( EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; - if ((fname.clone().as_str() == "path".to_string().as_str()) - || (fname.clone().as_str() == transport_path_key().as_str())) - { + if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { { let __tco_0 = r3.ctx.clone(); let __tco_1 = Some(r3.expr.clone()); @@ -7563,7 +7553,7 @@ pub fn parse_op_body_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text.clone().as_str() == "input".to_string().as_str()) { + if (kw_text.clone() == "input".to_string()) { let r = expect( Rc::new( tokens @@ -7632,7 +7622,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "output".to_string().as_str()) { + if (kw_text.clone() == "output".to_string()) { let r = expect( Rc::new( tokens @@ -7701,7 +7691,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "idempotent".to_string().as_str()) { + if (kw_text.clone() == "idempotent".to_string()) { let prop = modifier_to_prop("idempotent".to_string(), span); { let __tco_0 = Rc::new( @@ -7713,7 +7703,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "readonly".to_string().as_str()) { + if (kw_text.clone() == "readonly".to_string()) { let prop = modifier_to_prop("readonly".to_string(), span); { let __tco_0 = Rc::new( @@ -7729,8 +7719,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "hermetic".to_string().as_str()) - { + if (kw_text.clone() == "hermetic".to_string()) { let prop = modifier_to_prop("hermetic".to_string(), span); { let __tco_0 = Rc::new( @@ -7755,7 +7744,7 @@ pub fn parse_op_body_entries( } Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (id.clone().as_str() == "transport".to_string().as_str()) { + if (id.clone() == "transport".to_string()) { let r = parse_transport_binding( Rc::new( tokens @@ -7791,7 +7780,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone().as_str() == "exit".to_string().as_str()) { + if (id.clone() == "exit".to_string()) { let r = expect( Rc::new( tokens @@ -7861,7 +7850,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone().as_str() == "response".to_string().as_str()) { + if (id.clone() == "response".to_string()) { let r = parse_optional_response_block(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(OpBodyResult { @@ -7887,7 +7876,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone().as_str() == "mock_response".to_string().as_str()) { + if (id.clone() == "mock_response".to_string()) { let r = parse_optional_mock_response_block( tokens.clone(), ctx.clone(), @@ -8341,7 +8330,7 @@ pub fn parse_operation_modifiers_acc( ) -> Rc { loop { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (kw.clone().as_str() == "idempotent".to_string().as_str()) { + if (kw.clone() == "idempotent".to_string()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); let __tco_1 = v1_rt::rc_list_push(acc, OperationModifier::Idempotent); @@ -8350,7 +8339,7 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (kw.clone().as_str() == "readonly".to_string().as_str()) { + if (kw.clone() == "readonly".to_string()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8360,7 +8349,7 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (kw.clone().as_str() == "hermetic".to_string().as_str()) { + if (kw.clone() == "hermetic".to_string()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8418,8 +8407,7 @@ pub fn parse_status_pattern(tokens: Rc>>, ctx: Rc) - let next_tok = tokens.clone().get(1 as usize).cloned(); match next_tok { Some(t) => { - if (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "xx".to_string().as_str())) + if (is_ident_shape(t.shape.clone()) && (t.text.clone() == "xx".to_string())) { Rc::new(ExprResult { expr: make_expr_node( @@ -8545,8 +8533,7 @@ pub fn parse_optional_response_block( let tok = tokens.clone().first().cloned(); let is_response = match tok { Some(t) => { - (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "response".to_string().as_str())) + (is_ident_shape(t.shape.clone()) && (t.text.clone() == "response".to_string())) } None => false, }; @@ -8702,8 +8689,7 @@ pub fn parse_optional_mock_response_block( let tok = tokens.clone().first().cloned(); let is_mock = match tok { Some(t) => { - (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "mock_response".to_string().as_str())) + (is_ident_shape(t.shape.clone()) && (t.text.clone() == "mock_response".to_string())) } None => false, }; @@ -9043,7 +9029,7 @@ pub fn parse_resource_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok_keyword_text(tok.clone()); - if (kw_text.clone().as_str() == "capability".to_string().as_str()) { + if (kw_text.clone() == "capability".to_string()) { let r = parse_capability(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ResPropResult { @@ -9064,7 +9050,7 @@ pub fn parse_resource_entries( continue; } } else { - if (kw_text.clone().as_str() == "acquire".to_string().as_str()) { + if (kw_text.clone() == "acquire".to_string()) { let r = expect( Rc::new( tokens @@ -9103,7 +9089,7 @@ pub fn parse_resource_entries( continue; } } else { - if (kw_text.clone().as_str() == "release".to_string().as_str()) { + if (kw_text.clone() == "release".to_string()) { let r = expect( Rc::new( tokens @@ -9481,7 +9467,7 @@ pub fn parse_io_blocks_acc( }); } else { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (kw.clone().as_str() == "input".to_string().as_str()) { + if (kw.clone() == "input".to_string()) { let r = expect( Rc::new( tokens @@ -9535,7 +9521,7 @@ pub fn parse_io_blocks_acc( continue; } } else { - if (kw.clone().as_str() == "output".to_string().as_str()) { + if (kw.clone() == "output".to_string()) { let r = expect( Rc::new( tokens @@ -10073,10 +10059,10 @@ pub fn parse_stmt(tokens: Rc>>, ctx: Rc) -> Rc { let kw_text = tok_keyword_text(tok.clone()); - if (kw_text.clone().as_str() == "let".to_string().as_str()) { + if (kw_text.clone() == "let".to_string()) { parse_let(tokens.clone(), ctx) } else { - if (kw_text.clone().as_str() == "return".to_string().as_str()) { + if (kw_text.clone() == "return".to_string()) { parse_return(tokens.clone(), ctx) } else { if peek_is_eq_after_ident(tokens.clone()) { @@ -10231,9 +10217,7 @@ pub fn parse_constrained_assignment( pub fn peek_text_is(tokens: Rc>>, expected: String) -> bool { match tokens.first().cloned() { - Some(t) => { - (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == expected.as_str())) - } + Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone() == expected)), None => false, } } @@ -10636,7 +10620,7 @@ pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Optio let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (op.symbol.clone().as_str() == symbol.clone().as_str()) { + if (op.symbol.clone() == symbol.clone()) { __result.push(op); } } @@ -10668,7 +10652,7 @@ pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Op let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (op.symbol.clone().as_str() == symbol.clone().as_str()) { + if (op.symbol.clone() == symbol.clone()) { __result.push(op); } } @@ -11012,26 +10996,22 @@ pub fn parse_primary(tokens: Rc>>, ctx: Rc) -> Rc { - if (kw_text.clone().as_str() == "match".to_string().as_str()) { + if (kw_text.clone() == "match".to_string()) { parse_match(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() == "if".to_string().as_str()) { + if (kw_text.clone() == "if".to_string()) { parse_if(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() == "for".to_string().as_str()) { + if (kw_text.clone() == "for".to_string()) { parse_for(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() == "let".to_string().as_str()) { + if (kw_text.clone() == "let".to_string()) { parse_let(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() - == "return".to_string().as_str()) - { + if (kw_text.clone() == "return".to_string()) { parse_return(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() - == "fn".to_string().as_str()) - { + if (kw_text.clone() == "fn".to_string()) { parse_fn_lambda(tokens.clone(), ctx.clone()) } else { { @@ -11388,7 +11368,7 @@ pub fn try_postfix( } } Some(TokenShape::ShIdent) => { - if (tok.clone().unwrap().text.clone().as_str() == "as".to_string().as_str()) { + if (tok.clone().unwrap().text.clone() == "as".to_string()) { if (13 < min_bp) { Rc::new(PostfixResult { expr: lhs.clone(), @@ -11562,8 +11542,7 @@ pub fn is_constraint_bracket(tokens: Rc>>) -> bool { match tokens.get(1 as usize).cloned() { Some(t) => { if is_ident_shape(t.shape.clone()) { - ((t.text.clone().as_str() == "after".to_string().as_str()) - || (t.text.clone().as_str() == "when".to_string().as_str())) + ((t.text.clone() == "after".to_string()) || (t.text.clone() == "when".to_string())) } else { false } @@ -11626,8 +11605,8 @@ pub fn parse_constraint_list( let is_constraint_kw = match tok.clone() { Some(t) => { (is_ident_shape(t.shape.clone()) - && ((t.text.clone().as_str() == "after".to_string().as_str()) - || (t.text.clone().as_str() == "when".to_string().as_str()))) + && ((t.text.clone() == "after".to_string()) + || (t.text.clone() == "when".to_string()))) } None => false, }; @@ -12590,7 +12569,7 @@ pub fn looks_like_arm_start(tokens: Rc>>) -> bool { match sh { Some(TokenShape::ShIdent) => { let n = tok.clone().unwrap().text.clone(); - if (n.clone().as_str() == "_".to_string().as_str()) { + if (n.clone() == "_".to_string()) { peek_is_fat_arrow_at(tokens.clone(), 1) } else { if is_uppercase_start(n.clone()) { @@ -12761,7 +12740,7 @@ pub fn parse_pattern(tokens: Rc>>, ctx: Rc) -> Rc { let n = tok.clone().unwrap().text.clone(); - if (n.clone().as_str() == "_".to_string().as_str()) { + if (n.clone() == "_".to_string()) { Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), tokens: Rc::new( @@ -14304,8 +14283,8 @@ pub fn parse_brace_expr(tokens: Rc>>, ctx: Rc) -> Rc match sh { Some(TokenShape::ShKeyword) => { let brace_kw = tok_keyword_text(tok.clone()); - if ((brace_kw.clone().as_str() == "let".to_string().as_str()) - || (brace_kw.clone().as_str() == "return".to_string().as_str())) + if ((brace_kw.clone() == "let".to_string()) + || (brace_kw.clone() == "return".to_string())) { { let r = parse_stmts(tokens.clone(), ctx); @@ -14558,3 +14537,7 @@ pub fn peek_is_colon_after_ident(tokens: Rc>>) -> bool { None => false, } } + +pub struct ParserHelperSkipNewlines; +pub struct ParserHelperSkipContinuationNewlines; +pub struct ParserHelperWith; diff --git a/src/v1/stage0/src/v1_compiler_resolve.rs b/src/v1/stage0/src/v1_compiler_resolve.rs index 1b987853c7b..54f91424f89 100644 --- a/src/v1/stage0/src/v1_compiler_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_resolve.rs @@ -490,7 +490,7 @@ pub fn adjacency_add_edge( } pub fn topo_sort_key(name: String) -> String { - if (name.clone().as_str() == "std.types".to_string().as_str()) { + if (name.clone() == "std.types".to_string()) { "".to_string() } else { name.clone() @@ -512,7 +512,7 @@ pub fn topological_sort( let has_std_types = { let mut __found = false; for name in module_names.clone().iter().cloned() { - if (name.clone().as_str() == "std.types".to_string().as_str()) { + if (name.clone() == "std.types".to_string()) { __found = true; break; } @@ -550,8 +550,7 @@ pub fn topological_sort( let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - .as_str() - == "std.types".to_string().as_str()) + == "std.types".to_string()) { __found = true; break; @@ -559,11 +558,9 @@ pub fn topological_sort( } __found }; - if ((((m_name.clone().as_str() != "std.types".to_string().as_str()) - && (m_name.clone().as_str() - != "std.algebra".to_string().as_str())) - && (m_name.clone().as_str() - != "std.error_primitives".to_string().as_str())) + if ((((m_name.clone() != "std.types".to_string()) + && (m_name.clone() != "std.algebra".to_string())) + && (m_name.clone() != "std.error_primitives".to_string())) && (imports_std_types.clone() == false)) { Rc::new(vec![Rc::new(DepEdge { @@ -599,8 +596,8 @@ pub fn topological_sort( let imports_std_types = { let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { - if (authored_name_at(source_indices.clone(), imp.clone()).as_str() - == "std.types".to_string().as_str()) + if (authored_name_at(source_indices.clone(), imp.clone()) + == "std.types".to_string()) { __found = true; break; @@ -609,9 +606,9 @@ pub fn topological_sort( __found }; let implicit_std_types_in_degree = if ((((has_std_types.clone() - && (m_name.clone().as_str() != "std.types".to_string().as_str())) - && (m_name.clone().as_str() != "std.algebra".to_string().as_str())) - && (m_name.clone().as_str() != "std.error_primitives".to_string().as_str())) + && (m_name.clone() != "std.types".to_string())) + && (m_name.clone() != "std.algebra".to_string())) + && (m_name.clone() != "std.error_primitives".to_string())) && (imports_std_types.clone() == false)) { 1 diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 3df8222f6a3..5150b16d4a2 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -38,7 +38,7 @@ pub fn rt_concat_trait() -> String { } pub fn rt_string_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8.\n".to_string()), "pub fn utf8_decode_bytes(bytes: &[u8]) -> Result {\n".to_string()), " String::from_utf8(bytes.to_vec()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))\n".to_string()), "}\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) } pub fn rt_collection_ops() -> String { diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index baa2ce9dd3a..f1cf4592fed 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -4,6 +4,7 @@ use self::Stage0CrateKind::*; use crate::extdeps_cargo::CargoDepSource::{LocalPathDep, RegistryDep}; pub use crate::extdeps_cargo::{CargoDepSource, CargoDependency, CargoFeature}; +pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::v1_compiler_emit_rust::{emit_cargo_dep, emit_non_empty_wrappers}; use crate::v1_rt; use crate::v1_rt::Witness; @@ -165,11 +166,8 @@ pub fn emit_stage0_crate_manifest(spec: Rc) -> Rc { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "[package]\nname = \"".to_string(), - spec.package_name.clone(), - ), - "\"\nversion = \"0.1.0\"\nedition = \"2021\"".to_string(), + render_cargo_package_header_prefix(spec.package_name.clone()), + "\nedition = \"2021\"".to_string(), ), render_stage0_crate_features_section(spec.features.clone()), ), @@ -401,3 +399,6 @@ pub fn emit_stage0_crate_boundary_files(plan: Rc) -> Rc Rc>> { emit_stage0_crate_boundary_files(stage0_crate_plan()) } + +pub struct CoreCrate; +pub struct EmitCoreCrate; diff --git a/src/v1/stage0/src/v1_compiler_tokenize.rs b/src/v1/stage0/src/v1_compiler_tokenize.rs index 3ffce56192f..b4ebe75de51 100644 --- a/src/v1/stage0/src/v1_compiler_tokenize.rs +++ b/src/v1/stage0/src/v1_compiler_tokenize.rs @@ -33,18 +33,18 @@ pub fn single_punct() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("(".to_string(), TokenShape::ShLParen); - __m.insert(")".to_string(), TokenShape::ShRParen); - __m.insert("[".to_string(), TokenShape::ShLBracket); - __m.insert("]".to_string(), TokenShape::ShRBracket); - __m.insert(":".to_string(), TokenShape::ShColon); - __m.insert(",".to_string(), TokenShape::ShComma); - __m.insert(".".to_string(), TokenShape::ShDot); - __m.insert("+".to_string(), TokenShape::ShPlus); - __m.insert("*".to_string(), TokenShape::ShStar); - __m.insert("%".to_string(), TokenShape::ShPercent); - __m.insert("/".to_string(), TokenShape::ShSlash); - __m.insert("^".to_string(), TokenShape::ShCaret); + __m.insert("(", TokenShape::ShLParen); + __m.insert(")", TokenShape::ShRParen); + __m.insert("[", TokenShape::ShLBracket); + __m.insert("]", TokenShape::ShRBracket); + __m.insert(":", TokenShape::ShColon); + __m.insert(",", TokenShape::ShComma); + __m.insert(".", TokenShape::ShDot); + __m.insert("+", TokenShape::ShPlus); + __m.insert("*", TokenShape::ShStar); + __m.insert("%", TokenShape::ShPercent); + __m.insert("/", TokenShape::ShSlash); + __m.insert("^", TokenShape::ShCaret); Rc::new(__m) }; } @@ -735,13 +735,13 @@ pub fn scan_string_body( }); } else { let ch = source_char(source.clone(), pos.clone()); - if (ch.clone().as_str() == "\"".to_string().as_str()) { + if (ch.clone() == "\"".to_string()) { break Rc::new(StringScanResult::ClosedString { content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { - if (ch.clone().as_str() == "\\".to_string().as_str()) { + if (ch.clone() == "\\".to_string()) { if ((pos.clone() + 1) < source_len(source.clone())) { let escaped = source_char(source.clone(), (pos.clone() + 1)); { @@ -762,7 +762,7 @@ pub fn scan_string_body( }); } } else { - if (ch.clone().as_str() == "{".to_string().as_str()) { + if (ch.clone() == "{".to_string()) { if should_start_interpolation(source.clone(), pos.clone()) { break Rc::new(StringScanResult::InterpolationStart { content: acc.join(&"".to_string()), @@ -814,26 +814,26 @@ pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc, filter: Rc) -> Rc Rc::new({ let mut __result = Vec::new(); for e in trace.events.clone().iter().cloned() { - if (event_node_id(e.clone()).as_str() == name.clone().as_str()) { + if (event_node_id(e.clone()) == name.clone()) { __result.push(e); } } diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 7858d655b57..8462a365c03 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -152,11 +152,6 @@ pub fn to_string(value: i64) -> String { value.to_string() } -/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8. -pub fn utf8_decode_bytes(bytes: &[u8]) -> Result { - String::from_utf8(bytes.to_vec()).map_err(|e| format!("invalid UTF-8 in access payload: {e}")) -} - pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 { val.clamp(min_val, max_val) } diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 2bdb78c5ee4..0b1968427ae 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -693,12 +693,14 @@ pub fn is_discovery_corpus_advisory_typecheck_diagnostic(d: Rc) -> bool { - if !is_interpreter_blocking_diagnostic(d.clone()) { - false - } else if is_discovery_corpus_advisory_typecheck_diagnostic(d.clone()) { + if (is_interpreter_blocking_diagnostic(d.clone()) == false) { false } else { - true + if is_discovery_corpus_advisory_typecheck_diagnostic(d.clone()) { + false + } else { + true + } } } @@ -748,7 +750,7 @@ pub struct Node { } pub fn default_ident_span(name: String, span: Rc) -> Option> { - if (name.as_str() == "".to_string().as_str()) { + if (name == "".to_string()) { None } else { Some(span) @@ -1180,7 +1182,7 @@ pub fn authored_name_at( Some(span) => match v1_rt::map_get(&source_indices, span.file.clone()) { Some(index) => { let text = source_text_at(index.clone(), span.clone()); - if (text.clone().as_str() == "".to_string().as_str()) { + if (text.clone() == "".to_string()) { "".to_string() } else { text.clone() @@ -1188,8 +1190,7 @@ pub fn authored_name_at( } None => { if ((v1_rt::string_length(&span.file.clone()) > 8) - && (v1_rt::substring(&span.file.clone(), 0, 8).as_str() - == " bool { if { let mut __found = false; for r in roles.clone().iter().cloned() { - if (r.accessor.clone().as_str() == name.clone().as_str()) { + if (r.accessor.clone() == name.clone()) { __found = true; break; } @@ -1486,7 +1483,7 @@ pub fn is_child_accessor_in_model(name: String) -> bool { if { let mut __found = false; for r in roles.clone().iter().cloned() { - if (r.accessor.clone().as_str() == name.clone().as_str()) { + if (r.accessor.clone() == name.clone()) { __found = true; break; } @@ -1519,11 +1516,11 @@ pub fn node_field_roles() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("children".to_string(), NodeFieldRole::ChildrenListField); - __m.insert("params".to_string(), NodeFieldRole::ChildrenListField); - __m.insert("body".to_string(), NodeFieldRole::SubValueField); - __m.insert("expr_data".to_string(), NodeFieldRole::SubValueField); - __m.insert("match_pattern".to_string(), NodeFieldRole::SubValueField); + __m.insert("children", NodeFieldRole::ChildrenListField); + __m.insert("params", NodeFieldRole::ChildrenListField); + __m.insert("body", NodeFieldRole::SubValueField); + __m.insert("expr_data", NodeFieldRole::SubValueField); + __m.insert("match_pattern", NodeFieldRole::SubValueField); Rc::new(__m) }; } @@ -1577,15 +1574,15 @@ pub fn function_size_effects() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("with_required_cardinality".to_string(), Rc::new(FunctionSizeEffect::PropertyContraction { + __m.insert("with_required_cardinality", Rc::new(FunctionSizeEffect::PropertyContraction { domain_size: 2, })); - __m.insert("resolved_type".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("param_node_type_expr".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("field_binding_pattern".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("wrapper_inner_arg".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("extractor_inner_arg".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("child_type_node".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("resolved_type", Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("param_node_type_expr", Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("field_binding_pattern", Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("wrapper_inner_arg", Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("extractor_inner_arg", Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("child_type_node", Rc::new(FunctionSizeEffect::TreeSizeReducing)); Rc::new(__m) }; } @@ -1640,7 +1637,7 @@ pub fn arg_name_at( ) -> Option { { let name = authored_name_at(source_indices, n); - if (name.clone().as_str() == "".to_string().as_str()) { + if (name.clone() == "".to_string()) { None } else { Some(name.clone()) @@ -1918,7 +1915,7 @@ pub fn record_lit_type_name_at( ) -> Option { { let name = authored_name_at(source_indices, texpr); - if (name.clone().as_str() == "".to_string().as_str()) { + if (name.clone() == "".to_string()) { None } else { Some(name.clone()) @@ -2234,9 +2231,7 @@ pub fn find_property( match Rc::new({ let mut __result = Vec::new(); for p in props.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == prop_name.clone().as_str()) - { + if (field_init_node_name_at(p.clone(), source_indices.clone()) == prop_name.clone()) { __result.push(p); } } @@ -2312,13 +2307,13 @@ pub fn field_init_operation_modifier( ) -> Option { { let fi_name = field_init_node_name_at(field_init, source_indices); - if (fi_name.clone().as_str() == "idempotent".to_string().as_str()) { + if (fi_name.clone() == "idempotent".to_string()) { Some(OperationModifier::Idempotent) } else { - if (fi_name.clone().as_str() == "readonly".to_string().as_str()) { + if (fi_name.clone() == "readonly".to_string()) { Some(OperationModifier::Readonly) } else { - if (fi_name.clone().as_str() == "hermetic".to_string().as_str()) { + if (fi_name.clone() == "hermetic".to_string()) { Some(OperationModifier::Hermetic) } else { None @@ -2430,18 +2425,18 @@ pub fn transport_response_format( } pub fn is_config_reserved_key(name: String) -> bool { - ((((((((((((name.clone().as_str() == transport_url_key().as_str()) - || (name.clone().as_str() == transport_path_key().as_str())) - || (name.clone().as_str() == transport_auth_scheme_key().as_str())) - || (name.clone().as_str() == transport_auth_header_key().as_str())) - || (name.clone().as_str() == transport_auth_token_key().as_str())) - || (name.clone().as_str() == transport_method_key().as_str())) - || (name.clone().as_str() == transport_path_template_key().as_str())) - || (name.clone().as_str() == transport_query_key().as_str())) - || (name.clone().as_str() == transport_body_key().as_str())) - || (name.clone().as_str() == transport_stdin_key().as_str())) - || (name.clone().as_str() == transport_response_format_key().as_str())) - || (name.clone().as_str() == transport_headers_key().as_str())) + ((((((((((((name.clone() == transport_url_key()) + || (name.clone() == transport_path_key())) + || (name.clone() == transport_auth_scheme_key())) + || (name.clone() == transport_auth_header_key())) + || (name.clone() == transport_auth_token_key())) + || (name.clone() == transport_method_key())) + || (name.clone() == transport_path_template_key())) + || (name.clone() == transport_query_key())) + || (name.clone() == transport_body_key())) + || (name.clone() == transport_stdin_key())) + || (name.clone() == transport_response_format_key())) + || (name.clone() == transport_headers_key())) } pub fn transport_headers( @@ -2511,9 +2506,7 @@ pub fn expr_has_self_call( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() - == fn_name.clone().as_str()) - { + if (expr_call_func_at(texpr.clone(), source_indices.clone()) == fn_name.clone()) { true } else { { @@ -2555,9 +2548,7 @@ pub fn expr_has_non_tail_self_call( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() - == fn_name.clone().as_str()) - { + if (expr_call_func_at(texpr.clone(), source_indices.clone()) == fn_name.clone()) { if (in_tail.clone() == false) { true } else { @@ -2885,8 +2876,8 @@ pub fn has_service_config( { let mut __found = false; for p in n.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "svc_endpoint".to_string().as_str()) + if (field_init_node_name_at(p.clone(), source_indices.clone()) + == "svc_endpoint".to_string()) { __found = true; break; @@ -3548,7 +3539,7 @@ pub fn merge_intern_tables(tables: Rc>>) -> Rc .iter() .cloned() .fold(merged, |m: Rc, s: String| { - if (s.clone().as_str() == "".to_string().as_str()) { + if (s.clone() == "".to_string()) { m.clone() } else { intern(m.clone(), s.clone()).table.clone() @@ -3624,3 +3615,73 @@ pub fn with_required_cardinality(n: Rc) -> Rc { expr_data: n.expr_data.clone(), }) } + +pub struct ShKeyword; +pub struct ShLBrace; +pub struct ShRBrace; +pub struct ShLParen; +pub struct ShRParen; +pub struct ShLBracket; +pub struct ShRBracket; +pub struct ShLt; +pub struct ShGt; +pub struct ShLe; +pub struct ShGe; +pub struct ShFatArrow; +pub struct ShArrow; +pub struct ShColon; +pub struct ShComma; +pub struct ShDot; +pub struct ShDotDot; +pub struct ShEq; +pub struct ShEqEq; +pub struct ShNe; +pub struct ShPlus; +pub struct ShMinus; +pub struct ShStar; +pub struct ShSlash; +pub struct ShPercent; +pub struct ShBang; +pub struct ShAnd; +pub struct ShOr; +pub struct ShQuestion; +pub struct ShNullCoalesce; +pub struct ShCaret; +pub struct ShPipe; +pub struct ShPipeArrow; +pub struct ShLitStr; +pub struct ShLitInt; +pub struct ShLitFloat; +pub struct ShIdent; +pub struct ShStrBegin; +pub struct ShStrMid; +pub struct ShStrEnd; +pub struct ShNewline; +pub struct ShEof; +pub struct ShUnknown; +pub struct Conj; +pub struct Disj; +pub struct NoConnective; +pub struct Arrow; +pub struct Required; +pub struct CardOptional; +pub struct StoredField; +pub struct EnumAccessor; +pub struct OptionalUnwrap; +pub struct TupleFirst; +pub struct TupleSecond; +pub struct PlainValue; +pub struct OptionalValue; +pub struct PlainCallSemantics; +pub struct LookupCallSemantics; +pub struct ParseRecoveryError; +pub struct SemanticExprError; +pub struct InternalExprError; +pub struct Not; +pub struct Neg; +pub struct Idempotent; +pub struct Readonly; +pub struct Hermetic; +pub struct ChildrenListField; +pub struct SubValueField; +pub struct MetadataField; From 3b7c8dbd681d5d9340618dca176a7f0712facceb Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:53:12 +0000 Subject: [PATCH 05/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/05_emit_rust.dag | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index f48151cce42..f6692dccc93 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -4589,6 +4589,23 @@ fn emit_typed_expr_base(texpr: Node, registry: Map, scope: Inf } } +// True iff the dot-accessed `field` on `base` is stored as `Box<..>` -- the +// struct-def emitter boxes a field whose type `needs_box_wrapping` (recursive +// types, and generic-param magnitudes like `Measure.count: Box`). Reading +// such a field as a plain `base.field.clone()` is an E0308 (`Box` vs `M`); +// it must deref through the Box. Reuses the SAME `needs_box_wrapping` the def +// uses, so the read always agrees with how the field was stored. The base type +// is alias-chain-expanded first so a cross-module alias (`Gibibyte` -> +// `Measure { count }`) resolves to the struct carrying the field. +fn field_access_field_is_boxed(base: Node, field: String, scope: InferScope, shared_types: Set, emit_info: EmitGraphInfo) -> Bool { + let base_struct = expand_type_for_field_access(n: resolved_type(n: base), env: scope.type_env, module_name: scope.module_name) + match find_child_named(n: base_struct, name: field, source_indices: scope.type_env.source_indices) { + Present { value: field_child } => + needs_box_wrapping(n: resolved_type(n: field_child), recursive_types: emit_info.recursive_type_set, shared_types: shared_types, source_indices: scope.type_env.source_indices) + Absent => false + } +} + fn emit_typed_field_access(base: Node, field: String, summary: FieldSummary?, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { let base_str = emit_typed_expr_base(texpr: base, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) let base_is_anon_record = match base.inferred { @@ -4626,7 +4643,15 @@ fn emit_typed_field_access(base: Node, field: String, summary: FieldSummary?, re set_contains(emit_info.owned_bindings, base_name) _ => false } - if base_is_owned { + let field_is_boxed = field_access_field_is_boxed(base: base, field: field, scope: scope, shared_types: shared_types, emit_info: emit_info) + if field_is_boxed { + // Box stored field: deref through the Box to the magnitude, then + // clone. The parens group the deref before `.clone()` (unary `*` + // binds looser than `.`), so they are NOT redundant and stay + // warning-clean under -D warnings in sole-return, chained, and + // receiver positions alike. + concat("(*", base_str, ".", emit_ident(name: field, target: Rust), ").clone()") + } else if base_is_owned { concat(base_str, ".", emit_ident(name: field, target: Rust)) } else { apply_type_template1(template: sharing.clone_value, arg0: concat(base_str, ".", emit_ident(name: field, target: Rust))) From bf70404471a7f66a37a09c23fe89fb9b0748438e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 17:57:09 +0000 Subject: [PATCH 06/11] =?UTF-8?q?chore:=20revert=20regenerated=20stage0=20?= =?UTF-8?q?seed=20=E2=80=94=20keep=20PR=20.dag-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-commit captured a local regen of src/v1/stage0/. Per the regen-lockstep repair hygiene, the committed seed must stay main's until the green co-land (PR 5325); this slice ships the emitter .dag change only. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/compiler_tests.rs | 6 +- src/v1/stage0/src/extdeps_cargo.rs | 124 +- src/v1/stage0/src/extdeps_cargo_version.rs | 12 +- .../stage0/src/extdeps_languages_dag_emit.rs | 32 +- .../src/extdeps_languages_dag_syntax.rs | 118 +- .../stage0/src/extdeps_languages_go_emit.rs | 28 +- .../src/extdeps_languages_python_emit.rs | 28 +- .../src/extdeps_languages_python_types.rs | 3 - .../stage0/src/extdeps_languages_rust_emit.rs | 30 +- .../src/extdeps_languages_rust_syntax.rs | 78 +- .../src/extdeps_languages_rust_types.rs | 8 - src/v1/stage0/src/extdeps_version_semver.rs | 23 +- src/v1/stage0/src/lib.rs | 16 +- src/v1/stage0/src/main.rs | 6 + src/v1/stage0/src/std_algebra.rs | 38 +- src/v1/stage0/src/std_coercion.rs | 8 +- src/v1/stage0/src/std_computation.rs | 9 +- src/v1/stage0/src/std_constructors.rs | 9 +- src/v1/stage0/src/std_effects.rs | 58 +- src/v1/stage0/src/std_emit_model.rs | 6 +- src/v1/stage0/src/std_error_primitives.rs | 3 - src/v1/stage0/src/std_graph.rs | 4 +- src/v1/stage0/src/std_http_path.rs | 10 +- src/v1/stage0/src/std_induction.rs | 19 +- src/v1/stage0/src/std_integer.rs | 40 +- src/v1/stage0/src/std_lens_verdict.rs | 6 +- src/v1/stage0/src/std_machine_constraints.rs | 8 +- src/v1/stage0/src/std_magnitude.rs | 3 +- src/v1/stage0/src/std_measure.rs | 57 +- src/v1/stage0/src/std_node.rs | 8 +- src/v1/stage0/src/std_realization_schedule.rs | 45 +- src/v1/stage0/src/std_serialization.rs | 17 +- src/v1/stage0/src/std_syntax.rs | 36 - src/v1/stage0/src/std_termination.rs | 4 - src/v1/stage0/src/std_types.rs | 101 +- src/v1/stage0/src/v1_compiler_artifact.rs | 14 - src/v1/stage0/src/v1_compiler_coercion.rs | 8 +- src/v1/stage0/src/v1_compiler_compile.rs | 101 +- src/v1/stage0/src/v1_compiler_complexity.rs | 144 +- src/v1/stage0/src/v1_compiler_emit.rs | 79 +- .../src/v1_compiler_emit_core_support.rs | 4 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 13 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 15 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 2960 ++++++++--------- src/v1/stage0/src/v1_compiler_infer.rs | 483 +-- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 4 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 5 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 7 - src/v1/stage0/src/v1_compiler_infer_lookup.rs | 54 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 35 + .../stage0/src/v1_compiler_infer_patterns.rs | 37 +- .../stage0/src/v1_compiler_infer_resolve.rs | 78 +- .../stage0/src/v1_compiler_infer_service.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 6 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 74 +- src/v1/stage0/src/v1_compiler_languages.rs | 16 +- src/v1/stage0/src/v1_compiler_ownership.rs | 39 +- src/v1/stage0/src/v1_compiler_parse.rs | 187 +- src/v1/stage0/src/v1_compiler_resolve.rs | 25 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- .../stage0/src/v1_compiler_stage0_crates.rs | 11 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 44 +- src/v1/stage0/src/v1_compiler_trace.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 5 + src/v1/stage0/src/v1_std_core.rs | 175 +- 66 files changed, 2646 insertions(+), 2990 deletions(-) diff --git a/src/v1/stage0/src/compiler_tests.rs b/src/v1/stage0/src/compiler_tests.rs index fe59340b25a..fc07fce7ded 100644 --- a/src/v1/stage0/src/compiler_tests.rs +++ b/src/v1/stage0/src/compiler_tests.rs @@ -50,7 +50,11 @@ mod compiler_tests { .unwrap() .to_string_lossy() .to_string(); - // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules. + // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules; + // exclude them so the self_* whole-tree module scans don't try to parse + // them as modules and panic. The only .dag under src/v1/**/tests/ is the + // fixture, so this skips exactly it (#5124 added the fixture; the cargo-test + // CI gate surfaced the panic). No real module lives under a tests/ dir. if rel.contains("/tests/") { continue; } diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index 12340c9e698..793c4c9abe1 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -3,12 +3,7 @@ use self::CargoDepSource::*; use self::CargoTarget::*; -use self::RustEdition::*; use self::TestHarness::*; -pub use crate::extdeps_cargo_version::{ - CargoPackageVersion, CargoToolVersionFloor, CargoVersionRequirement, -}; -pub use crate::std_types::FilePathParts; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -18,50 +13,11 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] -#[serde(tag = "_variant")] -pub enum RustEdition { - Edition2015, - Edition2018, - Edition2021, - Edition2024, -} - -pub fn rust_edition_str(edition: RustEdition) -> String { - match edition { - RustEdition::Edition2015 => "2015".to_string(), - RustEdition::Edition2018 => "2018".to_string(), - RustEdition::Edition2021 => "2021".to_string(), - RustEdition::Edition2024 => "2024".to_string(), - } -} - -pub fn default_rust_edition() -> RustEdition { - thread_local! { - static CACHED: RustEdition = { - RustEdition::Edition2021 - }; - } - CACHED.with(|c: &RustEdition| c.clone()) -} - -pub fn min_cargo_version() -> SemVerConstraint { - thread_local! { - static CACHED: SemVerConstraint = { - serde_json::from_value(serde_json::json!(">= 1.56")) - .expect("valid data definition") - }; - } - CACHED.with(|c: &SemVerConstraint| c.clone()) -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoPackage { pub name: String, - pub version: Box, - pub edition: RustEdition, + pub version: String, + pub edition: String, pub path: String, } @@ -69,7 +25,7 @@ pub struct CargoPackage { #[serde(tag = "_variant")] pub enum CargoDepSource { RegistryDep { - version: Box, + version: String, features: Rc>, }, LocalPathDep { @@ -104,64 +60,6 @@ impl CargoTarget { } } -pub fn cargo_target_source_path( - target: Rc, - package_name: String, -) -> Rc { - match (*target).clone() { - CargoTarget::Lib => Rc::new(FilePathParts { - segments: Rc::new(vec!["src".to_string(), "lib.rs".to_string()]), - }), - CargoTarget::Bin { name: name, .. } => { - if (name.clone() == package_name) { - Rc::new(FilePathParts { - segments: Rc::new(vec!["src".to_string(), "main.rs".to_string()]), - }) - } else { - Rc::new(FilePathParts { - segments: Rc::new(vec![ - "src".to_string(), - "bin".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }) - } - } - CargoTarget::CargoTest { name: name, .. } => Rc::new(FilePathParts { - segments: Rc::new(vec![ - "tests".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }), - CargoTarget::Example { name: name, .. } => Rc::new(FilePathParts { - segments: Rc::new(vec![ - "examples".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }), - CargoTarget::Bench { name: name, .. } => Rc::new(FilePathParts { - segments: Rc::new(vec![ - "benches".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }), - } -} - -pub fn rust_module_candidate_paths(stem: String) -> Rc>> { - Rc::new(vec![ - Rc::new(FilePathParts { - segments: Rc::new(vec![ - "src".to_string(), - v1_rt::concat(stem.clone(), ".rs".to_string()), - ]), - }), - Rc::new(FilePathParts { - segments: Rc::new(vec!["src".to_string(), stem.clone(), "mod.rs".to_string()]), - }), - ]) -} - pub type CargoProfile = String; pub fn canonical_profiles() -> Rc> { @@ -188,6 +86,15 @@ pub enum TestHarness { NoHarness, } +pub fn default_edition() -> String { + thread_local! { + static CACHED: String = { + "2021".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn default_profile() -> String { thread_local! { static CACHED: String = { @@ -196,10 +103,3 @@ pub fn default_profile() -> String { } CACHED.with(|c: &String| c.clone()) } - -pub struct Edition2015; -pub struct Edition2018; -pub struct Edition2021; -pub struct Edition2024; -pub struct Harness; -pub struct NoHarness; diff --git a/src/v1/stage0/src/extdeps_cargo_version.rs b/src/v1/stage0/src/extdeps_cargo_version.rs index 96d8331a9f2..d20dfe8d70e 100644 --- a/src/v1/stage0/src/extdeps_cargo_version.rs +++ b/src/v1/stage0/src/extdeps_cargo_version.rs @@ -17,27 +17,27 @@ pub type CargoVersionRequirement = SemVerConstraint; pub type CargoToolVersionFloor = SemVerConstraint; -pub fn default_stage0_package_version() -> String { +pub fn default_stage0_package_version() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "0.1.0".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn render_cargo_package_version_field(version: CargoPackageVersion) -> String { +pub fn render_cargo_package_version_field(version: CargoPackageVersion) -> Rc> { v1_rt::concat( v1_rt::concat("version = \"".to_string(), version), "\"".to_string(), ) } -pub fn render_cargo_version_requirement_toml(req: CargoVersionRequirement) -> String { +pub fn render_cargo_version_requirement_toml(req: CargoVersionRequirement) -> Rc> { v1_rt::concat(v1_rt::concat("\"".to_string(), req), "\"".to_string()) } -pub fn render_cargo_package_header_prefix(name: String) -> String { +pub fn render_cargo_package_header_prefix(name: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat("[package]\nname = \"".to_string(), name), diff --git a/src/v1/stage0/src/extdeps_languages_dag_emit.rs b/src/v1/stage0/src/extdeps_languages_dag_emit.rs index 531f36a0b9a..53b714ba0d2 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_emit.rs @@ -14,13 +14,13 @@ pub fn dag_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true", "true".to_string()); - __m.insert("false", "false".to_string()); - __m.insert("null", "none".to_string()); - __m.insert("and", "&&".to_string()); - __m.insert("or", "||".to_string()); - __m.insert("not", "!".to_string()); - __m.insert("div", "/".to_string()); + __m.insert("true".to_string(), "true".to_string()); + __m.insert("false".to_string(), "false".to_string()); + __m.insert("null".to_string(), "none".to_string()); + __m.insert("and".to_string(), "&&".to_string()); + __m.insert("or".to_string(), "||".to_string()); + __m.insert("not".to_string(), "!".to_string()); + __m.insert("div".to_string(), "/".to_string()); Rc::new(__m) }; } @@ -31,15 +31,15 @@ pub fn dag_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list", "List<{0}>".to_string()); - __m.insert("set", "Set<{0}>".to_string()); - __m.insert("non_empty_list", "NonEmptyList<{0}>".to_string()); - __m.insert("non_empty_set", "NonEmptySet<{0}>".to_string()); - __m.insert("optional", "{0}?".to_string()); - __m.insert("map", "Map<{0}, {1}>".to_string()); - __m.insert("free_monoid", "List<{0}>".to_string()); - __m.insert("partial_function", "Map<{0}, {1}>".to_string()); - __m.insert("boolean_algebra", "Bool".to_string()); + __m.insert("list".to_string(), "List<{0}>".to_string()); + __m.insert("set".to_string(), "Set<{0}>".to_string()); + __m.insert("non_empty_list".to_string(), "NonEmptyList<{0}>".to_string()); + __m.insert("non_empty_set".to_string(), "NonEmptySet<{0}>".to_string()); + __m.insert("optional".to_string(), "{0}?".to_string()); + __m.insert("map".to_string(), "Map<{0}, {1}>".to_string()); + __m.insert("free_monoid".to_string(), "List<{0}>".to_string()); + __m.insert("partial_function".to_string(), "Map<{0}, {1}>".to_string()); + __m.insert("boolean_algebra".to_string(), "Bool".to_string()); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs index db8d00681bf..aa38fb08090 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs @@ -108,14 +108,14 @@ pub fn dag_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("true", Rc::new(LiteralValue::LitBool { + __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert("false", Rc::new(LiteralValue::LitBool { + __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { value: false, })); - __m.insert("none", Rc::new(LiteralValue::LitNull)); - __m.insert("null", Rc::new(LiteralValue::LitNull)); + __m.insert("none".to_string(), Rc::new(LiteralValue::LitNull)); + __m.insert("null".to_string(), Rc::new(LiteralValue::LitNull)); Rc::new(__m) }; } @@ -126,41 +126,41 @@ pub fn dag_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("module", true); - __m.insert("import", true); - __m.insert("type", true); - __m.insert("fn", true); - __m.insert("func", true); - __m.insert("resource", true); - __m.insert("service", true); - __m.insert("data", true); - __m.insert("interface", true); - __m.insert("pipeline", true); - __m.insert("profile", true); - __m.insert("pattern", true); - __m.insert("let", true); - __m.insert("return", true); - __m.insert("match", true); - __m.insert("if", true); - __m.insert("then", true); - __m.insert("else", true); - __m.insert("for", true); - __m.insert("in", true); - __m.insert("where", true); - __m.insert("with", true); - __m.insert("true", true); - __m.insert("false", true); - __m.insert("none", true); - __m.insert("null", true); - __m.insert("acquire", true); - __m.insert("release", true); - __m.insert("capability", true); - __m.insert("operation", true); - __m.insert("input", true); - __m.insert("output", true); - __m.insert("idempotent", true); - __m.insert("readonly", true); - __m.insert("hermetic", true); + __m.insert("module".to_string(), true); + __m.insert("import".to_string(), true); + __m.insert("type".to_string(), true); + __m.insert("fn".to_string(), true); + __m.insert("func".to_string(), true); + __m.insert("resource".to_string(), true); + __m.insert("service".to_string(), true); + __m.insert("data".to_string(), true); + __m.insert("interface".to_string(), true); + __m.insert("pipeline".to_string(), true); + __m.insert("profile".to_string(), true); + __m.insert("pattern".to_string(), true); + __m.insert("let".to_string(), true); + __m.insert("return".to_string(), true); + __m.insert("match".to_string(), true); + __m.insert("if".to_string(), true); + __m.insert("then".to_string(), true); + __m.insert("else".to_string(), true); + __m.insert("for".to_string(), true); + __m.insert("in".to_string(), true); + __m.insert("where".to_string(), true); + __m.insert("with".to_string(), true); + __m.insert("true".to_string(), true); + __m.insert("false".to_string(), true); + __m.insert("none".to_string(), true); + __m.insert("null".to_string(), true); + __m.insert("acquire".to_string(), true); + __m.insert("release".to_string(), true); + __m.insert("capability".to_string(), true); + __m.insert("operation".to_string(), true); + __m.insert("input".to_string(), true); + __m.insert("output".to_string(), true); + __m.insert("idempotent".to_string(), true); + __m.insert("readonly".to_string(), true); + __m.insert("hermetic".to_string(), true); Rc::new(__m) }; } @@ -171,12 +171,12 @@ pub fn dag_non_name_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true", true); - __m.insert("false", true); - __m.insert("none", true); - __m.insert("null", true); - __m.insert("acquire", true); - __m.insert("release", true); + __m.insert("true".to_string(), true); + __m.insert("false".to_string(), true); + __m.insert("none".to_string(), true); + __m.insert("null".to_string(), true); + __m.insert("acquire".to_string(), true); + __m.insert("release".to_string(), true); Rc::new(__m) }; } @@ -292,20 +292,20 @@ pub fn v3_supported_dag_operators() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("||", true); - __m.insert("&&", true); - __m.insert("==", true); - __m.insert("!=", true); - __m.insert("<", true); - __m.insert(">", true); - __m.insert("<=", true); - __m.insert(">=", true); - __m.insert("+", true); - __m.insert("-", true); - __m.insert("*", true); - __m.insert("/", true); - __m.insert("|>", true); - __m.insert(".", true); + __m.insert("||".to_string(), true); + __m.insert("&&".to_string(), true); + __m.insert("==".to_string(), true); + __m.insert("!=".to_string(), true); + __m.insert("<".to_string(), true); + __m.insert(">".to_string(), true); + __m.insert("<=".to_string(), true); + __m.insert(">=".to_string(), true); + __m.insert("+".to_string(), true); + __m.insert("-".to_string(), true); + __m.insert("*".to_string(), true); + __m.insert("/".to_string(), true); + __m.insert("|>".to_string(), true); + __m.insert(".".to_string(), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_go_emit.rs b/src/v1/stage0/src/extdeps_languages_go_emit.rs index d70276eeb64..1ea6c48a70c 100644 --- a/src/v1/stage0/src/extdeps_languages_go_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_go_emit.rs @@ -15,13 +15,13 @@ pub fn go_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true", "true".to_string()); - __m.insert("false", "false".to_string()); - __m.insert("null", "nil".to_string()); - __m.insert("and", "&&".to_string()); - __m.insert("or", "||".to_string()); - __m.insert("not", "!".to_string()); - __m.insert("div", "/".to_string()); + __m.insert("true".to_string(), "true".to_string()); + __m.insert("false".to_string(), "false".to_string()); + __m.insert("null".to_string(), "nil".to_string()); + __m.insert("and".to_string(), "&&".to_string()); + __m.insert("or".to_string(), "||".to_string()); + __m.insert("not".to_string(), "!".to_string()); + __m.insert("div".to_string(), "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn go_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list", "[]{0}".to_string()); - __m.insert("set", "map[{0}]struct{}".to_string()); - __m.insert("optional", "*{0}".to_string()); - __m.insert("map", "map[{0}]{1}".to_string()); - __m.insert("free_monoid", "[]{0}".to_string()); - __m.insert("partial_function", "map[{0}]{1}".to_string()); - __m.insert("boolean_algebra", "bool".to_string()); + __m.insert("list".to_string(), "[]{0}".to_string()); + __m.insert("set".to_string(), "map[{0}]struct{}".to_string()); + __m.insert("optional".to_string(), "*{0}".to_string()); + __m.insert("map".to_string(), "map[{0}]{1}".to_string()); + __m.insert("free_monoid".to_string(), "[]{0}".to_string()); + __m.insert("partial_function".to_string(), "map[{0}]{1}".to_string()); + __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_python_emit.rs b/src/v1/stage0/src/extdeps_languages_python_emit.rs index b9f572e1896..383495ab200 100644 --- a/src/v1/stage0/src/extdeps_languages_python_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_python_emit.rs @@ -15,13 +15,13 @@ pub fn python_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true", "True".to_string()); - __m.insert("false", "False".to_string()); - __m.insert("null", "None".to_string()); - __m.insert("and", "and".to_string()); - __m.insert("or", "or".to_string()); - __m.insert("not", "not ".to_string()); - __m.insert("div", "//".to_string()); + __m.insert("true".to_string(), "True".to_string()); + __m.insert("false".to_string(), "False".to_string()); + __m.insert("null".to_string(), "None".to_string()); + __m.insert("and".to_string(), "and".to_string()); + __m.insert("or".to_string(), "or".to_string()); + __m.insert("not".to_string(), "not ".to_string()); + __m.insert("div".to_string(), "//".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn python_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list", "list[{0}]".to_string()); - __m.insert("set", "set[{0}]".to_string()); - __m.insert("optional", "Optional[{0}]".to_string()); - __m.insert("map", "dict[{0}, {1}]".to_string()); - __m.insert("free_monoid", "list[{0}]".to_string()); - __m.insert("partial_function", "dict[{0}, {1}]".to_string()); - __m.insert("boolean_algebra", "bool".to_string()); + __m.insert("list".to_string(), "list[{0}]".to_string()); + __m.insert("set".to_string(), "set[{0}]".to_string()); + __m.insert("optional".to_string(), "Optional[{0}]".to_string()); + __m.insert("map".to_string(), "dict[{0}, {1}]".to_string()); + __m.insert("free_monoid".to_string(), "list[{0}]".to_string()); + __m.insert("partial_function".to_string(), "dict[{0}, {1}]".to_string()); + __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index 29759774f9e..113a676ad25 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -258,6 +258,3 @@ pub fn python_cast_syntax() -> Rc { } CACHED.with(|c: &Rc| c.clone()) } - -pub struct DynamicType; -pub struct AnnotatedType; diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index 77ab9b3334f..1892d93af82 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -15,13 +15,13 @@ pub fn rust_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true", "true".to_string()); - __m.insert("false", "false".to_string()); - __m.insert("null", "None".to_string()); - __m.insert("and", "&&".to_string()); - __m.insert("or", "||".to_string()); - __m.insert("not", "!".to_string()); - __m.insert("div", "/".to_string()); + __m.insert("true".to_string(), "true".to_string()); + __m.insert("false".to_string(), "false".to_string()); + __m.insert("null".to_string(), "None".to_string()); + __m.insert("and".to_string(), "&&".to_string()); + __m.insert("or".to_string(), "||".to_string()); + __m.insert("not".to_string(), "!".to_string()); + __m.insert("div".to_string(), "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn rust_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list", "Vec<{0}>".to_string()); - __m.insert("set", "std::collections::BTreeSet<{0}>".to_string()); - __m.insert("optional", "Option<{0}>".to_string()); - __m.insert("map", "HashMap<{0}, {1}>".to_string()); - __m.insert("free_monoid", "Vec<{0}>".to_string()); - __m.insert("partial_function", "HashMap<{0}, {1}>".to_string()); - __m.insert("boolean_algebra", "bool".to_string()); + __m.insert("list".to_string(), "Vec<{0}>".to_string()); + __m.insert("set".to_string(), "std::collections::BTreeSet<{0}>".to_string()); + __m.insert("optional".to_string(), "Option<{0}>".to_string()); + __m.insert("map".to_string(), "HashMap<{0}, {1}>".to_string()); + __m.insert("free_monoid".to_string(), "Vec<{0}>".to_string()); + __m.insert("partial_function".to_string(), "HashMap<{0}, {1}>".to_string()); + __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; } @@ -497,7 +497,7 @@ pub fn rt_bridge_function_names() -> Rc> { Rc::new({ let mut __result = Vec::new(); for f in rt_function_registry().iter().cloned() { - if (f.name.clone() != f.bridge_name.clone()) { + if (f.name.clone().as_str() != f.bridge_name.clone().as_str()) { __result.push(f); } } diff --git a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs index 2851575009e..a9ef8cc021c 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs @@ -113,10 +113,10 @@ pub fn rust_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("true", Rc::new(LiteralValue::LitBool { + __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert("false", Rc::new(LiteralValue::LitBool { + __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { value: false, })); Rc::new(__m) @@ -129,43 +129,43 @@ pub fn rust_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("fn", true); - __m.insert("struct", true); - __m.insert("enum", true); - __m.insert("type", true); - __m.insert("trait", true); - __m.insert("impl", true); - __m.insert("const", true); - __m.insert("static", true); - __m.insert("mod", true); - __m.insert("use", true); - __m.insert("let", true); - __m.insert("mut", true); - __m.insert("return", true); - __m.insert("match", true); - __m.insert("if", true); - __m.insert("else", true); - __m.insert("for", true); - __m.insert("in", true); - __m.insert("while", true); - __m.insert("loop", true); - __m.insert("break", true); - __m.insert("continue", true); - __m.insert("pub", true); - __m.insert("self", true); - __m.insert("super", true); - __m.insert("crate", true); - __m.insert("as", true); - __m.insert("where", true); - __m.insert("ref", true); - __m.insert("move", true); - __m.insert("async", true); - __m.insert("await", true); - __m.insert("dyn", true); - __m.insert("unsafe", true); - __m.insert("extern", true); - __m.insert("true", true); - __m.insert("false", true); + __m.insert("fn".to_string(), true); + __m.insert("struct".to_string(), true); + __m.insert("enum".to_string(), true); + __m.insert("type".to_string(), true); + __m.insert("trait".to_string(), true); + __m.insert("impl".to_string(), true); + __m.insert("const".to_string(), true); + __m.insert("static".to_string(), true); + __m.insert("mod".to_string(), true); + __m.insert("use".to_string(), true); + __m.insert("let".to_string(), true); + __m.insert("mut".to_string(), true); + __m.insert("return".to_string(), true); + __m.insert("match".to_string(), true); + __m.insert("if".to_string(), true); + __m.insert("else".to_string(), true); + __m.insert("for".to_string(), true); + __m.insert("in".to_string(), true); + __m.insert("while".to_string(), true); + __m.insert("loop".to_string(), true); + __m.insert("break".to_string(), true); + __m.insert("continue".to_string(), true); + __m.insert("pub".to_string(), true); + __m.insert("self".to_string(), true); + __m.insert("super".to_string(), true); + __m.insert("crate".to_string(), true); + __m.insert("as".to_string(), true); + __m.insert("where".to_string(), true); + __m.insert("ref".to_string(), true); + __m.insert("move".to_string(), true); + __m.insert("async".to_string(), true); + __m.insert("await".to_string(), true); + __m.insert("dyn".to_string(), true); + __m.insert("unsafe".to_string(), true); + __m.insert("extern".to_string(), true); + __m.insert("true".to_string(), true); + __m.insert("false".to_string(), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_rust_types.rs b/src/v1/stage0/src/extdeps_languages_rust_types.rs index 7daf897f12a..eb83a073861 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_types.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_types.rs @@ -216,11 +216,3 @@ pub fn serde_rename_template() -> String { } CACHED.with(|c: &String| c.clone()) } - -pub struct Owned; -pub struct SharedRef; -pub struct MutRef; -pub struct RawPtr; -pub struct BoxPtr; -pub struct RcPtr; -pub struct ArcPtr; diff --git a/src/v1/stage0/src/extdeps_version_semver.rs b/src/v1/stage0/src/extdeps_version_semver.rs index 44a9c9a0703..9091502c1d9 100644 --- a/src/v1/stage0/src/extdeps_version_semver.rs +++ b/src/v1/stage0/src/extdeps_version_semver.rs @@ -141,14 +141,16 @@ pub fn semver_compare(a: Rc, b: Rc) -> Ordering { } } -pub fn semver_identifier_label(id: Rc) -> String { +pub fn semver_identifier_label(id: Rc) -> Rc> { match (*id).clone() { - SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => format!("{}", v.clone()), + SemVerIdentifier::SemVerNumericIdentifier { value: v, .. } => { + crate::v2_std_text::host_string_text_from_rust_host(format!("{}", v.clone())) + } SemVerIdentifier::SemVerAlphanumericIdentifier { label: s, .. } => s.clone(), } } -pub fn semver_identifiers_label(ids: Rc>>) -> String { +pub fn semver_identifiers_label(ids: Rc>>) -> Rc> { Rc::new({ let mut __result = Vec::new(); for id in ids.iter().cloned() { @@ -159,15 +161,22 @@ pub fn semver_identifiers_label(ids: Rc>>) -> String { .join(&".".to_string()) } -pub fn semver_version_label(v: Rc) -> String { +pub fn semver_version_label(v: Rc) -> Rc> { { let core = v1_rt::concat( - (v.major.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((v.major.clone()).to_string()), v1_rt::concat( ".".to_string(), v1_rt::concat( - (v.minor.clone()).to_string(), - v1_rt::concat(".".to_string(), (v.patch.clone()).to_string()), + crate::v2_std_text::host_string_text_from_rust_host( + (v.minor.clone()).to_string(), + ), + v1_rt::concat( + ".".to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (v.patch.clone()).to_string(), + ), + ), ), ), ); diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index 1c9d2294e11..7383cb17be5 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -15,7 +15,6 @@ pub mod cli_run; pub mod coproduct_reflection; pub mod extdeps_cargo; -pub mod extdeps_cargo_version; pub mod extdeps_languages_dag_emit; pub mod extdeps_languages_dag_syntax; pub mod extdeps_languages_dag_types; @@ -29,10 +28,9 @@ pub mod extdeps_languages_rust_emit; pub mod extdeps_languages_rust_syntax; pub mod extdeps_languages_rust_types; pub mod extdeps_shape_transport_policy_project; -pub mod extdeps_version; -pub mod extdeps_version_semver; pub mod fact_cardinality_census; pub mod import_resolution_project; +pub mod languages_consumer_census; pub mod layering_imports_project; pub mod module_path_index; pub mod recorded_fixture; @@ -41,26 +39,14 @@ pub mod rest_transport_facts; pub mod std_algebra; pub mod std_coercion; pub mod std_computation; -pub mod std_constructors; pub mod std_effects; pub mod std_emit_model; pub mod std_error_primitives; pub mod std_graph; pub mod std_http_path; pub mod std_induction; -pub mod std_integer; pub mod std_iteration; -pub mod std_lens_verdict; -pub mod std_list; -pub mod std_logic; -pub mod std_machine_constraints; -pub mod std_magnitude; -pub mod std_measure; -pub mod std_nat; pub mod std_node; -pub mod std_pareto; -pub mod std_realization_schedule; -pub mod std_serialization; pub mod std_syntax; pub mod std_termination; pub mod std_types; diff --git a/src/v1/stage0/src/main.rs b/src/v1/stage0/src/main.rs index 52ee2e54b0b..5817bef1c05 100644 --- a/src/v1/stage0/src/main.rs +++ b/src/v1/stage0/src/main.rs @@ -44,6 +44,8 @@ enum Commands { #[arg(long, default_value = "rust")] target: String, }, + /// Run repo CI from CiSpec (delegates to dsl/tools/gunbc_ci.dag) + Ci, /// Execute a .dag program directly (interpreter) Run { /// Source root directories (searched recursively for .dag files) @@ -384,6 +386,10 @@ fn main() { } } + Commands::Ci {} => { + cli_run::handle_ci(); + } + Commands::Run { source_roots, function, diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index ff9a47c3c49..e4beb0a704e 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -55,12 +55,6 @@ pub struct AbelianGroup { pub inverse: Rc T>, } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GroupCompletion(pub std::marker::PhantomData); - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct FieldOfFractions(pub std::marker::PhantomData); - #[derive(Clone)] pub struct Semiring { pub add: Rc T>, @@ -284,13 +278,13 @@ pub fn kernel_algebra_profile() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("Int", AlgebraProfile::OrderedRingProfile); - __m.insert("Float", AlgebraProfile::ApproximateFieldProfile); - __m.insert("Bool", AlgebraProfile::BooleanAlgebraProfile); - __m.insert("String", AlgebraProfile::FreeMonoidScalarProfile); - __m.insert("List", AlgebraProfile::FreeMonoidCollectionProfile); - __m.insert("Set", AlgebraProfile::BooleanAlgebraCollectionProfile); - __m.insert("Map", AlgebraProfile::PartialFunctionProfile); + __m.insert("Int".to_string(), AlgebraProfile::OrderedRingProfile); + __m.insert("Float".to_string(), AlgebraProfile::ApproximateFieldProfile); + __m.insert("Bool".to_string(), AlgebraProfile::BooleanAlgebraProfile); + __m.insert("String".to_string(), AlgebraProfile::FreeMonoidScalarProfile); + __m.insert("List".to_string(), AlgebraProfile::FreeMonoidCollectionProfile); + __m.insert("Set".to_string(), AlgebraProfile::BooleanAlgebraCollectionProfile); + __m.insert("Map".to_string(), AlgebraProfile::PartialFunctionProfile); Rc::new(__m) }; } @@ -1422,21 +1416,3 @@ pub fn algebra_type_param_names(profile: AlgebraProfile) -> Rc> { AlgebraProfile::PartialFunctionProfile => Rc::new(vec!["K".to_string(), "V".to_string()]), } } - -pub struct Less; -pub struct Equal; -pub struct Greater; -pub struct OrderedRingProfile; -pub struct ApproximateFieldProfile; -pub struct BooleanAlgebraProfile; -pub struct BooleanAlgebraCollectionProfile; -pub struct FreeMonoidScalarProfile; -pub struct FreeMonoidCollectionProfile; -pub struct PartialFunctionProfile; -pub struct ShrinkEffect; -pub struct ProjectionEffect; -pub struct IdentityEffect; -pub struct ShapeConstant; -pub struct ShapeLinearScan; -pub struct ShapeIterateBody; -pub struct ShapeSortBody; diff --git a/src/v1/stage0/src/std_coercion.rs b/src/v1/stage0/src/std_coercion.rs index 4a100a0218e..861c5852c1a 100644 --- a/src/v1/stage0/src/std_coercion.rs +++ b/src/v1/stage0/src/std_coercion.rs @@ -63,8 +63,8 @@ pub fn dag_can_cast(source_type: String, target_type: String) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((r.from_type.clone() == source_type.clone()) - && (r.to_type.clone() == target_type.clone())) + if ((r.from_type.clone().as_str() == source_type.clone().as_str()) + && (r.to_type.clone().as_str() == target_type.clone().as_str())) { __found = true; break; @@ -78,7 +78,9 @@ pub fn is_dag_cast_domain_type(name: String) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((r.from_type.clone() == name.clone()) || (r.to_type.clone() == name.clone())) { + if ((r.from_type.clone().as_str() == name.clone().as_str()) + || (r.to_type.clone().as_str() == name.clone().as_str())) + { __found = true; break; } diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 89e297efc72..2337843f5b2 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -233,7 +233,7 @@ pub fn algebra_profile_to_dimension(profile: AlgebraProfile) -> Option Option { - if (type_name.clone() == "Node".to_string()) { + if (type_name.clone().as_str() == "Node".to_string().as_str()) { Some(IterationDimension::TreeDescent) } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { @@ -242,10 +242,3 @@ pub fn type_iteration_dimension(type_name: String) -> Option } } } - -pub struct Fold; -pub struct Descend; -pub struct Repeat; -pub struct TreeDescent; -pub struct CollectionFold; -pub struct ArithmeticRepeat; diff --git a/src/v1/stage0/src/std_constructors.rs b/src/v1/stage0/src/std_constructors.rs index 243c28a84ef..e9409846f87 100644 --- a/src/v1/stage0/src/std_constructors.rs +++ b/src/v1/stage0/src/std_constructors.rs @@ -11,14 +11,11 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Product(pub std::marker::PhantomData<()>); +pub type Product = Product; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Coproduct(pub std::marker::PhantomData<()>); +pub type Coproduct = Coproduct; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Phantom(pub std::marker::PhantomData<()>); +pub type Phantom = Phantom; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, diff --git a/src/v1/stage0/src/std_effects.rs b/src/v1/stage0/src/std_effects.rs index df954565fcc..1e870d01f38 100644 --- a/src/v1/stage0/src/std_effects.rs +++ b/src/v1/stage0/src/std_effects.rs @@ -11,9 +11,8 @@ use self::ModifierAgreement::*; use crate::std_http_path::PathTemplateParseResult::{MalformedPathTemplate, ParsedPathTemplate}; pub use crate::std_http_path::{has_path_params, last_path_param, parse_path_template}; pub use crate::std_http_path::{PathTemplate, PathTemplateParseResult}; -pub use crate::std_realization_schedule::string_list_eq; +pub use crate::std_types::HttpMethod; use crate::std_types::HttpMethod::{DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT}; -pub use crate::std_types::{HttpMethod, List}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -96,18 +95,18 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { } } -pub fn key_source_eq(left: Rc, right: Rc) -> bool { - match (*left).clone() { - KeySource::PathParam { param: pa, .. } => match (*right).clone() { - KeySource::PathParam { param: pb, .. } => (pa.clone() == pb.clone()), +pub fn key_source_eq(a: Rc, b: Rc) -> bool { + match (*a).clone() { + KeySource::PathParam { param: pa, .. } => match (*b).clone() { + KeySource::PathParam { param: pb, .. } => (pa.clone().as_str() == pb.clone().as_str()), _ => false, }, - KeySource::InputField { field: fa, .. } => match (*right).clone() { - KeySource::InputField { field: fb, .. } => (fa.clone() == fb.clone()), + KeySource::InputField { field: fa, .. } => match (*b).clone() { + KeySource::InputField { field: fb, .. } => (fa.clone().as_str() == fb.clone().as_str()), _ => false, }, - KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { - KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa.clone(), fb.clone()), + KeySource::CompositeKey { fields: fa, .. } => match (*b).clone() { + KeySource::CompositeKey { fields: fb, .. } => (fa.clone() == fb.clone()), _ => false, }, } @@ -308,14 +307,16 @@ pub fn check_modifier_vs_derivation( } else { if (declared_idempotent.clone() && !derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { ref cause, .. } => { - let CreateCause::PostAlways = cause.as_ref() else { - unreachable!() - }; - Rc::new(ModifierAgreement::DerivationUnknown { - reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared".to_string(), -}) - } + EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { + CreateCause::PostAlways => Rc::new(ModifierAgreement::DerivationUnknown { + reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared" + .to_string(), + }), + CreateCause::CreateIfAbsent { .. } => Rc::new(ModifierAgreement::Disagrees { + reason: "derivation says non-idempotent but modifier declares idempotent" + .to_string(), + }), + }, _ => Rc::new(ModifierAgreement::Disagrees { reason: "derivation says non-idempotent but modifier declares idempotent" .to_string(), @@ -324,18 +325,15 @@ pub fn check_modifier_vs_derivation( } else { if (!declared_idempotent.clone() && derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { ref cause, .. } => { - let CreateCause::CreateIfAbsent { - key_source: key_source, - .. - } = cause.as_ref() - else { - unreachable!() - }; - Rc::new(ModifierAgreement::Disagrees { - reason: "create-if-absent has proven identity but modifier declares non-idempotent".to_string(), -}) - } + EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { + CreateCause::CreateIfAbsent { .. } => { + Rc::new(ModifierAgreement::Disagrees { + reason: "create-if-absent has proven identity but modifier declares non-idempotent" + .to_string(), + }) + } + CreateCause::PostAlways => Rc::new(ModifierAgreement::Agrees), + }, _ => Rc::new(ModifierAgreement::Agrees), } } else { diff --git a/src/v1/stage0/src/std_emit_model.rs b/src/v1/stage0/src/std_emit_model.rs index 7723800d50e..5bd6eebf3a1 100644 --- a/src/v1/stage0/src/std_emit_model.rs +++ b/src/v1/stage0/src/std_emit_model.rs @@ -2,7 +2,6 @@ // Source module: std.emit_model use self::PlaceholderConvention::*; -pub use crate::std_serialization::DeclarationRef; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -12,6 +11,8 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +pub type DeclarationRef = String; + #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, )] @@ -36,6 +37,3 @@ pub struct MethodTemplateContract { pub wraps_result: bool, pub placeholder_convention: PlaceholderConvention, } - -pub struct IndexedArgs; -pub struct NamedArg; diff --git a/src/v1/stage0/src/std_error_primitives.rs b/src/v1/stage0/src/std_error_primitives.rs index b6cf7b7a27a..e0c45702a3b 100644 --- a/src/v1/stage0/src/std_error_primitives.rs +++ b/src/v1/stage0/src/std_error_primitives.rs @@ -29,6 +29,3 @@ pub enum DivError { DivideByZero, Overflow, } - -pub struct DivideByZero; -pub struct Overflow; diff --git a/src/v1/stage0/src/std_graph.rs b/src/v1/stage0/src/std_graph.rs index 5d20b69f286..0a335410820 100644 --- a/src/v1/stage0/src/std_graph.rs +++ b/src/v1/stage0/src/std_graph.rs @@ -66,7 +66,7 @@ pub fn build_call_graph_from_proof_edges( for e in Rc::new({ let mut __result = Vec::new(); for e in edges.iter().cloned() { - if (e.caller.clone() != e.callee.clone()) { + if (e.caller.clone().as_str() != e.callee.clone().as_str()) { __result.push(e); } } @@ -292,7 +292,7 @@ pub fn is_valid_proof(proof: Rc, edges: Rc>> let has_self_cycle = { let mut __found = false; for e in non_descending.clone().iter().cloned() { - if (e.caller.clone() == e.callee.clone()) { + if (e.caller.clone().as_str() == e.callee.clone().as_str()) { __found = true; break; } diff --git a/src/v1/stage0/src/std_http_path.rs b/src/v1/stage0/src/std_http_path.rs index 94fd4468f89..f5dd9a50bec 100644 --- a/src/v1/stage0/src/std_http_path.rs +++ b/src/v1/stage0/src/std_http_path.rs @@ -70,7 +70,7 @@ pub fn parse_path_template(raw: String) -> Rc { .iter() .cloned() { - if (s.clone() != "".to_string()) { + if (s.clone().as_str() != "".to_string().as_str()) { __result.push(s); } } @@ -227,28 +227,28 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let prefix_tokens = if (prefix.clone() != "".to_string()) { + let prefix_tokens = if (prefix.clone().as_str() != "".to_string().as_str()) { Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { text: prefix.clone(), })]) } else { Rc::new(vec![]) }; - let param_tokens = if (param_name.clone() != "".to_string()) { + let param_tokens = if (param_name.clone().as_str() != "".to_string().as_str()) { Rc::new(vec![Rc::new(UrlPathToken::ParamToken { name: param_name.clone(), })]) } else { Rc::new(vec![]) }; - let suffix_tokens = if (suffix.clone() != "".to_string()) { + let suffix_tokens = if (suffix.clone().as_str() != "".to_string().as_str()) { Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { text: suffix.clone(), })]) } else { Rc::new(vec![]) }; - if (((param_name.clone() == "".to_string()) + if (((param_name.clone().as_str() == "".to_string().as_str()) || v1_rt::contains(suffix.clone(), "{".to_string())) || v1_rt::contains(suffix.clone(), "}".to_string())) { diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index 3457a8f1cb8..5fecbc40044 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -84,11 +84,11 @@ pub fn recursion_shape_eq(a: RecursionShape, b: RecursionShape) -> bool { } pub fn inductive_field_eq(a: Rc, b: Rc) -> bool { - (((((a.type_name.clone() == b.type_name.clone()) - && (a.variant_name.clone() == b.variant_name.clone())) - && (a.field_name.clone() == b.field_name.clone())) + (((((a.type_name.clone().as_str() == b.type_name.clone().as_str()) + && (a.variant_name.clone().as_str() == b.variant_name.clone().as_str())) + && (a.field_name.clone().as_str() == b.field_name.clone().as_str())) && recursion_shape_eq(a.shape.clone(), b.shape.clone())) - && (a.element_type.clone() == b.element_type.clone())) + && (a.element_type.clone().as_str() == b.element_type.clone().as_str())) } pub fn inductive_field_to_dimension( @@ -193,7 +193,10 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) param: pb, factor: fac_b, .. - } => ((pa.clone() == pb.clone()) && shrink_factor_eq(fac_a.clone(), fac_b.clone())), + } => { + ((pa.clone().as_str() == pb.clone().as_str()) + && shrink_factor_eq(fac_a.clone(), fac_b.clone())) + } _ => false, }, SubValueRelation::PreservedValue => match (*b).clone() { @@ -1099,9 +1102,3 @@ pub fn bellman_ford_bound() -> Rc { pub fn floyd_warshall_bound() -> Rc { cost_poly("V".to_string(), 3) } - -pub struct DirectRecursion; -pub struct ListRecursion; -pub struct OptionalRecursion; -pub struct SetRecursion; -pub struct MapValueRecursion; diff --git a/src/v1/stage0/src/std_integer.rs b/src/v1/stage0/src/std_integer.rs index 4172d1f193b..ba1296928e7 100644 --- a/src/v1/stage0/src/std_integer.rs +++ b/src/v1/stage0/src/std_integer.rs @@ -13,49 +13,33 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type Int8 = - crate::std_machine_constraints::Compose; +pub type Int8 = crate::std_machine_constraints::Compose; -pub type Int16 = - crate::std_machine_constraints::Compose; +pub type Int16 = crate::std_machine_constraints::Compose; -pub type Int32 = - crate::std_machine_constraints::Compose; +pub type Int32 = crate::std_machine_constraints::Compose; -pub type Int64 = - crate::std_machine_constraints::Compose; +pub type Int64 = crate::std_machine_constraints::Compose; -pub type Int128 = - crate::std_machine_constraints::Compose; +pub type Int128 = crate::std_machine_constraints::Compose; -pub type UInt8 = - crate::std_machine_constraints::Compose; +pub type UInt8 = crate::std_machine_constraints::Compose; -pub type UInt16 = - crate::std_machine_constraints::Compose; +pub type UInt16 = crate::std_machine_constraints::Compose; -pub type UInt32 = - crate::std_machine_constraints::Compose; +pub type UInt32 = crate::std_machine_constraints::Compose; -pub type UInt64 = - crate::std_machine_constraints::Compose; +pub type UInt64 = crate::std_machine_constraints::Compose; -pub type UInt128 = - crate::std_machine_constraints::Compose; +pub type UInt128 = crate::std_machine_constraints::Compose; pub type Int = Rc>>; pub type UInt = Nat; -pub type IntPlatform = crate::std_machine_constraints::Compose< - Int, - crate::std_machine_constraints::MachineWidth, ->; +pub type IntPlatform = crate::std_machine_constraints::Compose; -pub type UIntPlatform = crate::std_machine_constraints::Compose< - UInt, - crate::std_machine_constraints::MachineWidth, ->; +pub type UIntPlatform = crate::std_machine_constraints::Compose; pub type NonNegativeInt = Nat; diff --git a/src/v1/stage0/src/std_lens_verdict.rs b/src/v1/stage0/src/std_lens_verdict.rs index 6b17a792825..18fcf31e98d 100644 --- a/src/v1/stage0/src/std_lens_verdict.rs +++ b/src/v1/stage0/src/std_lens_verdict.rs @@ -15,10 +15,10 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum LensVerdictLocus { - ModuleWholeFile { module_name: String }, + ModuleWholeFile { module_name: Rc> }, } impl LensVerdictLocus { - pub fn module_name(&self) -> String { + pub fn module_name(&self) -> Rc> { match self { LensVerdictLocus::ModuleWholeFile { module_name: __val, .. @@ -29,7 +29,7 @@ impl LensVerdictLocus { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct LensVerdictDiagnostic { - pub reason: String, + pub reason: Rc>, pub at: Rc, } diff --git a/src/v1/stage0/src/std_machine_constraints.rs b/src/v1/stage0/src/std_machine_constraints.rs index ea8dd6edf88..da534ba34c5 100644 --- a/src/v1/stage0/src/std_machine_constraints.rs +++ b/src/v1/stage0/src/std_machine_constraints.rs @@ -11,10 +11,4 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct MachineWidth(pub std::marker::PhantomData); - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct PointerWidth(pub std::marker::PhantomData<()>); - -pub type Compose = Phantom; +pub type PointerWidth = PointerWidth; diff --git a/src/v1/stage0/src/std_magnitude.rs b/src/v1/stage0/src/std_magnitude.rs index f923d48ec6b..d59e2d0a7ed 100644 --- a/src/v1/stage0/src/std_magnitude.rs +++ b/src/v1/stage0/src/std_magnitude.rs @@ -10,5 +10,4 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Magnitude(pub std::marker::PhantomData<()>); +pub type Magnitude = Magnitude; diff --git a/src/v1/stage0/src/std_measure.rs b/src/v1/stage0/src/std_measure.rs index 54822d2ae06..fc11b1971d3 100644 --- a/src/v1/stage0/src/std_measure.rs +++ b/src/v1/stage0/src/std_measure.rs @@ -28,8 +28,6 @@ pub enum Quantity { Count, Currency, Power, - Temperature, - RotationalSpeed, ElectricPotential, ElectricCurrent, Resistance, @@ -85,29 +83,14 @@ pub fn scale_exponent(s: Scale) -> i64 { } } -pub fn gibibyte_scale_factor_bytes() -> Nat { - 1073741824 -} - -pub fn memory_scale_factor_bytes(s: Scale) -> Option { +pub fn memory_scale_factor_bytes(s: Scale) -> Nat { match s { - Scale::One => Some(1), - Scale::Kibi => Some(1024), - Scale::Mebi => Some(1048576), - Scale::Gibi => Some(gibibyte_scale_factor_bytes()), - Scale::Tebi => Some(1099511627776), - Scale::Atto => None, - Scale::Femto => None, - Scale::Pico => None, - Scale::Nano => None, - Scale::Micro => None, - Scale::Milli => None, - Scale::Kilo => None, - Scale::Mega => None, - Scale::Giga => None, - Scale::Tera => None, - Scale::Peta => None, - Scale::Exa => None, + Scale::One => 1, + Scale::Kibi => 1024, + Scale::Mebi => 1048576, + Scale::Gibi => 1073741824, + Scale::Tebi => 1099511627776, + _ => 1, } } @@ -139,7 +122,7 @@ pub fn gibibyte_count(g: Gibibyte) -> Nat { } pub fn gibibyte_to_byte_size(g: Gibibyte) -> ByteSize { - byte_size((gibibyte_count(g) * gibibyte_scale_factor_bytes())) + byte_size((gibibyte_count(g) * memory_scale_factor_bytes(Scale::Gibi))) } pub type BitWidth = Rc>; @@ -150,10 +133,6 @@ pub type HardwareThreadCount = Rc>; pub type Watt = Rc>; -pub type Celsius = Rc>; - -pub type RevolutionsPerMinute = Rc>; - pub fn watt(count: Nat) -> Watt { Watt { count: count } } @@ -162,25 +141,9 @@ pub fn watt_count(w: Watt) -> Nat { compile_error!("field access missing reconcile summary for 'count'") } -pub fn celsius(count: i64) -> Celsius { - Celsius { count: count } -} - -pub fn celsius_count(c: Celsius) -> i64 { - compile_error!("field access missing reconcile summary for 'count'") -} - -pub fn rpm(count: Nat) -> RevolutionsPerMinute { - RevolutionsPerMinute { count: count } -} - -pub fn rpm_count(r: RevolutionsPerMinute) -> Nat { - compile_error!("field access missing reconcile summary for 'count'") -} - pub type MoneyAmount = Rc>; -pub type MoneyAmountMicro = MoneyAmount; +pub type MoneyAmountMicro = MoneyAmount; pub fn money_amount_micro(count: Nat) -> MoneyAmountMicro { MoneyAmountMicro { count: count } @@ -232,8 +195,6 @@ pub struct Frequency; pub struct Count; pub struct Currency; pub struct Power; -pub struct Temperature; -pub struct RotationalSpeed; pub struct ElectricPotential; pub struct ElectricCurrent; pub struct Resistance; diff --git a/src/v1/stage0/src/std_node.rs b/src/v1/stage0/src/std_node.rs index ea6f2590918..7ca1fbee5f6 100644 --- a/src/v1/stage0/src/std_node.rs +++ b/src/v1/stage0/src/std_node.rs @@ -105,10 +105,10 @@ pub fn compiler_recursive_types() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("Node", true); - __m.insert("InferredNode", true); - __m.insert("MatchPattern", true); - __m.insert("MethodSemantics", true); + __m.insert("Node".to_string(), true); + __m.insert("InferredNode".to_string(), true); + __m.insert("MatchPattern".to_string(), true); + __m.insert("MethodSemantics".to_string(), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/std_realization_schedule.rs b/src/v1/stage0/src/std_realization_schedule.rs index b393812624e..488dce36b7d 100644 --- a/src/v1/stage0/src/std_realization_schedule.rs +++ b/src/v1/stage0/src/std_realization_schedule.rs @@ -70,16 +70,16 @@ pub struct RealizationObjective { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ScheduleWitnessEntry { - pub entry: String, - pub function: String, + pub entry: Rc>, + pub function: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum Runnable { RunnableSingleClaim { - entry: String, - function: String, + entry: Rc>, + function: Rc>, }, RunnableDiscoveryBatch { source_roots: Rc>, @@ -99,19 +99,24 @@ pub struct RealizationPlan { pub total: Rc>, } -pub fn runnable_step_label(r: Rc) -> String { +pub fn runnable_step_label(r: Rc) -> Rc> { match (*r).clone() { Runnable::RunnableSingleClaim { function: f, .. } => f.clone(), Runnable::RunnableDiscoveryBatch { .. } => "__discovery_corpus__".to_string(), } } -pub fn schedule_batch_contains_label(batch: Rc>>, target: String) -> bool { +pub fn schedule_batch_contains_label( + batch: Rc>>, + target: Rc>, +) -> bool { batch .iter() .cloned() .fold(false, |acc: bool, r: Rc| { - (acc || (runnable_step_label(r.clone()) == target.clone())) + (acc || (crate::v2_std_text::host_string_text_to_rust_host(runnable_step_label( + r.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(target.clone()))) }) } @@ -119,12 +124,12 @@ pub fn schedule_batch_contains_label(batch: Rc>>, target: Strin #[serde(tag = "_variant")] pub enum ScheduleLensViolation { EmptySchedule, - CompileGateNotFirst { expected: String }, + CompileGateNotFirst { expected: Rc> }, CorpusBeforeCompile, SingleBatchOnly, } impl ScheduleLensViolation { - pub fn expected(&self) -> String { + pub fn expected(&self) -> Rc> { match self { ScheduleLensViolation::EmptySchedule => panic!("no expected on unit variant"), ScheduleLensViolation::CompileGateNotFirst { @@ -136,18 +141,18 @@ impl ScheduleLensViolation { } } -pub fn schedule_lens_module() -> String { +pub fn schedule_lens_module() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "std.realization_schedule".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn schedule_lens_violation_diagnostic( kind: Rc, - compile_gate_fn: String, + compile_gate_fn: Rc>, ) -> Rc { { let at = Rc::new(LensVerdictLocus::ModuleWholeFile { @@ -178,7 +183,7 @@ pub fn schedule_lens_violation_diagnostic( pub fn schedule_lens_verdict_for_ci_floor( plan: Rc>, - compile_gate_fn: String, + compile_gate_fn: Rc>, ) -> Rc { if (plan.schedule.clone().length() == 0) { Rc::new(LensVerdict::Violation { @@ -258,7 +263,10 @@ pub fn schedule_generates_same_batch_count( } pub fn schedule_witness_entry_eq(a: Rc, b: Rc) -> bool { - ((a.entry.clone() == b.entry.clone()) && (a.function.clone() == b.function.clone())) + ((crate::v2_std_text::host_string_text_to_rust_host(a.entry.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(b.entry.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(a.function.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(b.function.clone()))) } pub fn string_list_eq(mut left: Rc>, mut right: Rc>) -> bool { @@ -332,7 +340,12 @@ pub fn runnable_eq(left: Rc, right: Rc) -> bool { entry: re, function: rf, .. - } => ((le.clone() == re.clone()) && (lf.clone() == rf.clone())), + } => { + ((crate::v2_std_text::host_string_text_to_rust_host(le.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(re.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(lf.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(rf.clone()))) + } Runnable::RunnableDiscoveryBatch { .. } => false, }, Runnable::RunnableDiscoveryBatch { diff --git a/src/v1/stage0/src/std_serialization.rs b/src/v1/stage0/src/std_serialization.rs index 84dfcbfce2e..0fe9773c060 100644 --- a/src/v1/stage0/src/std_serialization.rs +++ b/src/v1/stage0/src/std_serialization.rs @@ -13,7 +13,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type DeclarationRef = String; +pub type DeclarationRef = Rc>; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] @@ -21,9 +21,16 @@ pub enum VariantNaming { AsAuthored, SnakeCase, ScreamingSnakeCase, - StripPrefixAndSnakeCase { prefix: String }, - StripSuffixAndSnakeCase { suffix: String }, - StripPrefixSuffixAndSnakeCase { prefix: String, suffix: String }, + StripPrefixAndSnakeCase { + prefix: Rc>, + }, + StripSuffixAndSnakeCase { + suffix: Rc>, + }, + StripPrefixSuffixAndSnakeCase { + prefix: Rc>, + suffix: Rc>, + }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -33,7 +40,7 @@ pub enum VariantEncoding { naming: Rc, }, InternallyTaggedObject { - tag_field: String, + tag_field: Rc>, naming: Rc, }, UntaggedVariant, diff --git a/src/v1/stage0/src/std_syntax.rs b/src/v1/stage0/src/std_syntax.rs index 1e280cc963c..019ae09f706 100644 --- a/src/v1/stage0/src/std_syntax.rs +++ b/src/v1/stage0/src/std_syntax.rs @@ -156,39 +156,3 @@ pub struct SyntaxSpec { pub keyword_literals: Rc>>, pub keyword_set: Rc>, } - -pub struct Add; -pub struct Sub; -pub struct Mul; -pub struct Div; -pub struct Mod; -pub struct Eq; -pub struct Ne; -pub struct Lt; -pub struct Gt; -pub struct Le; -pub struct Ge; -pub struct And; -pub struct Or; -pub struct NullCoalesce; -pub struct ExprBody; -pub struct BlockBody; -pub struct TypeBody; -pub struct ValueBody; -pub struct NoBody; -pub struct ServiceBody; -pub struct ResourceBody; -pub struct FuncForm; -pub struct StructForm; -pub struct EnumForm; -pub struct TypeAliasForm; -pub struct ModuleForm; -pub struct OtherForm; -pub struct AlgAdd; -pub struct AlgMul; -pub struct AlgReciprocal; -pub struct AlgQuotient; -pub struct AlgRemainder; -pub struct AlgCompare; -pub struct AlgMeet; -pub struct AlgJoin; diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 46d3e739ca9..3c3f23e0a92 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -256,7 +256,3 @@ pub struct ProofEdge { pub callee: String, pub evidence: Rc>, } - -pub struct Strict; -pub struct NonIncreasing; -pub struct DescentUnknown; diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index b6fa5fa4992..1500f5a4251 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -22,14 +22,14 @@ pub fn kernel_type_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("String", true); - __m.insert("Int", true); - __m.insert("Bool", true); - __m.insert("Float", true); - __m.insert("Secret", true); - __m.insert("Json", true); - __m.insert("Unit", true); - __m.insert("Bytes", true); + __m.insert("String".to_string(), true); + __m.insert("Int".to_string(), true); + __m.insert("Bool".to_string(), true); + __m.insert("Float".to_string(), true); + __m.insert("Secret".to_string(), true); + __m.insert("Json".to_string(), true); + __m.insert("Unit".to_string(), true); + __m.insert("Bytes".to_string(), true); Rc::new(__m) }; } @@ -47,10 +47,10 @@ pub fn container_type_arity() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List", 1); - __m.insert("Set", 1); - __m.insert("Map", 2); - __m.insert("Witness", 1); + __m.insert("List".to_string(), 1); + __m.insert("Set".to_string(), 1); + __m.insert("Map".to_string(), 2); + __m.insert("Witness".to_string(), 1); Rc::new(__m) }; } @@ -69,7 +69,7 @@ pub fn container_expected_arity(name: String) -> Option { } pub fn container_param_names_for(kind_name: String) -> Rc> { - if (kind_name.clone() == "Witness".to_string()) { + if (kind_name.clone().as_str() == "Witness".to_string().as_str()) { Rc::new(vec!["T".to_string()]) } else { match v1_rt::map_get(&kernel_algebra_profile(), kind_name.clone()) { @@ -123,7 +123,7 @@ pub fn ordered_element_collections() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List", true); + __m.insert("List".to_string(), true); Rc::new(__m) }; } @@ -138,18 +138,18 @@ pub fn container_template_algebra_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List", "FreeMonoid".to_string()); - __m.insert("list", "FreeMonoid".to_string()); - __m.insert("Set", "BooleanAlgebra".to_string()); - __m.insert("set", "BooleanAlgebra".to_string()); - __m.insert("Map", "PartialFunction".to_string()); - __m.insert("map", "PartialFunction".to_string()); - __m.insert("FreeMonoid", "FreeMonoid".to_string()); - __m.insert("free_monoid", "FreeMonoid".to_string()); - __m.insert("BooleanAlgebra", "BooleanAlgebra".to_string()); - __m.insert("boolean_algebra", "BooleanAlgebra".to_string()); - __m.insert("PartialFunction", "PartialFunction".to_string()); - __m.insert("partial_function", "PartialFunction".to_string()); + __m.insert("List".to_string(), "FreeMonoid".to_string()); + __m.insert("list".to_string(), "FreeMonoid".to_string()); + __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("Map".to_string(), "PartialFunction".to_string()); + __m.insert("map".to_string(), "PartialFunction".to_string()); + __m.insert("FreeMonoid".to_string(), "FreeMonoid".to_string()); + __m.insert("free_monoid".to_string(), "FreeMonoid".to_string()); + __m.insert("BooleanAlgebra".to_string(), "BooleanAlgebra".to_string()); + __m.insert("boolean_algebra".to_string(), "BooleanAlgebra".to_string()); + __m.insert("PartialFunction".to_string(), "PartialFunction".to_string()); + __m.insert("partial_function".to_string(), "PartialFunction".to_string()); Rc::new(__m) }; } @@ -160,12 +160,12 @@ pub fn container_template_alias_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List", "FreeMonoid".to_string()); - __m.insert("list", "FreeMonoid".to_string()); - __m.insert("Set", "BooleanAlgebra".to_string()); - __m.insert("set", "BooleanAlgebra".to_string()); - __m.insert("Map", "PartialFunction".to_string()); - __m.insert("map", "PartialFunction".to_string()); + __m.insert("List".to_string(), "FreeMonoid".to_string()); + __m.insert("list".to_string(), "FreeMonoid".to_string()); + __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("Map".to_string(), "PartialFunction".to_string()); + __m.insert("map".to_string(), "PartialFunction".to_string()); Rc::new(__m) }; } @@ -201,18 +201,12 @@ pub enum Bool { False, } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Json(pub std::marker::PhantomData<()>); +pub type Json = serde_json::Value; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Bytes(pub std::marker::PhantomData<()>); +pub type Bytes = Vec; pub type Char = i64; -pub fn list_length(items: Rc>) -> i64 { - items.iter().cloned().fold(0, |acc: i64, _: T| (acc + 1)) -} - pub type CommitSha = String; pub type Sha256 = String; @@ -474,7 +468,7 @@ pub struct Document { } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct DocumentFile { +pub struct TextFile { pub path: String, pub document: Rc, } @@ -538,28 +532,3 @@ pub struct DocSource { pub path: FilePath, pub kind: DocSourceKind, } - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct ReferenceModel(pub std::marker::PhantomData); - -pub struct True; -pub struct False; -pub struct Pure; -pub struct Transport; -pub struct SubDag; -pub struct Env; -pub struct Template; -pub struct Generated; -pub struct Static; -pub struct Xs; -pub struct S; -pub struct M; -pub struct L; -pub struct Xl; -pub struct GET; -pub struct POST; -pub struct PUT; -pub struct PATCH; -pub struct DELETE; -pub struct HEAD; -pub struct OPTIONS; diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index 6550786741c..8b235a5ebfd 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -163,17 +163,3 @@ pub struct DagArtifact { pub diagnostics: Rc>, pub files: Rc>, } - -pub struct Rust; -pub struct Python; -pub struct Go; -pub struct Dag; -pub struct ServiceBinary; -pub struct Library; -pub struct Frontend; -pub struct GeneratedSupport; -pub struct DirectCall; -pub struct HttpJson; -pub struct MessageQueue; -pub struct Ffi; -pub struct FileProtocol; diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index 6c8e64335a0..d86d3d71511 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -82,8 +82,8 @@ pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) Some(syntax) => { let mut __found = false; for r in syntax.cast_rules.clone().iter().cloned() { - if ((r.from_type.clone() == source_type.clone()) - && (r.to_type.clone() == target_type.clone())) + if ((r.from_type.clone().as_str() == source_type.clone().as_str()) + && (r.to_type.clone().as_str() == target_type.clone().as_str())) { __found = true; break; @@ -116,7 +116,7 @@ pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option Option>, ref_name: String) -> Rc>>) -> Rc let parse_results = parsed.parse_results.clone(); let newline_indices = parsed.newline_indices.clone(); let parse_diagnostics = collect_diagnostics(parse_results.clone()); - let has_parse_errors = { - let mut __found = false; - for p in parse_results.clone().iter().cloned() { - if (p.error.clone() != None) { - __found = true; - break; - } - } - __found - }; + let has_parse_errors = parse_results + .iter() + .cloned() + .any(|p: Rc| p.error.clone() != None); if has_parse_errors { Rc::new(FrontendResult { graph: None, @@ -2287,28 +2282,26 @@ pub fn front_end_sources(sources: Rc>>) -> Rc intern_table: parsed.intern_table.clone(), }) } else { - { - let modules = Rc::new({ - let mut __result = Vec::new(); - for p in parse_results.clone().iter().cloned() { - __result.push(p.module.clone().clone().unwrap()); - } - __result - }); - let source_indices = newline_indices.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, si: Rc| { - v1_rt::rc_map_insert(acc, si.file.clone(), si.clone()) - }, - ); - let graph = resolve_modules(modules, source_indices); - Rc::new(FrontendResult { - graph: Some(graph.clone()), - diagnostics: v1_rt::concat(parse_diagnostics, graph.diagnostics.clone()), - newline_indices: newline_indices.clone(), - intern_table: parsed.intern_table.clone(), - }) - } + let modules = Rc::new({ + let mut __result = Vec::new(); + for p in parse_results.iter().cloned() { + __result.push(p.module.clone().clone().unwrap()); + } + __result + }); + let source_indices = newline_indices.clone().iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, si: Rc| { + v1_rt::rc_map_insert(acc, si.file.clone(), si.clone()) + }, + ); + let graph = resolve_modules(modules, source_indices); + Rc::new(FrontendResult { + graph: Some(graph.clone()), + diagnostics: v1_rt::concat(parse_diagnostics, graph.diagnostics.clone()), + newline_indices: newline_indices.clone(), + intern_table: parsed.intern_table.clone(), + }) } } } @@ -2352,9 +2345,40 @@ pub fn compile_to_resolved(sources: Rc>>) -> Rc>>, +) -> Rc { + compile_to_resolved_with_options_gated(sources, default_compile_pipeline_options(), true) +} + +fn is_resolved_pipeline_typecheck_blocking( + diagnostic: Rc, + discovery_corpus_advisory_typecheck: bool, +) -> bool { + if !is_error_diagnostic(diagnostic.clone()) { + return false; + } + if discovery_corpus_advisory_typecheck { + is_discovery_corpus_blocking_diagnostic(diagnostic) + } else { + true + } +} + pub fn compile_to_resolved_with_options( sources: Rc>>, options: CompilePipelineOptions, +) -> Rc { + compile_to_resolved_with_options_gated(sources, options, false) +} + +fn compile_to_resolved_with_options_gated( + sources: Rc>>, + options: CompilePipelineOptions, + discovery_corpus_advisory_typecheck: bool, ) -> Rc { { let frontend = front_end_sources(sources); @@ -2439,7 +2463,10 @@ pub fn compile_to_resolved_with_options( let type_errors = Rc::new({ let mut __result = Vec::new(); for d in typed_diags.clone().iter().cloned() { - if is_error_diagnostic(d.diagnostic.clone()) { + if is_resolved_pipeline_typecheck_blocking( + d.diagnostic.clone(), + discovery_corpus_advisory_typecheck, + ) { __result.push(d); } } diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 3eb380b8d46..ae8d86f6d14 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -409,8 +409,8 @@ pub fn parser_state_param( { let idx = pair.0.clone(); let param = pair.1.clone(); - if (authored_name_at(si.clone(), param_node_type_expr(param.clone())) - == "ParserState".to_string()) + if (authored_name_at(si.clone(), param_node_type_expr(param.clone())).as_str() + == "ParserState".to_string().as_str()) { Some(Rc::new(ParserStateParam { name: param_node_name_at(param.clone(), si.clone()), @@ -501,10 +501,10 @@ pub fn parser_state_arg_expr( let idx = pair.0.clone(); let arg_node = pair.1.clone(); let matches_state = if (arg_name_at(arg_node.clone(), si.clone()).as_deref() - != Some("".to_string())) + != Some("".to_string().as_str())) { (arg_name_at(arg_node.clone(), si.clone()).as_deref() - == Some(state_param.name.clone())) + == Some(state_param.name.clone().as_str())) } else { (idx.clone() == state_param.index.clone()) }; @@ -532,7 +532,7 @@ pub fn parser_state_expr_progress( binding_kind: _, .. } => { let name = expr_var_name_at(expr.clone(), si.clone()); - if (name.clone() == state_param.name.clone()) { + if (name.clone().as_str() == state_param.name.clone().as_str()) { DescentEvidence::NonIncreasing } else { match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { @@ -542,7 +542,9 @@ pub fn parser_state_expr_progress( } } ExprData::ExprFieldAccess { .. } => { - if (field_access_field_at(expr.clone(), si.clone()) == "state".to_string()) { + if (field_access_field_at(expr.clone(), si.clone()).as_str() + == "state".to_string().as_str()) + { match parser_state_base_var(expr.clone(), si.clone()) { Some(result_name) => { match v1_rt::map_get(&env.result_sources.clone(), result_name.clone()) { @@ -1159,7 +1161,9 @@ pub fn parser_record_field_value( for child in Rc::new({ let mut __result = Vec::new(); for child in expr.children.clone().iter().cloned() { - if (field_init_node_name_at(child.clone(), si.clone()) == field_name.clone()) { + if (field_init_node_name_at(child.clone(), si.clone()).as_str() + == field_name.clone().as_str()) + { __result.push(child); } } @@ -1569,7 +1573,7 @@ pub fn build_call_graph_from_parser_edges( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (edge.caller.clone() != edge.callee.clone()) { + if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { __result.push(edge); } } @@ -1605,7 +1609,7 @@ pub fn same_progress_subgraph_has_cycle( let has_self_cycle = { let mut __found = false; for edge in same_edges.clone().iter().cloned() { - if (edge.caller.clone() == edge.callee.clone()) { + if (edge.caller.clone().as_str() == edge.callee.clone().as_str()) { __found = true; break; } @@ -1619,7 +1623,7 @@ pub fn same_progress_subgraph_has_cycle( let same_cross_edges = Rc::new({ let mut __result = Vec::new(); for edge in same_edges.clone().iter().cloned() { - if (edge.caller.clone() != edge.callee.clone()) { + if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { __result.push(edge); } } @@ -1747,7 +1751,7 @@ pub fn count_self_calls( let own = match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - if (f == func_name.clone()) { + if (f.as_str() == func_name.clone().as_str()) { 1 } else { 0 @@ -1785,7 +1789,11 @@ pub fn max_path_self_calls_with_cont( match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - let own = if (f == func_name.clone()) { 1 } else { 0 }; + let own = if (f.as_str() == func_name.clone().as_str()) { + 1 + } else { + 0 + }; let arg_calls = body.children .clone() @@ -2344,7 +2352,7 @@ pub fn descending_name_set_without_key( Rc::new(v1_rt::map_keys(&names)).iter().cloned().fold( v1_rt::rc_empty_map::(), |acc: Rc>, name: String| { - if (name.clone() == key.clone()) { + if (name.clone().as_str() == key.clone().as_str()) { acc.clone() } else { match v1_rt::map_get(&names, name.clone()) { @@ -2573,7 +2581,9 @@ pub fn has_arithmetic_descent( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let own_ok = if (expr_call_func_at(body.clone(), si.clone()) == func_name.clone()) { + let own_ok = if (expr_call_func_at(body.clone(), si.clone()).as_str() + == func_name.clone().as_str()) + { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -2633,7 +2643,7 @@ pub fn is_accessor_of_param( binding_kind: _, .. } => { let vname = expr_var_name_at(arg_value(arg_node.clone()), si.clone()); - ((vname.clone() == param_name.clone()) + ((vname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), vname.clone())) } _ => false, @@ -2664,7 +2674,10 @@ pub fn is_children_of_param( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name), + } => { + (expr_var_name_at(base.clone(), si.clone()).as_str() + == param_name.as_str()) + } _ => false, }); } @@ -2818,7 +2831,10 @@ pub fn is_list_shrink_expr( && match (*method_receiver(expr.clone()).expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(method_receiver(expr.clone()), si) == param_name), + } => { + (expr_var_name_at(method_receiver(expr.clone()), si).as_str() + == param_name.as_str()) + } _ => false, }) && match method_arg_nodes(expr.clone()).first().cloned() { @@ -2917,7 +2933,7 @@ pub fn consuming_tokens_arg( Some(_) => acc.clone(), None => match arg_name_at(child.clone(), si.clone()) { Some(name) => { - if (name.clone() == "tokens".to_string()) { + if (name.clone().as_str() == "tokens".to_string().as_str()) { Some(arg_value(child.clone())) } else { None @@ -2940,11 +2956,12 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone() == param_name.clone()) || set_has(vars, vname.clone())); + break ((vname.clone().as_str() == param_name.clone().as_str()) + || set_has(vars, vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field == param_name.clone()) { + if (field.as_str() == param_name.clone().as_str()) { break true; } else { let base = field_access_base(expr.clone()); @@ -2953,7 +2970,7 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - break ((bname.clone() == param_name.clone()) + break ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(vars, bname.clone())); } _ => { @@ -3096,7 +3113,7 @@ pub fn expr_contains_descent( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone() == param_name.clone()) + ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3189,7 +3206,10 @@ pub fn is_if_option_descent( Some(eb) => match (*eb.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(eb.clone(), si.clone()) == "none".to_string()), + } => { + (expr_var_name_at(eb.clone(), si.clone()).as_str() + == "none".to_string().as_str()) + } ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, _ => false, @@ -3267,8 +3287,8 @@ pub fn is_match_option_descent( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(arm_b.clone(), si.clone()) - != param_name.clone()) + (expr_var_name_at(arm_b.clone(), si.clone()).as_str() + != param_name.clone().as_str()) } _ => true, } @@ -3386,7 +3406,8 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()) == param_name.clone()) + (expr_var_name_at(inner.clone(), si.clone()).as_str() + == param_name.clone().as_str()) } _ => false, }; @@ -3405,7 +3426,7 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone() == param_name.clone()) + ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3495,7 +3516,7 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) + ((sname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3673,7 +3694,7 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone() == param_name.clone()) + ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3728,7 +3749,7 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) + ((sname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3857,7 +3878,7 @@ pub fn all_self_calls_descend_inc( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_ok = if (callee == func_name.clone()) { + let own_ok = if (callee.as_str() == func_name.clone().as_str()) { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -4069,7 +4090,10 @@ pub fn matches_on_sub_value_field( && match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == param_name), + } => { + (expr_var_name_at(base.clone(), si.clone()).as_str() + == param_name.as_str()) + } _ => false, }) } @@ -4150,7 +4174,7 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left.clone(), si) == param_name) + ((expr_var_name_at(left.clone(), si).as_str() == param_name.as_str()) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { @@ -4205,7 +4229,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone() == param_name.clone()) { + if (vname.clone().as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4270,14 +4294,14 @@ pub fn classify_self_call_evidence( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone() == param_name.clone())) + || (bname.clone().as_str() == param_name.clone().as_str())) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (field == param_name.clone()) { + if (field.as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4479,7 +4503,8 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()) == param_name.clone()) + (expr_var_name_at(inner.clone(), si.clone()).as_str() + == param_name.clone().as_str()) } _ => false, }; @@ -4498,7 +4523,7 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone() == param_name.clone()) + ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -4600,7 +4625,7 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone() == param_name.clone()) + ((sname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -4729,7 +4754,7 @@ pub fn collect_evidence_incremental( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_evidence = if (callee == func_name.clone()) { + let own_evidence = if (callee.as_str() == func_name.clone().as_str()) { { let arg_evidence = body.children.clone().iter().cloned().fold( DescentEvidence::DescentUnknown, @@ -5769,7 +5794,7 @@ pub fn build_call_graph( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (edge.caller.clone() != edge.callee.clone()) { + if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { __result.push(edge); } } @@ -5822,7 +5847,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone() == param_name.clone()) { + if (vname.clone().as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5876,14 +5901,14 @@ pub fn classify_scc_call_progress( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone() == param_name.clone())) + || (bname.clone().as_str() == param_name.clone().as_str())) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (field == param_name.clone()) { + if (field.as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -6221,7 +6246,8 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()) == param_name.clone()) + (expr_var_name_at(inner.clone(), si.clone()).as_str() + == param_name.clone().as_str()) } _ => false, }; @@ -6240,7 +6266,7 @@ pub fn collect_scc_child_edges( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone() == param_name.clone()) + ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(descent_vars.clone(), bname.clone())) } _ => false, @@ -6737,7 +6763,7 @@ let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pnam let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); -let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (pe.caller.clone() == name.clone()) { __result.push(pe); } } __result }); +let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (pe.caller.clone().as_str() == name.clone().as_str()) { __result.push(pe); } } __result }); let parser_edge_map = my_parser_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); let all_keys = v1_rt::concat(Rc::new(v1_rt::map_keys(&tree_edge_map)), Rc::new(v1_rt::map_keys(&parser_edge_map))); let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |acc: Rc>, k: String| v1_rt::rc_map_insert(acc, k.clone(), true)); @@ -6790,7 +6816,7 @@ let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for _ => false, } { __found = true; break; } } __found }) { __all = false; break; } } __all }); let descending_param = match self_evidence.clone().first().cloned() { - Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: String, rel: Rc| if (found.clone() != "".to_string()) { + Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: String, rel: Rc| if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match (*rel.clone()).clone() { @@ -6834,7 +6860,7 @@ Rc::new(vec![Rc::new(ProofEdge { } else { Rc::new(vec![]) }; -let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone() != name.clone()) { __result.push(m); } } __result }); +let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone().as_str() != name.clone().as_str()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { @@ -6869,7 +6895,7 @@ pub fn scc_descending_param( .iter() .cloned() .fold("".to_string(), |found: String, name: String| { - if (found.clone() != "".to_string()) { + if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match v1_rt::map_get(&func_index, name.clone()) { @@ -6883,7 +6909,7 @@ pub fn scc_descending_param( Some(call_ev) => call_ev.clone().iter().cloned().fold( "".to_string(), |p: String, rel: Rc| { - if (p.clone() != "".to_string()) { + if (p.clone().as_str() != "".to_string().as_str()) { p.clone() } else { match (*rel.clone()).clone() { @@ -6940,7 +6966,7 @@ pub fn construct_scc_termination_proof( let cx_l2_param = scc_descending_param(members.clone(), func_index.clone(), si.clone()); let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { - param: if (cx_l2_param.clone() != "".to_string()) { + param: if (cx_l2_param.clone().as_str() != "".to_string().as_str()) { cx_l2_param.clone() } else { "scc".to_string() @@ -7505,7 +7531,7 @@ pub fn resolve_lambda_arg( let f_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_arg_nodes.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()) == "f".to_string()) { + if (authored_name_at(si.clone(), a.clone()).as_str() == "f".to_string().as_str()) { __result.push(a); } } @@ -8266,7 +8292,8 @@ pub fn build_legend(size_names: Rc>) -> Rc { name.clone(), short.clone(), ), - suffix: if (acc.suffix.clone() == "".to_string()) { + suffix: if (acc.suffix.clone().as_str() == "".to_string().as_str()) + { v1_rt::concat( v1_rt::concat( v1_rt::concat(" where ".to_string(), short.clone()), @@ -8387,14 +8414,14 @@ pub fn classify_complexity(expr: Rc) -> String { pub fn collect_size_vars_from_size(size: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { - if (c.clone() == "__expr".to_string()) { + if (c.clone().as_str() == "__expr".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![c.clone()]) } } SizeExpr::SizeVar { name: n, .. } => { - if (n.clone() == "__k".to_string()) { + if (n.clone().as_str() == "__k".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![n.clone()]) @@ -9450,7 +9477,7 @@ pub fn max_path_descending( .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own = if (callee == fn_name.clone()) { + let own = if (callee.as_str() == fn_name.clone().as_str()) { match de.clone() { Some(evidence) => { match evidence.clone().get(param_index.clone() as usize).cloned() { @@ -9888,6 +9915,3 @@ pub fn build_complexity_report( }) } } - -pub struct Proven; -pub struct Conservative; diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index e428c2b2203..9471d8bd69f 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -192,7 +192,7 @@ pub fn derive_module_imports( ImportTrigger::TypeUsageTrigger { type_name: t, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (n.clone() == t.clone()) { + if (n.clone().as_str() == t.clone().as_str()) { __found = true; break; } @@ -204,7 +204,7 @@ pub fn derive_module_imports( ImportTrigger::ContainerUsageTrigger { container: c, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (n.clone() == c.clone()) { + if (n.clone().as_str() == c.clone().as_str()) { __found = true; break; } @@ -228,7 +228,7 @@ pub fn derive_module_imports( .iter() .cloned() { - if (path.clone() != "".to_string()) { + if (path.clone().as_str() != "".to_string().as_str()) { __result.push(path); } } @@ -512,7 +512,7 @@ pub fn emit_simple_string_interp( .iter() .cloned() { - if (a.clone() != "".to_string()) { + if (a.clone().as_str() != "".to_string().as_str()) { __result.push(a); } } @@ -652,7 +652,7 @@ pub fn typed_named_arg_matches( if (n.clone() == None) { false } else { - (n.clone().unwrap() == name) + (n.clone().unwrap().as_str() == name.as_str()) } } } @@ -1187,7 +1187,7 @@ pub fn emit_bin_op_symbol( } pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> String { - if (kind.clone() == "optional".to_string()) { + if (kind.clone().as_str() == "optional".to_string().as_str()) { apply_type_template1(target_optional_template(target.clone()), inner) } else { match coerce_container_template(target.clone(), kind.clone()) { @@ -1333,7 +1333,8 @@ pub fn render_node_type( { let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { - ((tn.clone() != "".to_string()) && (tn.clone() == var_id.clone())) + ((tn.clone().as_str() != "".to_string().as_str()) + && (tn.clone().as_str() == var_id.clone().as_str())) } _ => false, }; @@ -1387,7 +1388,7 @@ pub fn render_node_type( ret_str.clone(), ), None => { - if (ret_str.clone() == "".to_string()) { + if (ret_str.clone().as_str() == "".to_string().as_str()) { { let void_template = v1_rt::replace( repr.template.clone(), @@ -1529,7 +1530,8 @@ pub fn render_node_type( }; if has_template { { - let base = if (snake.clone() == "map".to_string()) { + let base = if (snake.clone().as_str() == "map".to_string().as_str()) + { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { emit_container(snake.clone(), "_".to_string(), target.clone()) @@ -1573,8 +1575,8 @@ pub fn render_node_type( } if ((n.children.clone().len() as i64) == 0) { { - let bare_is_map = - (is_container_type(tn.clone()) && (to_snake(tn.clone()) == "map".to_string())); + let bare_is_map = (is_container_type(tn.clone()) + && (to_snake(tn.clone()).as_str() == "map".to_string().as_str())); let bare_is_collection = (is_declared_container_alias_spelling(tn.clone()) && !bare_is_map.clone()); let has_container_template = match container_template_algebra(to_snake(tn.clone())) @@ -1630,7 +1632,7 @@ pub fn render_node_type( ) } } else { - if (tn.clone() == tuple_type_name()) { + if (tn.clone().as_str() == tuple_type_name().as_str()) { render_tuple_parts(Rc::new(vec![]), target.clone()) } else { coerce_primitive_type(target.clone(), tn.clone()) @@ -1724,7 +1726,7 @@ pub fn render_node_type( } __result }); - if (tn.clone() == tuple_type_name()) { + if (tn.clone().as_str() == tuple_type_name().as_str()) { { let multi_tuple_str = render_tuple_parts(child_strs.clone(), target.clone()); return multi_tuple_str; @@ -2087,10 +2089,10 @@ pub fn emit_unified_operation_method( let op_text = authored_name(env.clone(), op_node.clone()); let params_str = emit_params_shared(op_node.params.clone(), target.clone(), si.clone()); let sp = service_self_param(spec.clone()); - let all_params = if (sp.clone() == "".to_string()) { + let all_params = if (sp.clone().as_str() == "".to_string().as_str()) { params_str.clone() } else { - if (params_str.clone() == "".to_string()) { + if (params_str.clone().as_str() == "".to_string().as_str()) { sp.clone() } else { v1_rt::concat( @@ -2538,7 +2540,7 @@ pub fn emit_shared_tco_expr( let si = frame.scope.clone().type_env.clone().source_indices.clone(); match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si) == fn_name) { + if (expr_call_func_at(frame.expr.clone(), si).as_str() == fn_name.as_str()) { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), @@ -3250,7 +3252,7 @@ pub fn emit_unified_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let bs = language_spec(target.clone()).block_syntax.clone(); - if (bs.block_close.clone() == "".to_string()) { + if (bs.block_close.clone().as_str() == "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrut_str), @@ -3592,7 +3594,8 @@ pub fn is_tco_candidate( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - (expr_call_func_at(texpr.clone(), source_indices.clone()) == func_name.clone()) + (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() + == func_name.clone().as_str()) } ExprData::ExprReturn => is_tco_candidate( return_value(texpr.clone()), @@ -3671,7 +3674,9 @@ pub fn suffix_escape_collides_with_reserved_chain( &name, (name_len.clone() - suffix_len.clone()), name_len.clone(), - ) != suffix.clone()) + ) + .as_str() + != suffix.clone().as_str()) { break false; } else { @@ -3679,7 +3684,7 @@ pub fn suffix_escape_collides_with_reserved_chain( if { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (r.clone() == base.clone()) { + if (r.clone().as_str() == base.clone().as_str()) { __found = true; break; } @@ -3708,7 +3713,7 @@ pub fn emit_suffix_escape_ident( let is_reserved = { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (r.clone() == converted.clone()) { + if (r.clone().as_str() == converted.clone().as_str()) { __found = true; break; } @@ -3741,7 +3746,7 @@ pub fn emit_ident(name: String, target: RenderTarget) -> String { let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (r.clone() == converted.clone()) { + if (r.clone().as_str() == converted.clone().as_str()) { __found = true; break; } @@ -3784,7 +3789,7 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (r.clone() == result.clone()) { + if (r.clone().as_str() == result.clone().as_str()) { __found = true; break; } @@ -3941,10 +3946,12 @@ pub fn emit_expr_var_shared( ) -> String { { let n = expr_var_name_at(expr, source_indices); - if (n.clone() == "none".to_string()) { + if (n.clone().as_str() == "none".to_string().as_str()) { emit_keyword("null".to_string(), target) } 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(), target) } else { emit_ident(n.clone(), target) @@ -4007,7 +4014,9 @@ pub fn emit_typed_cast_shared( } _ => "".to_string(), }; - if ((src_ty.clone() != "".to_string()) && (src_ty.clone() == ty_str.clone())) { + if ((src_ty.clone().as_str() != "".to_string().as_str()) + && (src_ty.clone().as_str() == ty_str.clone().as_str())) + { expr_str } else { if can_cast(target.clone(), src_ty.clone(), ty_str.clone()) { @@ -4791,7 +4800,7 @@ pub fn emit_typed_string_interp_unified( .iter() .cloned() { - if (a.clone() != "".to_string()) { + if (a.clone().as_str() != "".to_string().as_str()) { __result.push(a); } } @@ -5568,7 +5577,7 @@ pub fn emit_typed_match_unified( __result }); let arms_str = arm_strs.join(&"\n".to_string()); - if (bs.block_close.clone() == "".to_string()) { + if (bs.block_close.clone().as_str() == "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrutinee_str), @@ -6014,7 +6023,7 @@ pub fn is_tco_identity_passthrough( match (*arg_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(arg_val.clone(), si) == param_name), + } => (expr_var_name_at(arg_val.clone(), si).as_str() == param_name.as_str()), _ => false, } } @@ -6096,15 +6105,3 @@ pub fn emit_typed_tco_reassign_shared( pub fn seed_bindings(key: String, value: String) -> Rc> { v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) } - -pub struct CapServiceEmit; -pub struct CapAsyncTransport; -pub struct CapTestGeneration; -pub struct CapDryRunMode; -pub struct CapRcOwnership; -pub struct ExprCatLeaf; -pub struct ExprCatCompound; -pub struct ExprCatControlFlow; -pub struct ExprCatBinding; -pub struct ExprCatService; -pub struct ExprCatNone; diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index e384a9d4951..35da76811db 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -551,7 +551,7 @@ pub fn has_mock_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5) == "mock_".to_string()) + (v1_rt::substring(&name, 0, 5).as_str() == "mock_".to_string().as_str()) } } @@ -651,7 +651,7 @@ pub fn is_type_alias_return_node( n: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, n) != "Unit".to_string()) + (authored_name_at(source_indices, n).as_str() != "Unit".to_string().as_str()) } pub fn is_service_item(item: Rc) -> bool { diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 80ca723d392..fb593f98367 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -135,11 +135,12 @@ pub fn emit_go(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); } @@ -153,7 +154,7 @@ pub fn emit_go(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone() != "".to_string()) { + if (f.path.clone().as_str() != "".to_string().as_str()) { __result.push(f); } } @@ -483,7 +484,7 @@ pub fn emit_go_module( module_imports(m.clone()), si.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\n".to_string(), imports_str.clone()) @@ -1580,7 +1581,7 @@ pub fn emit_go_rest_call( v1_rt::concat( v1_rt::concat( Rc::new(vec![url_line, body_line, req_line]), - if (auth_line.clone() == "".to_string()) { + if (auth_line.clone().as_str() == "".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![auth_line.clone()]) @@ -1828,7 +1829,7 @@ pub fn go_export_ident(name: String) -> String { if { let mut __found = false; for r in go_reserved().iter().cloned() { - if (r.clone() == result.clone()) { + if (r.clone().as_str() == result.clone().as_str()) { __found = true; break; } diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index ddb3cc3f4a9..6c00b21f8fb 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -123,11 +123,12 @@ pub fn emit_python(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); } @@ -141,7 +142,7 @@ pub fn emit_python(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone() != "".to_string()) { + if (f.path.clone().as_str() != "".to_string().as_str()) { __result.push(f); } } @@ -370,7 +371,7 @@ pub fn emit_py_module( let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); - let imports_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()) @@ -499,7 +500,7 @@ pub fn emit_py_imports( Rc::new({ let mut __result = Vec::new(); for line in import_lines.iter().cloned() { - if (line.clone() != "".to_string()) { + if (line.clone().as_str() != "".to_string().as_str()) { __result.push(line); } } @@ -1290,7 +1291,7 @@ pub fn emit_py_headers_dict( } __result }); - let all_entries = if (auth_entry.clone() == "".to_string()) { + let all_entries = if (auth_entry.clone().as_str() == "".to_string().as_str()) { header_entries.join(&", ".to_string()) } else { v1_rt::concat(auth_entry.clone(), header_entries.join(&", ".to_string())) @@ -1470,7 +1471,7 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String __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()) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index fedbdc81610..8588f1532c4 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, @@ -37,17 +36,16 @@ pub use crate::v1_compiler_emit::{ pub use crate::v1_compiler_emit_core_support::{ apply_named_template, apply_type_template1, apply_type_template2, apply_type_template3, capitalize_first, escape_json_string, escape_string_literal_body, extract_test_projections, - has_mock_prefix, is_data_def_item, is_function_item, is_resource_def_item, is_service_def_item, - is_service_item, is_type_alias_item, is_type_alias_return_node, is_type_decl_item, - is_type_def_item, is_upper, language_spec, make_indent, module_to_filename, + has_mock_prefix, is_bare_leaf_item, is_data_def_item, is_function_item, is_resource_def_item, + is_service_def_item, is_service_item, is_type_alias_item, is_type_alias_return_node, + is_type_decl_item, is_type_def_item, is_upper, language_spec, make_indent, module_to_filename, sanitize_service_name, service_var_name, test_function_name, to_lower_char, to_pascal, to_screaming_snake, to_snake, to_string, to_string_helper, to_upper_char, unique_strings, }; 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::TypeRepr::{EnumRepr, StructRepr}; pub use crate::v1_compiler_infer_emit_info::{ @@ -85,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}; @@ -161,18 +160,6 @@ pub fn render_rust_type( Rc::new(vec![]), 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_type_without_applied_binding( @@ -205,15 +192,6 @@ pub fn render_rust_type_without_applied_binding( Rc::new(vec![]), 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::>>>(), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -253,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)) - && rust_emit_faithful_text_carrier(source_indices.clone())) - { - 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(), + ) } } } @@ -278,24 +255,16 @@ 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 rust_corpus_includes_v1_compiler( source_indices: Rc>>, ) -> bool { - { - let mut __found = false; - for k in Rc::new(v1_rt::map_keys(&source_indices)).iter().cloned() { - if (v1_rt::contains(k.clone(), "/v1/".to_string()) - || v1_rt::contains(k.clone(), "src/v1".to_string())) - { - __found = true; - break; - } - } - __found - } + v1_rt::map_keys(&source_indices) + .iter() + .cloned() + .any(|k| k.contains("/v1/") || k.contains("src/v1")) } pub fn rust_emit_faithful_text_carrier( @@ -347,33 +316,38 @@ 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())) - } 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 - } - } -} - -pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if ((name.clone() == "Json".to_string()) || (name.clone() == "Bytes".to_string())) { - Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) + 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 { None } } -pub fn rust_seed_host_numeric_alias( - name: String, - source_indices: Rc>>, -) -> Option { - if (((name.clone() == "Nat".to_string()) || (name.clone() == "Int".to_string())) - && rust_corpus_includes_v1_compiler(source_indices)) +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()) { - Some("i64".to_string()) + Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { None } @@ -383,16 +357,16 @@ pub fn rust_named_type_base( name: String, source_indices: Rc>>, ) -> String { - if ((name.clone() == "Witness".to_string()) || (name.clone() == "witness".to_string())) { + if ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) + { "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()) - && rust_emit_faithful_text_carrier(source_indices)) - { - "FreeMonoid".to_string() - } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) - } + coerce_primitive_type(RenderTarget::Rust, name.clone()) } } @@ -425,19 +399,10 @@ pub fn render_rust_applied_type_arg( generic_param_names: Rc>, shared_types: Rc>, 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, - variant_to_enum, - env, - ), + _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), } } @@ -446,8 +411,6 @@ pub fn render_rust_applied_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { let base = rust_named_type_base( @@ -466,8 +429,6 @@ pub fn render_rust_applied_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), )); } __result @@ -500,8 +461,6 @@ pub fn render_rust_applied_type_shared( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { let rendered = render_rust_applied_type( @@ -509,8 +468,6 @@ pub fn render_rust_applied_type_shared( generic_param_names, shared_types.clone(), 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()) @@ -522,8 +479,6 @@ pub fn render_rust_decl_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -531,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()) @@ -547,8 +503,6 @@ pub fn render_rust_decl_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -557,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; } @@ -566,87 +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())) - && rust_emit_faithful_text_carrier(source_indices.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(), - 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(), - 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(), - 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(), + ) } } } @@ -655,23 +589,21 @@ 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( @@ -679,44 +611,25 @@ pub fn render_rust_fn_sig_type( generic_param_names: Rc>, shared_types: Rc>, 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())) - && rust_emit_faithful_text_carrier(source_indices.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, - source_indices.clone(), - variant_to_enum, - env.clone(), - ) - } else { - render_rust_fn_sig_type_applied_binding( - n.clone(), - shared_types, - 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) } } @@ -733,37 +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, - 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, - 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, source_indices.clone()) - } + None => render_rust_type_with_applied_binding(n, shared_types, source_indices), } } @@ -788,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; } @@ -797,96 +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()) { - if ((name.clone() == "String".to_string()) - && rust_emit_faithful_text_carrier(source_indices.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 = 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 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(), - 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(), source_indices.clone()) + applied_ty.clone() } } + } else { + render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -1013,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)) @@ -1031,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() { @@ -1065,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()))) } } @@ -1167,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); } } @@ -1237,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(), @@ -1263,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(), @@ -1280,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(), @@ -1310,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), @@ -1321,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), @@ -1332,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), @@ -1343,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(), @@ -1363,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(), @@ -1383,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(), @@ -1437,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( @@ -1448,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( @@ -1481,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( @@ -1674,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( @@ -1685,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, } } @@ -1714,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; } @@ -1745,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(), @@ -1766,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; @@ -1828,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; } @@ -1893,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); } } @@ -2265,173 +2213,6 @@ pub fn emit_rust_init_block_stmts( } } -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 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()); - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - vname.clone(), - ), - ";".to_string(), - ) - }); - } - __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(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - vname.clone(), - ), - ";".to_string(), - )); - } - __result - }) - .join(&"\n".to_string()) -} - pub fn has_complex_variants(item: Rc) -> bool { if ((item.children.clone().len() as i64) == 0) { false @@ -2571,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); } @@ -2830,11 +2612,12 @@ 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); } @@ -2848,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); } } @@ -2859,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; @@ -2968,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() }; @@ -3108,7 +2892,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()) @@ -3138,7 +2922,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( @@ -3225,7 +3009,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( @@ -3286,19 +3070,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 { @@ -3500,10 +3284,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; @@ -3555,8 +3339,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; @@ -3598,7 +3382,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()))) @@ -3631,7 +3416,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()))) @@ -3713,7 +3499,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; } @@ -3808,7 +3594,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; } @@ -3862,7 +3648,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; } @@ -4036,7 +3823,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); } } @@ -4111,7 +3898,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())) { @@ -4136,7 +3924,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; } @@ -4233,7 +4021,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); @@ -4306,7 +4094,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; @@ -4344,7 +4132,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( @@ -4396,7 +4184,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; } @@ -4509,7 +4297,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; @@ -4600,7 +4388,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))) { @@ -4653,7 +4441,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; } @@ -4760,8 +4548,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()))) @@ -4808,12 +4596,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, @@ -4824,34 +4628,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 { @@ -5049,7 +4827,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( @@ -5098,100 +4878,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( @@ -5221,21 +4992,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 + } } } } @@ -5263,7 +5050,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; } @@ -5405,7 +5192,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); } } @@ -5439,7 +5226,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; @@ -5461,7 +5248,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; } @@ -5486,7 +5273,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; @@ -5570,7 +5357,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); } @@ -5648,13 +5437,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![]) @@ -5674,7 +5463,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(), @@ -5685,7 +5476,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, }, } { @@ -5724,15 +5517,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) { @@ -5753,7 +5546,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); } } @@ -5764,7 +5557,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); } } @@ -5800,7 +5593,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(), @@ -5813,7 +5609,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(), @@ -5892,7 +5689,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; } @@ -5926,7 +5723,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); } } @@ -5935,7 +5732,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); } } @@ -6059,7 +5856,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(), @@ -6092,7 +5889,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 { { @@ -6117,14 +5916,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))) @@ -6163,7 +5965,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); } } @@ -6276,7 +6080,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); } @@ -6346,7 +6151,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(), @@ -6476,73 +6282,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(), - env.source_indices.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, - 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()) { @@ -6608,18 +6385,16 @@ pub fn emit_typed_item( ";".to_string(), ) } - } else { - if is_parametric_opaque_type_decl_item( + } 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(), - ) { - emit_parametric_phantom_opaque_struct( - item.clone(), - env.source_indices.clone(), - ) - } else { - "".to_string() - } + ) + } else { + "".to_string() } } } else { @@ -6752,7 +6527,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()); @@ -6803,11 +6580,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)) } } @@ -6928,10 +6706,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( @@ -6958,7 +6737,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( @@ -6971,76 +6750,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) { - match unused.clone().first().cloned() { - Some(u) => u.clone(), - None => "()".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, @@ -7063,7 +6772,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(), @@ -7115,32 +6826,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( @@ -7183,74 +6869,45 @@ 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(), - 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(), + 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(), source_indices.clone()) + render_rust_type(n.clone(), shared_types, source_indices.clone()) } } - None => render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()), + None => render_rust_type(n.clone(), shared_types, source_indices.clone()), } } @@ -7422,7 +7079,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 @@ -7453,8 +7110,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); } @@ -7497,20 +7154,21 @@ pub fn emit_rust_field_definition( visibility: String, ) -> String { { - 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())) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + 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( + 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( @@ -7580,7 +7238,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()) @@ -7622,7 +7280,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( @@ -7671,7 +7329,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; } @@ -7735,7 +7395,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); } @@ -7763,7 +7424,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; } @@ -7786,7 +7447,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); } } @@ -7943,7 +7606,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, @@ -7965,7 +7629,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, @@ -7978,120 +7644,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( @@ -8101,9 +7714,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 { @@ -8122,7 +7735,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) => { @@ -8185,7 +7798,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); } } @@ -8270,7 +7883,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, } } @@ -8305,7 +7920,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) => { @@ -8503,75 +8119,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 rust_emit_faithful_text_carrier(si.clone()) { - seam_fn.clone() - } else { - "".to_string() - } + 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())); } - 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( + __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(), 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(), - 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(), - 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( @@ -8582,53 +8194,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, + ) } } } @@ -8790,7 +8398,6 @@ pub fn emit_func_def( shared_types.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( @@ -9010,7 +8617,6 @@ pub fn emit_tco_params( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9022,7 +8628,6 @@ pub fn emit_tco_params( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9037,7 +8642,6 @@ pub fn emit_tco_param( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9048,8 +8652,7 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( @@ -9057,7 +8660,6 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, env, ) }; @@ -9084,7 +8686,6 @@ pub fn emit_func_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9097,7 +8698,6 @@ pub fn emit_func_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9158,7 +8758,6 @@ pub fn emit_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9171,7 +8770,6 @@ pub fn emit_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9186,17 +8784,15 @@ pub fn render_rust_param_sig_type( generic_param_names: Rc>, shared_types: Rc>, 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, source_indices, - variant_to_enum, env, ) } @@ -9207,7 +8803,6 @@ pub fn emit_rust_param_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -9220,7 +8815,6 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -9233,7 +8827,6 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -9255,8 +8848,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), + env, ) } } @@ -9267,7 +8859,6 @@ pub fn emit_param( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -9278,8 +8869,7 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( @@ -9287,7 +8877,6 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, env, ) }; @@ -9307,7 +8896,6 @@ pub fn emit_inferred( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -9317,7 +8905,6 @@ pub fn emit_inferred( generic_param_names, shared_types, source_indices, - variant_to_enum, env, ), ) @@ -9400,11 +8987,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(), @@ -9423,7 +9011,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()]) @@ -9454,7 +9042,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)) { @@ -9497,7 +9085,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( @@ -9638,7 +9227,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() @@ -9681,12 +9270,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, } } @@ -9744,7 +9334,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() @@ -9757,7 +9347,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( @@ -9769,7 +9359,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() { @@ -9800,8 +9390,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()); @@ -10004,24 +9594,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(), ); @@ -10032,13 +9623,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(), @@ -10046,25 +9639,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(), @@ -10135,7 +9729,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; } @@ -10171,7 +9765,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![]), @@ -10195,23 +9790,24 @@ pub fn analyze_rc_pattern( None => false, }; let ref_bound_fields = Rc::new({ - let mut __result = Vec::new(); - for fb in fbs.clone().iter().cloned() { - __result.extend( - (*{ - 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 mut __result = Vec::new(); + for fb in fbs.clone().iter().cloned() { + __result.extend( + (*{ + 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() + }; if analyze_rc_pattern( field_binding_pattern(fb.clone()), inner_scrut.clone(), @@ -10371,7 +9967,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() @@ -10384,7 +9980,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( @@ -10396,7 +9992,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() { @@ -10435,8 +10031,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()); @@ -10671,24 +10267,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(), ); @@ -10716,7 +10313,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() { @@ -10726,26 +10326,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(), @@ -10853,7 +10453,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(), @@ -10876,7 +10476,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()]) @@ -10961,7 +10563,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 { @@ -11036,6 +10638,117 @@ 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( name: String, binding_kind: Option>, @@ -11046,7 +10759,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 @@ -11059,7 +10772,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(), @@ -11086,10 +10800,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 { { @@ -11105,9 +10823,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() @@ -11197,10 +10915,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 { { @@ -11214,9 +10936,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() @@ -11327,7 +11050,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); } @@ -11464,7 +11189,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) @@ -11477,12 +11202,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) @@ -11529,7 +11254,7 @@ pub fn rust_empty_map_value_type_str( shared_types, source_indices, ); - if (rendered.clone() == "".to_string()) { + if (rendered.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { rendered.clone() @@ -11558,7 +11283,9 @@ pub fn rust_empty_map_kv_type_str( shared_types.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(), @@ -11586,12 +11313,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())) } } @@ -11664,7 +11391,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(), @@ -11967,17 +11694,11 @@ pub fn emit_rust_expr_record_lit( scope.type_env.clone().source_indices.clone(), ); let fs = expr.children.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 raw = emit_typed_record_lit( tn.clone(), fs, parent_enum.clone(), - expanded_rt.clone(), + resolved_type(expr.clone()), registry, scope.clone(), depth, @@ -11994,26 +11715,15 @@ pub fn emit_rust_expr_record_lit( 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()) @@ -12448,7 +12158,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(), @@ -12616,7 +12326,7 @@ 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( @@ -12624,7 +12334,7 @@ pub fn emit_typed_call_expr( shared_types, 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(), @@ -12641,7 +12351,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( @@ -12685,7 +12395,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(); @@ -12729,7 +12439,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) { @@ -12827,7 +12537,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()); @@ -12855,17 +12565,38 @@ pub fn emit_typed_call( 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() { @@ -12884,10 +12615,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()); @@ -13062,7 +12793,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()) @@ -13118,11 +12850,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; @@ -13235,7 +12968,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( @@ -13674,9 +13407,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 { @@ -13725,7 +13459,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 { { @@ -14053,9 +13787,9 @@ 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()) { { @@ -14064,7 +13798,7 @@ pub fn emit_rust_fold_method_call( shared_types.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(), @@ -14077,12 +13811,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( @@ -14091,7 +13826,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( @@ -14212,7 +13948,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()) @@ -14699,7 +14435,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()); @@ -14937,7 +14675,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); } @@ -15034,7 +14774,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(), @@ -15048,7 +14788,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(), @@ -15059,7 +14799,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(), @@ -15073,7 +14813,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); } } @@ -15093,7 +14835,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(), @@ -15104,7 +14847,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(), @@ -15115,8 +14860,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(), @@ -15130,7 +14875,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(), @@ -15167,7 +14914,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(), @@ -15558,8 +15306,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( @@ -15569,10 +15317,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() @@ -15834,13 +15582,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 { @@ -15854,8 +15603,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 { @@ -15886,13 +15635,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() { @@ -15916,8 +15668,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, }, @@ -16139,7 +15891,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()) @@ -16392,9 +16144,9 @@ pub fn emit_typed_record_lit( }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); if ((((resolved_type.ident_span.clone() != None) - && (rt_name.clone() != tn.clone())) + && (rt_name.clone().as_str() != tn.clone().as_str())) && !rt_is_type_var) - && (rt_name.clone() != "Error".to_string())) + && (rt_name.clone().as_str() != "Error".to_string().as_str())) { Some(rt_name.clone()) } else { @@ -16406,7 +16158,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() @@ -16425,7 +16177,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() { @@ -16465,8 +16218,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, }); @@ -16628,13 +16381,18 @@ pub fn emit_typed_record_lit( &ftm, fname.clone(), ) { - Some(ft) => match rust_zero_value( - ft.clone(), - si.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() @@ -16658,7 +16416,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(), si.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![]), }, @@ -16674,48 +16435,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( @@ -16739,13 +16459,13 @@ pub fn rust_zero_value( type_name: String, source_indices: Rc>>, ) -> Option { - if (type_name.clone() == "Int".to_string()) { + 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 (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::()" @@ -16814,7 +16534,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str, + l_str.clone(), scope.type_env.clone().source_indices.clone(), ), ), @@ -16828,7 +16548,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( "Some(".to_string(), emit_rust_dag_string_to_host_via_seam( - r_str, + r_str.clone(), scope.type_env.clone().source_indices.clone(), ), ), @@ -16861,7 +16581,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( "(".to_string(), emit_rust_dag_string_to_host_via_seam( - l_str, + l_str.clone(), scope .type_env .clone() @@ -16876,7 +16596,7 @@ pub fn emit_typed_bin_op( " ".to_string(), ), emit_rust_dag_string_to_host_via_seam( - r_str, + r_str.clone(), scope.type_env.clone().source_indices.clone(), ), ), @@ -17010,7 +16730,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); } } @@ -17196,7 +16916,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; @@ -17550,7 +17272,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; @@ -17837,8 +17561,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( @@ -17848,10 +17572,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() @@ -17921,7 +17645,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() { @@ -18293,7 +18020,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() { @@ -18318,7 +18045,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() @@ -18386,7 +18113,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()) }, @@ -18451,15 +18178,14 @@ pub fn emit_operation_method( Rc::new(vec![]), shared_types.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()) @@ -18794,7 +18520,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); } } @@ -19124,7 +18850,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()) } } @@ -19135,8 +18861,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); } @@ -19190,8 +18916,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; @@ -19209,8 +18935,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); } @@ -19229,7 +18955,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()) @@ -19247,7 +18973,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 { { @@ -19258,7 +18984,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, } } @@ -19309,7 +19035,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); } @@ -19425,7 +19151,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); } } @@ -19512,8 +19238,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( @@ -19521,7 +19248,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, + source_indices.clone(), ), ), ").ok_or(\"missing field: ".to_string(), @@ -19531,7 +19258,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(), @@ -19540,7 +19267,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(), @@ -19549,7 +19276,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(), @@ -19707,7 +19434,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, }; @@ -19797,15 +19525,15 @@ pub fn emit_response_arm( 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); @@ -19860,7 +19588,7 @@ 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()) } } @@ -19886,8 +19614,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; @@ -19909,7 +19637,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(), 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(), + source_indices.clone(), + ), + ), + ") },".to_string(), + ) }; v1_rt::concat( v1_rt::concat( @@ -19937,12 +19674,12 @@ pub fn emit_exit_arm( { 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( @@ -19955,7 +19692,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(), source_indices.clone())), ") },".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(), + ) } } } @@ -20316,7 +20068,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() @@ -20343,13 +20095,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() @@ -20492,15 +20244,14 @@ pub fn emit_capability_method( Rc::new(vec![]), shared_types.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()) @@ -20598,8 +20349,8 @@ pub fn emit_data_def( shared_types.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(), @@ -20611,10 +20362,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( @@ -20916,35 +20669,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(), + ), ), - scope - .type_env - .clone() - .source_indices - .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(), ) }); } @@ -21079,6 +20835,14 @@ pub fn emit_test_file( pub fn rust_test_signature_comment(projection: Rc) -> String { { + 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: projection.source_indices.clone(), + intern_table: empty_intern_table(), + }); let params_str = Rc::new({ let mut __result = Vec::new(); for p in projection.params.clone().iter().cloned() { @@ -21092,7 +20856,7 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { Rc::new(vec![]), v1_rt::rc_empty_set::(), projection.source_indices.clone(), - v1_rt::rc_empty_map::(), + stub_env.clone(), ), )); } @@ -21145,7 +20909,7 @@ 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() == "".to_string()) { + let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { args_str.clone() @@ -21247,8 +21011,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![ @@ -21348,8 +21112,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); } @@ -21559,7 +21323,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(), @@ -22131,18 +21898,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 { @@ -22213,7 +21973,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( @@ -22248,7 +22008,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 ab745a18038..ec4d51a09a6 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -163,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)] @@ -546,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, @@ -574,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, @@ -750,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); } @@ -881,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) } } @@ -902,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); } @@ -936,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)) { @@ -947,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 { @@ -959,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 { @@ -1003,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 { @@ -1173,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) } } @@ -1190,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())) } @@ -1209,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() { @@ -1341,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() { @@ -1357,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()) @@ -1373,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 @@ -1410,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 @@ -1448,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()) @@ -1498,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 @@ -1571,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 { @@ -1614,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() { @@ -1666,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()); @@ -1681,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()); @@ -1729,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()) { @@ -1857,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 { @@ -2113,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 { { @@ -2122,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); } @@ -2251,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()) } } @@ -2265,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()) } } } @@ -2339,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 { @@ -2747,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 { @@ -3402,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() { @@ -3466,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() { @@ -3539,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(), @@ -4275,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, }, @@ -5279,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; } @@ -5353,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(); @@ -5481,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 { @@ -5817,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); } @@ -5909,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() { @@ -6006,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 { @@ -6062,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() { @@ -6073,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() { @@ -6087,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) => { @@ -6130,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 { @@ -6161,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 = @@ -6282,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); } @@ -6482,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({ @@ -6494,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); } } @@ -6565,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); @@ -6624,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(), @@ -6704,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(), @@ -6847,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())) { { @@ -6992,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, .. } = @@ -7034,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() { @@ -7252,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()) { @@ -7298,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); } } @@ -7442,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( @@ -7486,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( @@ -7504,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( @@ -7646,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); } } @@ -7786,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() { @@ -7833,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(), @@ -7850,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(), @@ -7861,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(), @@ -7873,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(), @@ -7901,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(), @@ -8040,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(), @@ -8049,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); } } @@ -8073,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()); @@ -8086,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)) @@ -8127,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(), @@ -8151,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()), @@ -8188,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(), @@ -8213,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()), @@ -8306,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(), @@ -8423,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(), @@ -8527,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() @@ -8573,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( @@ -8583,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); } } @@ -8887,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() @@ -8953,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; } @@ -9002,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(), @@ -9011,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); } } @@ -9167,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()) @@ -9355,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(), @@ -9767,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 { @@ -9926,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 { @@ -9978,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( @@ -10002,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(), @@ -10039,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)) @@ -10323,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( @@ -10616,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()); @@ -11040,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)] @@ -11058,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() { @@ -11083,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())))) } } @@ -11108,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; } @@ -11167,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())) } } } @@ -11194,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); } @@ -11249,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; } @@ -11271,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( @@ -11748,7 +11826,7 @@ pub fn build_type_env( let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (imp.module_path.clone() == "std.types".to_string()) { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { __found = true; break; } @@ -11756,7 +11834,8 @@ pub fn build_type_env( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = if ((module_name_str.clone() != "std.types".to_string()) + let std_types_parent_env = if ((module_name_str.clone().as_str() + != "std.types".to_string().as_str()) && (imports_std_types == false)) { match v1_rt::map_get(&parent_index, "std.types".to_string()) { @@ -11789,7 +11868,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(), )) @@ -12364,7 +12443,7 @@ pub fn build_type_env_unresolved( let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (imp.module_path.clone() == "std.types".to_string()) { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { __found = true; break; } @@ -12372,15 +12451,17 @@ pub fn build_type_env_unresolved( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = - if ((module_name_str != "std.types".to_string()) && (imports_std_types == false)) { - match v1_rt::map_get(&parent_index, "std.types".to_string()) { - Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let std_types_parent_env = if ((module_name_str.as_str() + != "std.types".to_string().as_str()) + && (imports_std_types == false)) + { + match v1_rt::map_get(&parent_index, "std.types".to_string()) { + Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let imported_parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12404,7 +12485,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(), )) @@ -13318,8 +13399,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)) { @@ -13532,7 +13613,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, }) } diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 80801b55852..e06cb29b877 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -27,7 +27,7 @@ pub fn compute_in_graph_deps( let local = Rc::new({ let mut __result = Vec::new(); for d in deps.clone().iter().cloned() { - if ((d.clone() != name.clone()) + if ((d.clone().as_str() != name.clone().as_str()) && v1_rt::set_contains(&name_set, d.clone())) { __result.push(d); @@ -250,7 +250,7 @@ pub fn detect_type_cycles_kahn( Some(deps) => { let mut __found = false; for d in deps.clone().iter().cloned() { - if (d.clone() == name.clone()) { + if (d.clone().as_str() == name.clone().as_str()) { __found = true; break; } 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 46b10002315..98745ada53b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -453,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 { diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index b71b0e74f5c..34a7f135c98 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -97,8 +97,8 @@ pub fn is_inductive_field( { let mut __found = false; for f in inductive_fields_for(env, type_name).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())) { __found = true; break; diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index f8f68621146..6f94f923962 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -225,10 +225,3 @@ pub fn variant_locals_from_items( }, ) } - -pub struct FnItem; -pub struct FuncItem; -pub struct TypeItem; -pub struct DataItem; -pub struct ServiceItem; -pub struct OtherItem; diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 8ecd32b5f56..72331fe9761 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -57,7 +57,8 @@ pub fn is_type_variable(inferred: Rc) -> bool { } 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)] @@ -91,7 +92,7 @@ pub fn lookup_field_type_node( if is_optional { { let inner = with_required_cardinality(n.clone()); - if (field_name.clone() == "value".to_string()) { + if (field_name.clone().as_str() == "value".to_string().as_str()) { Some(inner) } else { match lookup_field_type_node(inner, field_name.clone(), source_indices.clone()) @@ -115,7 +116,8 @@ pub fn lookup_field_type_node( ) { Some(field_child) => { if (node_is_keyed_collection(n.clone(), source_indices.clone()) - && (field_name.clone() == "lookup".to_string())) + && (field_name.clone().as_str() + == "lookup".to_string().as_str())) { { let value_child = @@ -235,15 +237,16 @@ pub fn resolve_scrutinee_type_node_seen( let canonical = authored_name(env.clone(), normed.clone()); if (normed.inferred.clone() != None) { { - let next_seen = if (canonical.clone() == "".to_string()) { - seen.clone() - } else { - v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) - }; + 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) + }; match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - if ((((authored_name(env.clone(), target.clone()) - == canonical.clone()) + if ((((authored_name(env.clone(), target.clone()).as_str() + == canonical.clone().as_str()) && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) @@ -261,21 +264,23 @@ pub fn resolve_scrutinee_type_node_seen( } } } else { - if ((canonical.clone() != "".to_string()) + if ((canonical.clone().as_str() != "".to_string().as_str()) && emit_map_has(seen.clone(), canonical.clone())) { nominal_type_ref(canonical.clone()) } else { { - let next_seen = if (canonical.clone() == "".to_string()) { - seen.clone() - } else { - v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) - }; + 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) + }; match lookup_type_for(env.clone(), normed.clone()) { Some(resolved) => { if ((((authored_name(env.clone(), resolved.clone()) - == canonical.clone()) + .as_str() + == canonical.clone().as_str()) && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) @@ -376,7 +381,7 @@ pub fn field_summary_for_type( let resolved = resolve_scrutinee_type_node(env.clone(), base_type); let normed = normalize_access_type_node(resolved.clone()); let normed_opt = (normed.return_cardinality.clone() == Cardinality::CardOptional); - if ((field.clone() == "value".to_string()) && normed_opt.clone()) { + if ((field.clone().as_str() == "value".to_string().as_str()) && normed_opt.clone()) { Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::OptionalUnwrap, value_shape: FieldValueShape::PlainValue, @@ -464,7 +469,7 @@ pub fn map_lookup_result_type( field: Rc, source_indices: Rc>>, ) -> Option> { - if (authored_name_at(source_indices.clone(), product) == "Map".to_string()) { + if (authored_name_at(source_indices.clone(), product).as_str() == "Map".to_string().as_str()) { match product_field_result_type(field) { Some(raw) => { if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { @@ -493,14 +498,17 @@ pub fn lookup_field_in_product( let matching = Rc::new({ let mut __result = Vec::new(); for c in product.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()) == method_name.clone()) { + if (authored_name_at(source_indices.clone(), c.clone()).as_str() + == method_name.clone().as_str()) + { __result.push(c); } } __result }); match matching.first().cloned() { - Some(field) => match if (method_name.clone() == "lookup".to_string()) { + Some(field) => match if (method_name.clone().as_str() == "lookup".to_string().as_str()) + { map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) } else { None @@ -575,7 +583,9 @@ pub fn lookup_structural_method( Rc::new({ let mut __result = Vec::new(); for t in templates.iter().cloned() { - if (t.name.clone() == method_name.clone()) { + if (t.name.clone().as_str() + == method_name.clone().as_str()) + { __result.push(t); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 0d601ca6166..2cbb1838368 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -192,6 +192,11 @@ pub fn builtin_function_registry() -> Rc>> { "extdeps_dead_param_count_for_operation".to_string(), int_type(), ); + let m = v1_rt::rc_map_insert( + m.clone(), + "shell_materialize_argv_for_operation".to_string(), + list_of_element(string_type()), + ); let m = v1_rt::rc_map_insert( m.clone(), "extdeps_dead_param_count_for_path".to_string(), @@ -247,6 +252,36 @@ pub fn builtin_function_registry() -> Rc>> { "transport_script_literal_violation_count_for_path".to_string(), int_type(), ); + let m = v1_rt::rc_map_insert( + m.clone(), + "layer_import_facts".to_string(), + list_of_type_variable("layer_import_fact_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "import_resolution_facts".to_string(), + list_of_type_variable("import_resolution_fact_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_coexistence_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_diverged_fork_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_is_coexistence".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_is_diverged_fork".to_string(), + bool_type(), + ); let m = v1_rt::rc_map_insert( m.clone(), "languages_consumer_census_data_decl_count".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 09d2fd66b4b..84910fc453a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -35,7 +35,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)] @@ -355,33 +356,34 @@ pub fn lookup_variant_in_type( } else { { let optional_cardinality_subject = (scrut_opt.clone() - && (authored_name_at(source_indices.clone(), scrut_node.clone()) - != "Optional".to_string())); + && (authored_name_at(source_indices.clone(), scrut_node.clone()).as_str() + != "Optional".to_string().as_str())); let witness_subject = (is_witness_type_name(authored_name_at( source_indices.clone(), scrut_node.clone(), )) && ((scrut_node.children.clone().len() as i64) == 1)); if (optional_cardinality_subject.clone() - && (variant_name.clone() == "Present".to_string())) + && (variant_name.clone().as_str() == "Present".to_string().as_str())) { node_lookup_resolved(synthesize_optional_present_variant( scrut_node.clone(), )) } else { if (optional_cardinality_subject.clone() - && (variant_name.clone() == "Absent".to_string())) + && (variant_name.clone().as_str() == "Absent".to_string().as_str())) { node_lookup_resolved(none_type()) } else { if (witness_subject.clone() - && (variant_name.clone() == "Holds".to_string())) + && (variant_name.clone().as_str() == "Holds".to_string().as_str())) { node_lookup_resolved(synthesize_witness_holds_variant( scrut_node.clone(), )) } else { if (witness_subject.clone() - && (variant_name.clone() == "Violates".to_string())) + && (variant_name.clone().as_str() + == "Violates".to_string().as_str())) { node_lookup_resolved(synthesize_witness_violates_variant( scrut_node.clone(), @@ -392,10 +394,13 @@ pub fn lookup_variant_in_type( source_indices.clone(), scrut_node.clone(), ); - let optional_coproduct_subject = ((scrut_name.clone() - == "Optional".to_string()) - && ((variant_name.clone() == "Present".to_string()) - || (variant_name.clone() == "Absent".to_string()))); + let optional_coproduct_subject = + ((scrut_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 direct_match = find_child_named( scrut_node.clone(), variant_name.clone(), @@ -404,12 +409,14 @@ pub fn lookup_variant_in_type( let record_destructure = (((field_binding_count > 0) && (scrut_node.connective.clone() == Connective::Conj)) - && (scrut_name.clone() == variant_name.clone())); + && (scrut_name.clone().as_str() + == variant_name.clone().as_str())); let fallback = if record_destructure { node_lookup_resolved(scrut_node.clone()) } else { if (optional_coproduct_subject.clone() - && (variant_name.clone() == "Present".to_string())) + && (variant_name.clone().as_str() + == "Present".to_string().as_str())) { node_lookup_resolved( synthesize_optional_present_variant( @@ -418,8 +425,8 @@ pub fn lookup_variant_in_type( ) } else { if (optional_coproduct_subject.clone() - && (variant_name.clone() - == "Absent".to_string())) + && (variant_name.clone().as_str() + == "Absent".to_string().as_str())) { node_lookup_resolved(none_type()) } else { diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 2647173a217..c6f8c18b5e4 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -74,8 +74,8 @@ pub fn unit_variant_in_coproduct( if (acc.clone() != None) { acc.clone() } else { - if ((authored_name_at(env.source_indices.clone(), v.clone()) - == variant_name.clone()) + if ((authored_name_at(env.source_indices.clone(), v.clone()).as_str() + == variant_name.clone().as_str()) && is_unit_variant_node(v.clone())) { Some(v.clone()) @@ -188,8 +188,9 @@ pub fn preserve_nominal_brand_on_resolve( brand_name: String, source_indices: Rc>>, ) -> Rc { - if (((brand_name.clone() != "".to_string()) - && (brand_name.clone() != authored_name_at(source_indices, structural.clone()))) + if (((brand_name.clone().as_str() != "".to_string().as_str()) + && (brand_name.clone().as_str() + != authored_name_at(source_indices, structural.clone()).as_str())) && !is_declared_container_alias_spelling(brand_name.clone())) { with_authored_identity(identity, structural.clone()) @@ -231,9 +232,9 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S .resolved .clone() }; - if (((brand.clone() != "".to_string()) - && (brand.clone() - != authored_name_at(source_indices.clone(), structural.clone()))) + if (((brand.clone().as_str() != "".to_string().as_str()) + && (brand.clone().as_str() + != authored_name_at(source_indices.clone(), structural.clone()).as_str())) && !is_declared_container_alias_spelling(brand.clone())) { with_authored_identity(n.clone(), structural.clone()) @@ -345,8 +346,8 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { decl.clone() } else { if ((((n.children.clone().len() as i64) > 0) - && (n.name.clone() != "".to_string())) - && (n.name.clone() != brand)) + && (n.name.clone().as_str() != "".to_string().as_str())) + && (n.name.clone().as_str() != brand.as_str())) { match lookup_type_by_name(env.clone(), n.name.clone()) { Some(structural) => structural.clone(), @@ -416,8 +417,8 @@ pub fn substitute_type_slots( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.push( - if (authored_name_at(source_indices.clone(), child.clone()) - == decl_name.clone()) + if (authored_name_at(source_indices.clone(), child.clone()).as_str() + == decl_name.clone().as_str()) { { let substituted_args = Rc::new({ @@ -838,14 +839,17 @@ pub fn resolve_node_bounded( let field_rt = resolved_type( field_child.clone(), ); - let is_self_ref = - ((authored_name( - env.clone(), - field_rt.clone(), - ) == authored_name( + let is_self_ref = ((authored_name( + env.clone(), + field_rt.clone(), + ) + .as_str() + == authored_name( env.clone(), n.clone(), - )) && ((field_rt + ) + .as_str()) + && ((field_rt .children .clone() .len() @@ -2011,6 +2015,9 @@ pub fn resolve_expr_types( descent_evidence: de, .. } => { + // bind-once: resolve each arg child a SINGLE time, then split + // into resolved children + diagnostics. Resolving twice made a + // nested constructor literal O(2^depth). let arg_results = Rc::new({ let mut __result = Vec::new(); for arg_node in texpr.children.clone().iter().cloned() { @@ -2040,14 +2047,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.clone().iter().cloned() { + for r in arg_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.clone().iter().cloned() { + for r in arg_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2071,6 +2078,7 @@ pub fn resolve_expr_types( method_semantics: ms, .. } => { + // bind-once: resolve each child a SINGLE time (see ExprCall). let mc_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2136,14 +2144,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.clone().iter().cloned() { + for r in mc_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.clone().iter().cloned() { + for r in mc_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2163,6 +2171,7 @@ pub fn resolve_expr_types( }) } ExprData::ExprMatch => { + // bind-once: resolve each scrutinee/arm a SINGLE time (see ExprCall). let match_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2273,14 +2282,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in match_results.clone().iter().cloned() { + for r in match_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in match_results.clone().iter().cloned() { + for r in match_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2381,6 +2390,9 @@ pub fn resolve_expr_types( ExprData::ExprRecordLit { parent_enum: pe, .. } => { + // bind-once: resolve each field-init value a SINGLE time. This is + // the arm hit by deep nested constructor literals (Cons/record + // chains) — resolving twice per field was O(2^depth). let fi_results = Rc::new({ let mut __result = Vec::new(); for fi_node in texpr.children.clone().iter().cloned() { @@ -2406,14 +2418,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.clone().iter().cloned() { + for r in fi_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.clone().iter().cloned() { + for r in fi_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2547,6 +2559,7 @@ pub fn resolve_expr_types( }) } ExprData::ExprStringInterp => { + // bind-once: resolve each interpolation part a SINGLE time (see ExprCall). let part_results = Rc::new({ let mut __result = Vec::new(); for part_node in texpr.children.clone().iter().cloned() { @@ -2581,14 +2594,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in part_results.clone().iter().cloned() { + for r in part_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in part_results.clone().iter().cloned() { + for r in part_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2804,8 +2817,9 @@ pub fn fn_type_param_names( for p in Rc::new({ let mut __result = Vec::new(); for p in item.params.clone().iter().cloned() { - if (param_node_name_at(p.clone(), source_indices.clone()) - == authored_name_at(source_indices.clone(), param_node_type_expr(p.clone()))) + if (param_node_name_at(p.clone(), source_indices.clone()).as_str() + == authored_name_at(source_indices.clone(), param_node_type_expr(p.clone())) + .as_str()) { __result.push(p); } @@ -2852,7 +2866,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { .iter() .cloned() { - if (other.clone() == s.clone()) { + if (other.clone().as_str() == s.clone().as_str()) { __found = true; break; } @@ -3302,7 +3316,3 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }) }) } - -pub struct AliasParameterized; -pub struct AliasLeaf; -pub struct AliasPassthrough; diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 76923b77bc0..f4617b9f287 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -223,7 +223,7 @@ let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.c Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), }).iter().cloned()); } __result }); -let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: String| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (s.clone() == svc.clone()) { __found = true; break; } } __found } { +let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: String| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (s.clone().as_str() == svc.clone().as_str()) { __found = true; break; } } __found } { svc_list.clone() } else { v1_rt::rc_list_push(svc_list.clone(), svc.clone()) @@ -331,7 +331,7 @@ pub fn check_service_method_call_node( let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.clone().iter().cloned() { - if (op.name.clone() == method.clone()) { + if (op.name.clone().as_str() == method.clone().as_str()) { __result.push(op); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 50aaab3357e..eb42df493d0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -139,7 +139,7 @@ pub fn func_reaches_self( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (e.caller.clone() == current.clone()) { + if (e.caller.clone().as_str() == current.clone().as_str()) { __result.push(e); } } @@ -155,7 +155,7 @@ pub fn func_reaches_self( { let mut __found = false; for c in callees.iter().cloned() { - if if (c.clone() == root.clone()) { + if if (c.clone().as_str() == root.clone().as_str()) { true } else { func_reaches_self( @@ -296,7 +296,7 @@ pub fn topo_resolve_loop( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (e.caller.clone() == fn_name.clone()) { + if (e.caller.clone().as_str() == fn_name.clone().as_str()) { __result.push(e); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index ed5a74b13f6..8f708772956 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -132,7 +132,8 @@ pub fn node_is_set_collection( source_indices: Rc>>, ) -> bool { (node_is_element_collection(n.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), n.clone()) == "Set".to_string())) + && (authored_name_at(source_indices.clone(), n.clone()).as_str() + == "Set".to_string().as_str())) } pub fn canonical_template_name( @@ -159,7 +160,7 @@ pub fn structural_carrier_template_name( n: Rc, source_indices: Rc>>, ) -> String { - if (n.name.clone() != "".to_string()) { + if (n.name.clone().as_str() != "".to_string().as_str()) { canonical_template_name( Rc::new(Node { name: n.name.clone(), @@ -1095,7 +1096,9 @@ pub fn unify_template( } ContainerSource::Named { name: n, .. } => n.clone(), }; - if (authored_name_at(source_indices.clone(), concrete.clone()) != expected_name) { + if (authored_name_at(source_indices.clone(), concrete.clone()).as_str() + != expected_name.as_str()) + { subst.clone() } else { match concrete.children.clone().first().cloned() { @@ -1658,8 +1661,8 @@ pub fn node_type_shape( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (authored_name_at(source_indices.clone(), rt.clone()) - != "None".to_string())) + && (authored_name_at(source_indices.clone(), rt.clone()).as_str() + != "None".to_string().as_str())) && (is_kernel_type(authored_name_at( source_indices.clone(), rt.clone(), @@ -1806,7 +1809,9 @@ pub fn node_type_compatible( node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { if (canonical_template_name(left.clone(), source_indices.clone()) - != canonical_template_name(right.clone(), source_indices.clone())) + .as_str() + != canonical_template_name(right.clone(), source_indices.clone()) + .as_str()) { break false; } else { @@ -1845,16 +1850,18 @@ pub fn node_type_compatible( if (((((canonical_template_name( left.clone(), source_indices.clone(), - ) == canonical_template_name( - right.clone(), - source_indices.clone(), - )) && (authored_name_at( - source_indices.clone(), - left.clone(), - ) != authored_name_at( - source_indices.clone(), - right.clone(), - ))) && ((left.children.clone().len() as i64) == 1)) + ) + .as_str() + == canonical_template_name( + right.clone(), + source_indices.clone(), + ) + .as_str()) + && (authored_name_at(source_indices.clone(), left.clone()) + .as_str() + != authored_name_at(source_indices.clone(), right.clone()) + .as_str())) + && ((left.children.clone().len() as i64) == 1)) && ((right.children.clone().len() as i64) == 1)) && (is_declared_container_alias_spelling(authored_name_at( source_indices.clone(), @@ -1917,10 +1924,13 @@ pub fn node_type_compatible( break (authored_name_at( source_indices.clone(), left.clone(), - ) == authored_name_at( - source_indices.clone(), - right.clone(), - )); + ) + .as_str() + == authored_name_at( + source_indices.clone(), + right.clone(), + ) + .as_str()); } } } @@ -1964,7 +1974,8 @@ pub fn prefer_specific_type( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); let right_is_optional = (right.return_cardinality.clone() == Cardinality::CardOptional); let same_kind = if (left_is_container.clone() && right_is_container) { - (left_norm_name == authored_name_at(source_indices.clone(), right.clone())) + (left_norm_name.as_str() + == authored_name_at(source_indices.clone(), right.clone()).as_str()) } else { if (left_is_optional.clone() && right_is_optional) { true @@ -2065,10 +2076,10 @@ pub fn node_type_equals_core( let left_name = authored_name_at(source_indices.clone(), left.clone()); let right_name = authored_name_at(source_indices.clone(), right.clone()); if (left_leaf.clone() && right_leaf.clone()) { - (left_name == right_name) + (left_name.as_str() == right_name.as_str()) } else { if (left_struct.clone() && right_struct.clone()) { - if (left_name != right_name) { + if (left_name.as_str() != right_name.as_str()) { false } else { if ((left.connective.clone() == Connective::Conj) @@ -2119,10 +2130,10 @@ pub fn node_type_equals_core( } } else { if (left_leaf.clone() && right_struct.clone()) { - (left_name == right_name) + (left_name.as_str() == right_name.as_str()) } else { if (left_struct.clone() && right_leaf.clone()) { - (left_name == right_name) + (left_name.as_str() == right_name.as_str()) } else { { let left_is_container = @@ -2130,7 +2141,7 @@ pub fn node_type_equals_core( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { - if (left_name != right_name) { + if (left_name.as_str() != right_name.as_str()) { false } else { match left.children.clone().first().cloned() { @@ -2327,8 +2338,8 @@ pub fn node_type_deps( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (authored_name_at(source_indices.clone(), rt.clone()) - != "None".to_string())) + && (authored_name_at(source_indices.clone(), rt.clone()).as_str() + != "None".to_string().as_str())) && (is_kernel_type(authored_name_at(source_indices.clone(), rt.clone())) == false)) } @@ -2400,7 +2411,7 @@ pub fn node_type_deps( } } else { if ((is_kernel_type(n_name.clone()) - || (n_name.clone() == "None".to_string())) + || (n_name.clone().as_str() == "None".to_string().as_str())) || (n.ident_span.clone() == None)) { Rc::new(vec![]) @@ -2461,7 +2472,7 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { if is_optional { with_required_cardinality(n.clone()) } else { - if ((n.name.clone() == "Optional".to_string()) + if ((n.name.clone().as_str() == "Optional".to_string().as_str()) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { @@ -2672,7 +2683,8 @@ pub fn for_each_element_type_node( if ((((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) == 0)) && ((normed.properties.clone().len() as i64) == 0)) - && (authored_name_at(source_indices, normed.clone()) == "String".to_string())) + && (authored_name_at(source_indices, normed.clone()).as_str() + == "String".to_string().as_str())) { string_type() } else { diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index 48cc3ac7710..55bfc8d5028 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -1282,7 +1282,7 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Rust => { let mut __found = false; for t in rust_string_types().iter().cloned() { - if (t.clone() == name.clone()) { + if (t.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1292,7 +1292,7 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Go => { let mut __found = false; for t in go_string_types().iter().cloned() { - if (t.clone() == name.clone()) { + if (t.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1302,7 +1302,7 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Python => { let mut __found = false; for t in python_string_types().iter().cloned() { - if (t.clone() == name.clone()) { + if (t.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1345,13 +1345,3 @@ pub fn wrap_shared_type(target: RenderTarget, inner: String) -> String { v1_rt::replace(tmpl, "{0}".to_string(), inner) } } - -pub struct SnakeCaseTestNames; -pub struct PascalCaseTestNames; -pub struct IfExpression; -pub struct ConditionalTernary; -pub struct IfStatement; -pub struct MatchExpression; -pub struct MatchStatementArmReturn; -pub struct PascalCase; -pub struct CamelCase; diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 6f6a1fd17f3..881d0355c8b 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -314,12 +314,14 @@ pub fn walk_expr( } ExprData::ExprCall { .. } => { let fname = expr_call_func_at(texpr.clone(), si.clone()); - if (fname == "fold".to_string()) { + if (fname.as_str() == "fold".to_string().as_str()) { { let init_arg = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()) == "init".to_string()) { + if (authored_name_at(si.clone(), a.clone()).as_str() + == "init".to_string().as_str()) + { __result.push(a); } } @@ -352,7 +354,9 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { + if (authored_name_at(si.clone(), a.clone()).as_str() + != "init".to_string().as_str()) + { __result.push(a); } } @@ -378,13 +382,15 @@ pub fn walk_expr( let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let mname = expr_method_name_at(texpr.clone(), si.clone()); - if (mname == "fold".to_string()) { + if (mname.as_str() == "fold".to_string().as_str()) { { let recv_accum = walk_expr(accum, recv, false, si.clone()); let init_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()) == "init".to_string()) { + if (authored_name_at(si.clone(), a.clone()).as_str() + == "init".to_string().as_str()) + { __result.push(a); } } @@ -417,7 +423,9 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()) != "init".to_string()) { + if (authored_name_at(si.clone(), a.clone()).as_str() + != "init".to_string().as_str()) + { __result.push(a); } } @@ -923,7 +931,9 @@ pub fn summarize_fold_acc_uses( ExprData::ExprVar { binding_kind: _, .. } => { - if (expr_var_name_at(node.clone(), si.clone()) == acc_name.clone()) { + if (expr_var_name_at(node.clone(), si.clone()).as_str() + == acc_name.clone().as_str()) + { if inside_nested.clone() { Rc::new(FoldAccUseSummary { whole_acc_uses: 0, @@ -946,7 +956,10 @@ pub fn summarize_fold_acc_uses( let is_direct = match (*base.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(base.clone(), si.clone()) == acc_name.clone()), + } => { + (expr_var_name_at(base.clone(), si.clone()).as_str() + == acc_name.clone().as_str()) + } _ => false, }; if is_direct { @@ -1072,7 +1085,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal.clone()) == acc_type_name) + (authored_name_at(si, terminal.clone()).as_str() == acc_type_name.as_str()) } _ => false, } @@ -1165,7 +1178,8 @@ pub fn analyze_single_fold( acc_param_name.clone(), si.clone(), ); - let eligible = ((cond_required && (acc_type_name.clone() != "".to_string())) + let eligible = ((cond_required + && (acc_type_name.clone().as_str() != "".to_string().as_str())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { site_key: (method_call.span.clone().start.clone()).to_string(), @@ -1232,8 +1246,3 @@ pub fn analyze_ownership( }) } } - -pub struct Consumed; -pub struct Read; -pub struct Threaded; -pub struct Projected; diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index a58b1c11ef3..e5170bf42d7 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -1146,7 +1146,7 @@ pub fn is_pipe_arrow_shape(shape: TokenShape) -> bool { pub fn tok_is_keyword(tok: Option>, kw: String) -> bool { match tok { - Some(t) => (is_keyword_shape(t.shape.clone()) && (t.text.clone() == kw)), + Some(t) => (is_keyword_shape(t.shape.clone()) && (t.text.clone().as_str() == kw.as_str())), None => false, } } @@ -1173,7 +1173,7 @@ pub fn tok_is_ident(tok: Option>) -> bool { pub fn tok_is_ident_text(tok: Option>, text: String) -> bool { match tok { - Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone() == text)), + Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == text.as_str())), None => false, } } @@ -1198,7 +1198,8 @@ pub fn drop_leading_type_modifier( pub fn drop_leading_test_marker(tokens: Rc>>) -> Rc>> { if (tok_is_ident_text(tokens.clone().first().cloned(), "test".to_string()) - && (tok_keyword_text(tokens.clone().get(1 as usize).cloned()) != "".to_string())) + && (tok_keyword_text(tokens.clone().get(1 as usize).cloned()).as_str() + != "".to_string().as_str())) { Rc::new( tokens @@ -1478,7 +1479,8 @@ pub fn expected_token_name(expected: Rc) -> String { pub fn token_matches_expected(token: Rc, expected: Rc) -> bool { match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => { - (is_keyword_shape(token.shape.clone()) && (token.text.clone() == kw.clone())) + (is_keyword_shape(token.shape.clone()) + && (token.text.clone().as_str() == kw.clone().as_str())) } ExpectedToken::ExpectLBrace => is_lbrace_shape(token.shape.clone()), ExpectedToken::ExpectRBrace => is_rbrace_shape(token.shape.clone()), @@ -1783,8 +1785,8 @@ pub fn parser_helper_state_arg_expr( let arg_node = pair.1.clone(); let matches_state = match arg_name_at(arg_node.clone(), source_indices.clone()) { Some(name) => { - ((name.clone() == "state".to_string()) - || (name.clone() == "tokens".to_string())) + ((name.clone().as_str() == "state".to_string().as_str()) + || (name.clone().as_str() == "tokens".to_string().as_str())) } None => (idx.clone() == 0), }; @@ -1805,8 +1807,8 @@ pub fn parser_progress_flag_var( match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), source_indices.clone()); - if ((field.clone() == "consumed".to_string()) - || (field.clone() == "changed".to_string())) + if ((field.clone().as_str() == "consumed".to_string().as_str()) + || (field.clone().as_str() == "changed".to_string().as_str())) { parser_result_base_var(expr.clone(), source_indices.clone()) } else { @@ -1818,13 +1820,13 @@ pub fn parser_progress_flag_var( } pub fn parser_helper_identity(callee: String) -> Option { - if (callee.clone() == "skip_newlines".to_string()) { + if (callee.clone().as_str() == "skip_newlines".to_string().as_str()) { Some(ParserHelperIdentity::ParserHelperSkipNewlines) } else { - if (callee.clone() == "skip_continuation_newlines".to_string()) { + if (callee.clone().as_str() == "skip_continuation_newlines".to_string().as_str()) { Some(ParserHelperIdentity::ParserHelperSkipContinuationNewlines) } else { - if (callee.clone() == "with".to_string()) { + if (callee.clone().as_str() == "with".to_string().as_str()) { Some(ParserHelperIdentity::ParserHelperWith) } else { None @@ -1889,7 +1891,7 @@ pub fn leaf_type_node(name: String, span: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: span.clone(), - ident_span: if (name.clone() == "".to_string()) { + ident_span: if (name.clone().as_str() == "".to_string().as_str()) { None } else { Some(span.clone()) @@ -2485,7 +2487,7 @@ pub fn find_item_form(forms: Rc>>, keyword: String) -> Option { - let min_val = if (r.arg_name.clone() == "min".to_string()) { + let min_val = if (r.arg_name.clone().as_str() == "min".to_string().as_str()) { Some(r.arg_value.clone()) } else { None }; - let max_val = if (r.arg_name.clone() == "max".to_string()) { + let max_val = if (r.arg_name.clone().as_str() == "max".to_string().as_str()) { Some(r.arg_value.clone()) } else { None @@ -4562,7 +4564,7 @@ pub fn parse_type_expr(tokens: Rc>>, ctx: Rc) -> Rc< }) } Some(TokenShape::ShKeyword) => { - if (tok.clone().unwrap().text.clone() == "fn".to_string()) { + if (tok.clone().unwrap().text.clone().as_str() == "fn".to_string().as_str()) { parse_callable_type_expr( Rc::new( tokens @@ -5171,7 +5173,7 @@ pub fn parse_optional_from_key( }; match sh { Some(TokenShape::ShIdent) => { - if (tok.clone().unwrap().text.clone() == "from".to_string()) { + if (tok.clone().unwrap().text.clone().as_str() == "from".to_string().as_str()) { { let tok2 = tokens.clone().get(1 as usize).cloned(); let sh2 = match tok2.clone() { @@ -5510,7 +5512,7 @@ pub fn parse_func_def(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> R let tokens = skip_newlines(tokens.clone()); let tok = tokens.clone().first().cloned(); let is_uses = match tok { - Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone() == "uses".to_string())), + Some(t) => { + (is_ident_shape(t.shape.clone()) + && (t.text.clone().as_str() == "uses".to_string().as_str())) + } None => false, }; if is_uses { @@ -6350,7 +6355,7 @@ pub fn parse_service_entries( match sh { Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (id.clone() == "config".to_string()) { + if (id.clone().as_str() == "config".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -6408,7 +6413,7 @@ pub fn parse_service_entries( continue; } } else { - if (id.clone() == "transport".to_string()) { + if (id.clone().as_str() == "transport".to_string().as_str()) { let r = parse_transport_binding( Rc::new( tokens @@ -6457,7 +6462,7 @@ pub fn parse_service_entries( } Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text == "operation".to_string()) { + if (kw_text.as_str() == "operation".to_string().as_str()) { let r = parse_operation_def(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ServiceBodyResult { @@ -6669,7 +6674,7 @@ pub fn parse_transport_binding( }; match sh { Some(TokenShape::ShIdent) => { - if (tok_text.clone() == "rest".to_string()) { + if (tok_text.clone().as_str() == "rest".to_string().as_str()) { { let r = expect( Rc::new( @@ -6720,7 +6725,7 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text.clone() == "shell".to_string()) { + if (tok_text.clone().as_str() == "shell".to_string().as_str()) { { let r = expect( Rc::new( @@ -6773,7 +6778,7 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text.clone() == "file".to_string()) { + if (tok_text.clone().as_str() == "file".to_string().as_str()) { { let r = expect( Rc::new( @@ -6945,49 +6950,52 @@ pub fn parse_rest_fields( EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; ctx = r3.ctx.clone(); - if (fname.clone() == transport_url_key()) { + if (fname.clone().as_str() == transport_url_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { - if (fname.clone() == transport_method_key()) { + if (fname.clone().as_str() == transport_method_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { - if (fname.clone() == transport_path_template_key()) { + if (fname.clone().as_str() == transport_path_template_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { - if (fname.clone() == transport_query_key()) { + if (fname.clone().as_str() == transport_query_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { - if (fname.clone() == transport_body_key()) { + if (fname.clone().as_str() == transport_body_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { - if (fname.clone() == transport_response_format_key()) { + if (fname.clone().as_str() + == transport_response_format_key().as_str()) + { { let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { - if (fname.clone() == transport_headers_key()) { + if (fname.clone().as_str() == transport_headers_key().as_str()) + { let h = match (*r3.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { @@ -7066,7 +7074,7 @@ pub fn parse_shell_fields( err: r2.err.clone(), }); } - if (fname.clone() == "argv".to_string()) { + if (fname.clone().as_str() == "argv".to_string().as_str()) { let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectLBracket)); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7111,7 +7119,7 @@ pub fn parse_shell_fields( continue; } } else { - if (fname.clone() == transport_stdin_key()) { + if (fname.clone().as_str() == transport_stdin_key().as_str()) { let r3 = parse_expr(r2.tokens.clone(), ctx.clone()); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7231,7 +7239,9 @@ pub fn parse_file_fields( EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; - if ((fname.clone() == "path".to_string()) || (fname.clone() == transport_path_key())) { + if ((fname.clone().as_str() == "path".to_string().as_str()) + || (fname.clone().as_str() == transport_path_key().as_str())) + { { let __tco_0 = r3.ctx.clone(); let __tco_1 = Some(r3.expr.clone()); @@ -7553,7 +7563,7 @@ pub fn parse_op_body_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text.clone() == "input".to_string()) { + if (kw_text.clone().as_str() == "input".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -7622,7 +7632,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone() == "output".to_string()) { + if (kw_text.clone().as_str() == "output".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -7691,7 +7701,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone() == "idempotent".to_string()) { + if (kw_text.clone().as_str() == "idempotent".to_string().as_str()) { let prop = modifier_to_prop("idempotent".to_string(), span); { let __tco_0 = Rc::new( @@ -7703,7 +7713,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone() == "readonly".to_string()) { + if (kw_text.clone().as_str() == "readonly".to_string().as_str()) { let prop = modifier_to_prop("readonly".to_string(), span); { let __tco_0 = Rc::new( @@ -7719,7 +7729,8 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone() == "hermetic".to_string()) { + if (kw_text.clone().as_str() == "hermetic".to_string().as_str()) + { let prop = modifier_to_prop("hermetic".to_string(), span); { let __tco_0 = Rc::new( @@ -7744,7 +7755,7 @@ pub fn parse_op_body_entries( } Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (id.clone() == "transport".to_string()) { + if (id.clone().as_str() == "transport".to_string().as_str()) { let r = parse_transport_binding( Rc::new( tokens @@ -7780,7 +7791,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone() == "exit".to_string()) { + if (id.clone().as_str() == "exit".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -7850,7 +7861,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone() == "response".to_string()) { + if (id.clone().as_str() == "response".to_string().as_str()) { let r = parse_optional_response_block(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(OpBodyResult { @@ -7876,7 +7887,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone() == "mock_response".to_string()) { + if (id.clone().as_str() == "mock_response".to_string().as_str()) { let r = parse_optional_mock_response_block( tokens.clone(), ctx.clone(), @@ -8330,7 +8341,7 @@ pub fn parse_operation_modifiers_acc( ) -> Rc { loop { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (kw.clone() == "idempotent".to_string()) { + if (kw.clone().as_str() == "idempotent".to_string().as_str()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); let __tco_1 = v1_rt::rc_list_push(acc, OperationModifier::Idempotent); @@ -8339,7 +8350,7 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (kw.clone() == "readonly".to_string()) { + if (kw.clone().as_str() == "readonly".to_string().as_str()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8349,7 +8360,7 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (kw.clone() == "hermetic".to_string()) { + if (kw.clone().as_str() == "hermetic".to_string().as_str()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8407,7 +8418,8 @@ pub fn parse_status_pattern(tokens: Rc>>, ctx: Rc) - let next_tok = tokens.clone().get(1 as usize).cloned(); match next_tok { Some(t) => { - if (is_ident_shape(t.shape.clone()) && (t.text.clone() == "xx".to_string())) + if (is_ident_shape(t.shape.clone()) + && (t.text.clone().as_str() == "xx".to_string().as_str())) { Rc::new(ExprResult { expr: make_expr_node( @@ -8533,7 +8545,8 @@ pub fn parse_optional_response_block( let tok = tokens.clone().first().cloned(); let is_response = match tok { Some(t) => { - (is_ident_shape(t.shape.clone()) && (t.text.clone() == "response".to_string())) + (is_ident_shape(t.shape.clone()) + && (t.text.clone().as_str() == "response".to_string().as_str())) } None => false, }; @@ -8689,7 +8702,8 @@ pub fn parse_optional_mock_response_block( let tok = tokens.clone().first().cloned(); let is_mock = match tok { Some(t) => { - (is_ident_shape(t.shape.clone()) && (t.text.clone() == "mock_response".to_string())) + (is_ident_shape(t.shape.clone()) + && (t.text.clone().as_str() == "mock_response".to_string().as_str())) } None => false, }; @@ -9029,7 +9043,7 @@ pub fn parse_resource_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok_keyword_text(tok.clone()); - if (kw_text.clone() == "capability".to_string()) { + if (kw_text.clone().as_str() == "capability".to_string().as_str()) { let r = parse_capability(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ResPropResult { @@ -9050,7 +9064,7 @@ pub fn parse_resource_entries( continue; } } else { - if (kw_text.clone() == "acquire".to_string()) { + if (kw_text.clone().as_str() == "acquire".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -9089,7 +9103,7 @@ pub fn parse_resource_entries( continue; } } else { - if (kw_text.clone() == "release".to_string()) { + if (kw_text.clone().as_str() == "release".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -9467,7 +9481,7 @@ pub fn parse_io_blocks_acc( }); } else { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (kw.clone() == "input".to_string()) { + if (kw.clone().as_str() == "input".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -9521,7 +9535,7 @@ pub fn parse_io_blocks_acc( continue; } } else { - if (kw.clone() == "output".to_string()) { + if (kw.clone().as_str() == "output".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -10059,10 +10073,10 @@ pub fn parse_stmt(tokens: Rc>>, ctx: Rc) -> Rc { let kw_text = tok_keyword_text(tok.clone()); - if (kw_text.clone() == "let".to_string()) { + if (kw_text.clone().as_str() == "let".to_string().as_str()) { parse_let(tokens.clone(), ctx) } else { - if (kw_text.clone() == "return".to_string()) { + if (kw_text.clone().as_str() == "return".to_string().as_str()) { parse_return(tokens.clone(), ctx) } else { if peek_is_eq_after_ident(tokens.clone()) { @@ -10217,7 +10231,9 @@ pub fn parse_constrained_assignment( pub fn peek_text_is(tokens: Rc>>, expected: String) -> bool { match tokens.first().cloned() { - Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone() == expected)), + Some(t) => { + (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == expected.as_str())) + } None => false, } } @@ -10620,7 +10636,7 @@ pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Optio let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (op.symbol.clone() == symbol.clone()) { + if (op.symbol.clone().as_str() == symbol.clone().as_str()) { __result.push(op); } } @@ -10652,7 +10668,7 @@ pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Op let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (op.symbol.clone() == symbol.clone()) { + if (op.symbol.clone().as_str() == symbol.clone().as_str()) { __result.push(op); } } @@ -10996,22 +11012,26 @@ pub fn parse_primary(tokens: Rc>>, ctx: Rc) -> Rc { - if (kw_text.clone() == "match".to_string()) { + if (kw_text.clone().as_str() == "match".to_string().as_str()) { parse_match(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone() == "if".to_string()) { + if (kw_text.clone().as_str() == "if".to_string().as_str()) { parse_if(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone() == "for".to_string()) { + if (kw_text.clone().as_str() == "for".to_string().as_str()) { parse_for(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone() == "let".to_string()) { + if (kw_text.clone().as_str() == "let".to_string().as_str()) { parse_let(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone() == "return".to_string()) { + if (kw_text.clone().as_str() + == "return".to_string().as_str()) + { parse_return(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone() == "fn".to_string()) { + if (kw_text.clone().as_str() + == "fn".to_string().as_str()) + { parse_fn_lambda(tokens.clone(), ctx.clone()) } else { { @@ -11368,7 +11388,7 @@ pub fn try_postfix( } } Some(TokenShape::ShIdent) => { - if (tok.clone().unwrap().text.clone() == "as".to_string()) { + if (tok.clone().unwrap().text.clone().as_str() == "as".to_string().as_str()) { if (13 < min_bp) { Rc::new(PostfixResult { expr: lhs.clone(), @@ -11542,7 +11562,8 @@ pub fn is_constraint_bracket(tokens: Rc>>) -> bool { match tokens.get(1 as usize).cloned() { Some(t) => { if is_ident_shape(t.shape.clone()) { - ((t.text.clone() == "after".to_string()) || (t.text.clone() == "when".to_string())) + ((t.text.clone().as_str() == "after".to_string().as_str()) + || (t.text.clone().as_str() == "when".to_string().as_str())) } else { false } @@ -11605,8 +11626,8 @@ pub fn parse_constraint_list( let is_constraint_kw = match tok.clone() { Some(t) => { (is_ident_shape(t.shape.clone()) - && ((t.text.clone() == "after".to_string()) - || (t.text.clone() == "when".to_string()))) + && ((t.text.clone().as_str() == "after".to_string().as_str()) + || (t.text.clone().as_str() == "when".to_string().as_str()))) } None => false, }; @@ -12569,7 +12590,7 @@ pub fn looks_like_arm_start(tokens: Rc>>) -> bool { match sh { Some(TokenShape::ShIdent) => { let n = tok.clone().unwrap().text.clone(); - if (n.clone() == "_".to_string()) { + if (n.clone().as_str() == "_".to_string().as_str()) { peek_is_fat_arrow_at(tokens.clone(), 1) } else { if is_uppercase_start(n.clone()) { @@ -12740,7 +12761,7 @@ pub fn parse_pattern(tokens: Rc>>, ctx: Rc) -> Rc { let n = tok.clone().unwrap().text.clone(); - if (n.clone() == "_".to_string()) { + if (n.clone().as_str() == "_".to_string().as_str()) { Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), tokens: Rc::new( @@ -14283,8 +14304,8 @@ pub fn parse_brace_expr(tokens: Rc>>, ctx: Rc) -> Rc match sh { Some(TokenShape::ShKeyword) => { let brace_kw = tok_keyword_text(tok.clone()); - if ((brace_kw.clone() == "let".to_string()) - || (brace_kw.clone() == "return".to_string())) + if ((brace_kw.clone().as_str() == "let".to_string().as_str()) + || (brace_kw.clone().as_str() == "return".to_string().as_str())) { { let r = parse_stmts(tokens.clone(), ctx); @@ -14537,7 +14558,3 @@ pub fn peek_is_colon_after_ident(tokens: Rc>>) -> bool { None => false, } } - -pub struct ParserHelperSkipNewlines; -pub struct ParserHelperSkipContinuationNewlines; -pub struct ParserHelperWith; diff --git a/src/v1/stage0/src/v1_compiler_resolve.rs b/src/v1/stage0/src/v1_compiler_resolve.rs index 54f91424f89..1b987853c7b 100644 --- a/src/v1/stage0/src/v1_compiler_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_resolve.rs @@ -490,7 +490,7 @@ pub fn adjacency_add_edge( } pub fn topo_sort_key(name: String) -> String { - if (name.clone() == "std.types".to_string()) { + if (name.clone().as_str() == "std.types".to_string().as_str()) { "".to_string() } else { name.clone() @@ -512,7 +512,7 @@ pub fn topological_sort( let has_std_types = { let mut __found = false; for name in module_names.clone().iter().cloned() { - if (name.clone() == "std.types".to_string()) { + if (name.clone().as_str() == "std.types".to_string().as_str()) { __found = true; break; } @@ -550,7 +550,8 @@ pub fn topological_sort( let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { if (authored_name_at(source_indices.clone(), imp.clone()) - == "std.types".to_string()) + .as_str() + == "std.types".to_string().as_str()) { __found = true; break; @@ -558,9 +559,11 @@ pub fn topological_sort( } __found }; - if ((((m_name.clone() != "std.types".to_string()) - && (m_name.clone() != "std.algebra".to_string())) - && (m_name.clone() != "std.error_primitives".to_string())) + if ((((m_name.clone().as_str() != "std.types".to_string().as_str()) + && (m_name.clone().as_str() + != "std.algebra".to_string().as_str())) + && (m_name.clone().as_str() + != "std.error_primitives".to_string().as_str())) && (imports_std_types.clone() == false)) { Rc::new(vec![Rc::new(DepEdge { @@ -596,8 +599,8 @@ pub fn topological_sort( let imports_std_types = { let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { - if (authored_name_at(source_indices.clone(), imp.clone()) - == "std.types".to_string()) + if (authored_name_at(source_indices.clone(), imp.clone()).as_str() + == "std.types".to_string().as_str()) { __found = true; break; @@ -606,9 +609,9 @@ pub fn topological_sort( __found }; let implicit_std_types_in_degree = if ((((has_std_types.clone() - && (m_name.clone() != "std.types".to_string())) - && (m_name.clone() != "std.algebra".to_string())) - && (m_name.clone() != "std.error_primitives".to_string())) + && (m_name.clone().as_str() != "std.types".to_string().as_str())) + && (m_name.clone().as_str() != "std.algebra".to_string().as_str())) + && (m_name.clone().as_str() != "std.error_primitives".to_string().as_str())) && (imports_std_types.clone() == false)) { 1 diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 5150b16d4a2..3df8222f6a3 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -38,7 +38,7 @@ pub fn rt_concat_trait() -> String { } pub fn rt_string_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8.\n".to_string()), "pub fn utf8_decode_bytes(bytes: &[u8]) -> Result {\n".to_string()), " String::from_utf8(bytes.to_vec()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))\n".to_string()), "}\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) } pub fn rt_collection_ops() -> String { diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index f1cf4592fed..baa2ce9dd3a 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -4,7 +4,6 @@ use self::Stage0CrateKind::*; use crate::extdeps_cargo::CargoDepSource::{LocalPathDep, RegistryDep}; pub use crate::extdeps_cargo::{CargoDepSource, CargoDependency, CargoFeature}; -pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::v1_compiler_emit_rust::{emit_cargo_dep, emit_non_empty_wrappers}; use crate::v1_rt; use crate::v1_rt::Witness; @@ -166,8 +165,11 @@ pub fn emit_stage0_crate_manifest(spec: Rc) -> Rc { v1_rt::concat( v1_rt::concat( v1_rt::concat( - render_cargo_package_header_prefix(spec.package_name.clone()), - "\nedition = \"2021\"".to_string(), + v1_rt::concat( + "[package]\nname = \"".to_string(), + spec.package_name.clone(), + ), + "\"\nversion = \"0.1.0\"\nedition = \"2021\"".to_string(), ), render_stage0_crate_features_section(spec.features.clone()), ), @@ -399,6 +401,3 @@ pub fn emit_stage0_crate_boundary_files(plan: Rc) -> Rc Rc>> { emit_stage0_crate_boundary_files(stage0_crate_plan()) } - -pub struct CoreCrate; -pub struct EmitCoreCrate; diff --git a/src/v1/stage0/src/v1_compiler_tokenize.rs b/src/v1/stage0/src/v1_compiler_tokenize.rs index b4ebe75de51..3ffce56192f 100644 --- a/src/v1/stage0/src/v1_compiler_tokenize.rs +++ b/src/v1/stage0/src/v1_compiler_tokenize.rs @@ -33,18 +33,18 @@ pub fn single_punct() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("(", TokenShape::ShLParen); - __m.insert(")", TokenShape::ShRParen); - __m.insert("[", TokenShape::ShLBracket); - __m.insert("]", TokenShape::ShRBracket); - __m.insert(":", TokenShape::ShColon); - __m.insert(",", TokenShape::ShComma); - __m.insert(".", TokenShape::ShDot); - __m.insert("+", TokenShape::ShPlus); - __m.insert("*", TokenShape::ShStar); - __m.insert("%", TokenShape::ShPercent); - __m.insert("/", TokenShape::ShSlash); - __m.insert("^", TokenShape::ShCaret); + __m.insert("(".to_string(), TokenShape::ShLParen); + __m.insert(")".to_string(), TokenShape::ShRParen); + __m.insert("[".to_string(), TokenShape::ShLBracket); + __m.insert("]".to_string(), TokenShape::ShRBracket); + __m.insert(":".to_string(), TokenShape::ShColon); + __m.insert(",".to_string(), TokenShape::ShComma); + __m.insert(".".to_string(), TokenShape::ShDot); + __m.insert("+".to_string(), TokenShape::ShPlus); + __m.insert("*".to_string(), TokenShape::ShStar); + __m.insert("%".to_string(), TokenShape::ShPercent); + __m.insert("/".to_string(), TokenShape::ShSlash); + __m.insert("^".to_string(), TokenShape::ShCaret); Rc::new(__m) }; } @@ -735,13 +735,13 @@ pub fn scan_string_body( }); } else { let ch = source_char(source.clone(), pos.clone()); - if (ch.clone() == "\"".to_string()) { + if (ch.clone().as_str() == "\"".to_string().as_str()) { break Rc::new(StringScanResult::ClosedString { content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { - if (ch.clone() == "\\".to_string()) { + if (ch.clone().as_str() == "\\".to_string().as_str()) { if ((pos.clone() + 1) < source_len(source.clone())) { let escaped = source_char(source.clone(), (pos.clone() + 1)); { @@ -762,7 +762,7 @@ pub fn scan_string_body( }); } } else { - if (ch.clone() == "{".to_string()) { + if (ch.clone().as_str() == "{".to_string().as_str()) { if should_start_interpolation(source.clone(), pos.clone()) { break Rc::new(StringScanResult::InterpolationStart { content: acc.join(&"".to_string()), @@ -814,26 +814,26 @@ pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc, filter: Rc) -> Rc Rc::new({ let mut __result = Vec::new(); for e in trace.events.clone().iter().cloned() { - if (event_node_id(e.clone()) == name.clone()) { + if (event_node_id(e.clone()).as_str() == name.clone().as_str()) { __result.push(e); } } diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 8462a365c03..7858d655b57 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -152,6 +152,11 @@ pub fn to_string(value: i64) -> String { value.to_string() } +/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8. +pub fn utf8_decode_bytes(bytes: &[u8]) -> Result { + String::from_utf8(bytes.to_vec()).map_err(|e| format!("invalid UTF-8 in access payload: {e}")) +} + pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 { val.clamp(min_val, max_val) } diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 0b1968427ae..2bdb78c5ee4 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -693,14 +693,12 @@ pub fn is_discovery_corpus_advisory_typecheck_diagnostic(d: Rc) -> bool { - if (is_interpreter_blocking_diagnostic(d.clone()) == false) { + if !is_interpreter_blocking_diagnostic(d.clone()) { + false + } else if is_discovery_corpus_advisory_typecheck_diagnostic(d.clone()) { false } else { - if is_discovery_corpus_advisory_typecheck_diagnostic(d.clone()) { - false - } else { - true - } + true } } @@ -750,7 +748,7 @@ pub struct Node { } pub fn default_ident_span(name: String, span: Rc) -> Option> { - if (name == "".to_string()) { + if (name.as_str() == "".to_string().as_str()) { None } else { Some(span) @@ -1182,7 +1180,7 @@ pub fn authored_name_at( Some(span) => match v1_rt::map_get(&source_indices, span.file.clone()) { Some(index) => { let text = source_text_at(index.clone(), span.clone()); - if (text.clone() == "".to_string()) { + if (text.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { text.clone() @@ -1190,7 +1188,8 @@ pub fn authored_name_at( } None => { if ((v1_rt::string_length(&span.file.clone()) > 8) - && (v1_rt::substring(&span.file.clone(), 0, 8) == " bool { if { let mut __found = false; for r in roles.clone().iter().cloned() { - if (r.accessor.clone() == name.clone()) { + if (r.accessor.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1483,7 +1486,7 @@ pub fn is_child_accessor_in_model(name: String) -> bool { if { let mut __found = false; for r in roles.clone().iter().cloned() { - if (r.accessor.clone() == name.clone()) { + if (r.accessor.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1516,11 +1519,11 @@ pub fn node_field_roles() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("children", NodeFieldRole::ChildrenListField); - __m.insert("params", NodeFieldRole::ChildrenListField); - __m.insert("body", NodeFieldRole::SubValueField); - __m.insert("expr_data", NodeFieldRole::SubValueField); - __m.insert("match_pattern", NodeFieldRole::SubValueField); + __m.insert("children".to_string(), NodeFieldRole::ChildrenListField); + __m.insert("params".to_string(), NodeFieldRole::ChildrenListField); + __m.insert("body".to_string(), NodeFieldRole::SubValueField); + __m.insert("expr_data".to_string(), NodeFieldRole::SubValueField); + __m.insert("match_pattern".to_string(), NodeFieldRole::SubValueField); Rc::new(__m) }; } @@ -1574,15 +1577,15 @@ pub fn function_size_effects() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("with_required_cardinality", Rc::new(FunctionSizeEffect::PropertyContraction { + __m.insert("with_required_cardinality".to_string(), Rc::new(FunctionSizeEffect::PropertyContraction { domain_size: 2, })); - __m.insert("resolved_type", Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("param_node_type_expr", Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("field_binding_pattern", Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("wrapper_inner_arg", Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("extractor_inner_arg", Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("child_type_node", Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("resolved_type".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("param_node_type_expr".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("field_binding_pattern".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("wrapper_inner_arg".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("extractor_inner_arg".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert("child_type_node".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); Rc::new(__m) }; } @@ -1637,7 +1640,7 @@ pub fn arg_name_at( ) -> Option { { let name = authored_name_at(source_indices, n); - if (name.clone() == "".to_string()) { + if (name.clone().as_str() == "".to_string().as_str()) { None } else { Some(name.clone()) @@ -1915,7 +1918,7 @@ pub fn record_lit_type_name_at( ) -> Option { { let name = authored_name_at(source_indices, texpr); - if (name.clone() == "".to_string()) { + if (name.clone().as_str() == "".to_string().as_str()) { None } else { Some(name.clone()) @@ -2231,7 +2234,9 @@ pub fn find_property( match Rc::new({ let mut __result = Vec::new(); for p in props.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) == prop_name.clone()) { + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == prop_name.clone().as_str()) + { __result.push(p); } } @@ -2307,13 +2312,13 @@ pub fn field_init_operation_modifier( ) -> Option { { let fi_name = field_init_node_name_at(field_init, source_indices); - if (fi_name.clone() == "idempotent".to_string()) { + if (fi_name.clone().as_str() == "idempotent".to_string().as_str()) { Some(OperationModifier::Idempotent) } else { - if (fi_name.clone() == "readonly".to_string()) { + if (fi_name.clone().as_str() == "readonly".to_string().as_str()) { Some(OperationModifier::Readonly) } else { - if (fi_name.clone() == "hermetic".to_string()) { + if (fi_name.clone().as_str() == "hermetic".to_string().as_str()) { Some(OperationModifier::Hermetic) } else { None @@ -2425,18 +2430,18 @@ pub fn transport_response_format( } pub fn is_config_reserved_key(name: String) -> bool { - ((((((((((((name.clone() == transport_url_key()) - || (name.clone() == transport_path_key())) - || (name.clone() == transport_auth_scheme_key())) - || (name.clone() == transport_auth_header_key())) - || (name.clone() == transport_auth_token_key())) - || (name.clone() == transport_method_key())) - || (name.clone() == transport_path_template_key())) - || (name.clone() == transport_query_key())) - || (name.clone() == transport_body_key())) - || (name.clone() == transport_stdin_key())) - || (name.clone() == transport_response_format_key())) - || (name.clone() == transport_headers_key())) + ((((((((((((name.clone().as_str() == transport_url_key().as_str()) + || (name.clone().as_str() == transport_path_key().as_str())) + || (name.clone().as_str() == transport_auth_scheme_key().as_str())) + || (name.clone().as_str() == transport_auth_header_key().as_str())) + || (name.clone().as_str() == transport_auth_token_key().as_str())) + || (name.clone().as_str() == transport_method_key().as_str())) + || (name.clone().as_str() == transport_path_template_key().as_str())) + || (name.clone().as_str() == transport_query_key().as_str())) + || (name.clone().as_str() == transport_body_key().as_str())) + || (name.clone().as_str() == transport_stdin_key().as_str())) + || (name.clone().as_str() == transport_response_format_key().as_str())) + || (name.clone().as_str() == transport_headers_key().as_str())) } pub fn transport_headers( @@ -2506,7 +2511,9 @@ pub fn expr_has_self_call( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(texpr.clone(), source_indices.clone()) == fn_name.clone()) { + if (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() + == fn_name.clone().as_str()) + { true } else { { @@ -2548,7 +2555,9 @@ pub fn expr_has_non_tail_self_call( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(texpr.clone(), source_indices.clone()) == fn_name.clone()) { + if (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() + == fn_name.clone().as_str()) + { if (in_tail.clone() == false) { true } else { @@ -2876,8 +2885,8 @@ pub fn has_service_config( { let mut __found = false; for p in n.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()) - == "svc_endpoint".to_string()) + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "svc_endpoint".to_string().as_str()) { __found = true; break; @@ -3539,7 +3548,7 @@ pub fn merge_intern_tables(tables: Rc>>) -> Rc .iter() .cloned() .fold(merged, |m: Rc, s: String| { - if (s.clone() == "".to_string()) { + if (s.clone().as_str() == "".to_string().as_str()) { m.clone() } else { intern(m.clone(), s.clone()).table.clone() @@ -3615,73 +3624,3 @@ pub fn with_required_cardinality(n: Rc) -> Rc { expr_data: n.expr_data.clone(), }) } - -pub struct ShKeyword; -pub struct ShLBrace; -pub struct ShRBrace; -pub struct ShLParen; -pub struct ShRParen; -pub struct ShLBracket; -pub struct ShRBracket; -pub struct ShLt; -pub struct ShGt; -pub struct ShLe; -pub struct ShGe; -pub struct ShFatArrow; -pub struct ShArrow; -pub struct ShColon; -pub struct ShComma; -pub struct ShDot; -pub struct ShDotDot; -pub struct ShEq; -pub struct ShEqEq; -pub struct ShNe; -pub struct ShPlus; -pub struct ShMinus; -pub struct ShStar; -pub struct ShSlash; -pub struct ShPercent; -pub struct ShBang; -pub struct ShAnd; -pub struct ShOr; -pub struct ShQuestion; -pub struct ShNullCoalesce; -pub struct ShCaret; -pub struct ShPipe; -pub struct ShPipeArrow; -pub struct ShLitStr; -pub struct ShLitInt; -pub struct ShLitFloat; -pub struct ShIdent; -pub struct ShStrBegin; -pub struct ShStrMid; -pub struct ShStrEnd; -pub struct ShNewline; -pub struct ShEof; -pub struct ShUnknown; -pub struct Conj; -pub struct Disj; -pub struct NoConnective; -pub struct Arrow; -pub struct Required; -pub struct CardOptional; -pub struct StoredField; -pub struct EnumAccessor; -pub struct OptionalUnwrap; -pub struct TupleFirst; -pub struct TupleSecond; -pub struct PlainValue; -pub struct OptionalValue; -pub struct PlainCallSemantics; -pub struct LookupCallSemantics; -pub struct ParseRecoveryError; -pub struct SemanticExprError; -pub struct InternalExprError; -pub struct Not; -pub struct Neg; -pub struct Idempotent; -pub struct Readonly; -pub struct Hermetic; -pub struct ChildrenListField; -pub struct SubValueField; -pub struct MetadataField; From bf80b1264d085f03c454468236c9cf56c4b9404c Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:21:05 +0000 Subject: [PATCH 07/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/05_emit_rust.dag | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index f6692dccc93..c3936529ce1 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -3137,11 +3137,11 @@ fn struct_unused_param_names(generic_param_names: List, children: List`), several as a tuple // (`PhantomData<(Q, S)>`) so one field "uses" them all. fn rust_phantom_marker_inner(unused: List) -> String { + // Single unused param -> bare `PhantomData`; several -> `PhantomData<(Q, S)>`. + // `join` of a one-element list is that element, so the single case needs no + // Optional peel (avoids a `match` whose `Absent` arm is unreachable here). if unused |> count == 1 { - match unused |> first { - Present { value: u } => u - Absent => "()" - } + unused |> join(separator: ", ") } else { concat("(", unused |> join(separator: ", "), ")") } From 293aaf5a58e7092016461a042030249deae9847f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:48:54 +0000 Subject: [PATCH 08/11] WIP: emit: Measure-alias count peel (E0560) --- src/v1/05_emit_rust.dag | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index c3936529ce1..b9a202406cf 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -4901,11 +4901,26 @@ 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. + 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) - 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 => "" } + // The struct-literal NAME passed to emit_typed_record_lit must be the + // CONCRETE struct (`Measure`), not the authored alias (`Gibibyte` = + // `Rc>`, not brace-constructible). `record_lit_type_name_at` + // gives the alias; `expanded_rt` is the peeled struct decl. Pass its name + // so the literal name, the `Box` field boxing (keyed on the type_name), + // and the `PhantomData` population (E0392) all resolve on the real struct + // — every one of these keys on this name, so they must agree (cursor + // review 31502). Only override for a plain struct-alias literal (peeled + // type is a named product, not an enum variant); variants / non-aliases + // keep their authored name. + let peeled_type_name = + if parent_enum == none && expanded_rt.connective == Conj && expanded_rt.ident_span != none { + let concrete = authored_name_at(source_indices: si, node: expanded_rt) + if concrete != "" && concrete != variant_name { Present { value: concrete } } else { tn } + } else { tn } + let raw = emit_typed_record_lit(type_name: peeled_type_name, 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 rc_name = match parent_enum { Present { value: en } => en Absent => @@ -6284,7 +6299,16 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St Absent => let rt_is_type_var = if resolved_type.inferred != none { is_type_variable(inferred: resolved_type.inferred.value) } else { false } let rt_name = authored_name_at(source_indices: si, node: resolved_type) - if resolved_type.ident_span != none && rt_name != tn && !rt_is_type_var && rt_name != "Error" { + // Only treat `rt_name` as an enum PARENT (prefixing `display_tn` as + // `Enum::Variant`) when `tn` is genuinely a variant of it -- the + // guard the sibling sites already use. Without it, a struct-alias + // literal whose expanded `resolved_type` names a different concrete + // struct than the written name would wrongly emit `Measure::Gibibyte` + // (cursor review 31502). For a plain struct it is not a variant, so + // the fallback yields `parent_enum` and `display_tn` stays the bare + // struct name. + if resolved_type.ident_span != none && rt_name != tn && !rt_is_type_var && rt_name != "Error" + && variant_belongs_to_enum(type_summaries: emit_info.type_summaries, variant_name: tn, enum_name: rt_name) { Present { value: rt_name } } else { parent_enum @@ -6385,10 +6409,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 - // 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. 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 From 15f1b19476a304dc5d50c3dba457dcd4f5e25e13 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 18:56:19 +0000 Subject: [PATCH 09/11] review(#5396): key record-lit name/box/phantom on the peeled concrete struct (cursor 31502) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Construction peel kept naming/boxing/phantom on the AUTHORED alias (tn, e.g. Gibibyte) while feeding the expanded resolved_type — so for a struct alias the phantom field was skipped (E0063) and display could become Measure::Gibibyte. Fix: pass the peeled concrete struct name (from expanded_rt) as emit_typed_record_lit's type_name so the literal name, Box boxing, and PhantomData population all agree on Measure; and guard the effective_parent fallback with variant_belongs_to_enum so a struct is never prefixed as Enum::Variant. .dag-only; seed stays main's. Co-Authored-By: Claude Opus 4.8 --- src/v1/05_emit_rust.dag | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b9a202406cf..80b0fdc5174 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -4915,11 +4915,10 @@ fn emit_rust_expr_record_lit(expr: Node, registry: Map, scope: // review 31502). Only override for a plain struct-alias literal (peeled // type is a named product, not an enum variant); variants / non-aliases // keep their authored name. - let peeled_type_name = - if parent_enum == none && expanded_rt.connective == Conj && expanded_rt.ident_span != none { - let concrete = authored_name_at(source_indices: si, node: expanded_rt) - if concrete != "" && concrete != variant_name { Present { value: concrete } } else { tn } - } else { tn } + let peeled_type_name = if parent_enum == none && expanded_rt.connective == Conj && expanded_rt.ident_span != none { + let concrete = authored_name_at(source_indices: si, node: expanded_rt) + if concrete != "" && concrete != variant_name { Present { value: concrete } } else { tn } + } else { tn } let raw = emit_typed_record_lit(type_name: peeled_type_name, 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 rc_name = match parent_enum { Present { value: en } => en From 36ef6aa576b741519536f7855718b9f572596423 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 19:00:47 +0000 Subject: [PATCH 10/11] WIP: emit: Measure-alias count peel (E0560) --- .../claim/measure_alias_emit_witness_test.dag | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 dsl/test/claim/measure_alias_emit_witness_test.dag diff --git a/dsl/test/claim/measure_alias_emit_witness_test.dag b/dsl/test/claim/measure_alias_emit_witness_test.dag new file mode 100644 index 00000000000..708163ebb87 --- /dev/null +++ b/dsl/test/claim/measure_alias_emit_witness_test.dag @@ -0,0 +1,71 @@ +// Discriminating by-execution witness for the Measure-alias construction peel +// (cursor review 31502 on gunbc#5396). Runs the REAL emit pipeline +// (`compile_sources`) over a probe module via the interpreter, so it executes +// the live `05_emit_rust.dag` logic — NOT a hand-written target string. +// +// The probe defines a single-field struct with an UNUSED generic param `Q` +// (the `Measure` shape) plus a struct alias `Gib`, and constructs through the +// alias. The fix requires the emitter to: name the concrete struct `Probe` +// (not the alias `Gib`, not `Probe::Gib`), and populate the synthetic +// `_phantom` field for the unused `Q` (E0392). This witness fails RED if the +// construction peel regresses. +// +// Run: +// gunbc run --source-root src/v1 --source-root dsl \ +// --entry dsl/test/claim/measure_alias_emit_witness_test.dag \ +// --function measure_alias_emit_witnesses --claim-run + +module test.claim.measure_alias_emit_witness + +import v1.compiler.compile { compile_sources, SourceFile } +import v1.compiler.artifact { Rust } +import v1.std.core { TextFile } +import std.types { Int } + +// Self-contained probe: `Probe` has the Measure shape (`Q` unused -> needs +// a PhantomData carrier), `Gib` is a concrete struct alias, `mk` constructs +// through the alias. +fn probe_source() -> String { + concat( + "module probe\n", + "type Marker { tag: Int }\n", + "type Probe { count: M }\n", + "type Gib = Probe\n", + "fn mk(c: Int) -> Gib { Gib { count: c } }\n" + ) +} + +fn emitted_rust() -> String { + let sources = [SourceFile { path: "probe.dag", content: probe_source() }] + let result = compile_sources(sources: sources, target: Rust) + fold(result.files, init: "", f: (acc, file) => concat(acc, file.content)) +} + +// The alias construction must name the concrete struct `Probe`, never the alias. +fn w_constructs_concrete_struct() -> Bool { + string_contains(s: emitted_rust(), pattern: "Probe {") +} + +// The synthetic phantom field for the unused `Q` must be populated at the +// construction site (E0063 if missing once the struct def carries it). +fn w_populates_phantom_field() -> Bool { + string_contains(s: emitted_rust(), pattern: "_phantom") +} + +// Must NOT construct through the alias name (`Rc>` is not +// brace-constructible -> E0560) ... +fn w_not_alias_constructor() -> Bool { + string_contains(s: emitted_rust(), pattern: "Gib {") == false +} + +// ... and must NOT prefix the struct as an enum variant (`Probe::Gib`). +fn w_not_enum_prefixed() -> Bool { + string_contains(s: emitted_rust(), pattern: "Probe::Gib") == false +} + +test fn measure_alias_emit_witnesses() -> Bool { + w_constructs_concrete_struct() && + w_populates_phantom_field() && + w_not_alias_constructor() && + w_not_enum_prefixed() +} From b13bd4282bf9530b158f1c1fdfa7da6e0e32b944 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 19:02:14 +0000 Subject: [PATCH 11/11] =?UTF-8?q?test:=20drop=20emit=20witness=20=E2=80=94?= =?UTF-8?q?=20interpreter=20lacks=20String.chars=20for=20compile=5Fsources?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The discriminating witness ran the real emit pipeline via the interpreter, but `compile_sources` hits 'not yet implemented: method chars' in the interpreter, so it cannot execute (and would RED the CI floor if enrolled). Removing it; execution-verification of the construction peel rides the integration-branch full build. Keeps the PR .dag-only. Co-Authored-By: Claude Opus 4.8 --- .../claim/measure_alias_emit_witness_test.dag | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 dsl/test/claim/measure_alias_emit_witness_test.dag diff --git a/dsl/test/claim/measure_alias_emit_witness_test.dag b/dsl/test/claim/measure_alias_emit_witness_test.dag deleted file mode 100644 index 708163ebb87..00000000000 --- a/dsl/test/claim/measure_alias_emit_witness_test.dag +++ /dev/null @@ -1,71 +0,0 @@ -// Discriminating by-execution witness for the Measure-alias construction peel -// (cursor review 31502 on gunbc#5396). Runs the REAL emit pipeline -// (`compile_sources`) over a probe module via the interpreter, so it executes -// the live `05_emit_rust.dag` logic — NOT a hand-written target string. -// -// The probe defines a single-field struct with an UNUSED generic param `Q` -// (the `Measure` shape) plus a struct alias `Gib`, and constructs through the -// alias. The fix requires the emitter to: name the concrete struct `Probe` -// (not the alias `Gib`, not `Probe::Gib`), and populate the synthetic -// `_phantom` field for the unused `Q` (E0392). This witness fails RED if the -// construction peel regresses. -// -// Run: -// gunbc run --source-root src/v1 --source-root dsl \ -// --entry dsl/test/claim/measure_alias_emit_witness_test.dag \ -// --function measure_alias_emit_witnesses --claim-run - -module test.claim.measure_alias_emit_witness - -import v1.compiler.compile { compile_sources, SourceFile } -import v1.compiler.artifact { Rust } -import v1.std.core { TextFile } -import std.types { Int } - -// Self-contained probe: `Probe` has the Measure shape (`Q` unused -> needs -// a PhantomData carrier), `Gib` is a concrete struct alias, `mk` constructs -// through the alias. -fn probe_source() -> String { - concat( - "module probe\n", - "type Marker { tag: Int }\n", - "type Probe { count: M }\n", - "type Gib = Probe\n", - "fn mk(c: Int) -> Gib { Gib { count: c } }\n" - ) -} - -fn emitted_rust() -> String { - let sources = [SourceFile { path: "probe.dag", content: probe_source() }] - let result = compile_sources(sources: sources, target: Rust) - fold(result.files, init: "", f: (acc, file) => concat(acc, file.content)) -} - -// The alias construction must name the concrete struct `Probe`, never the alias. -fn w_constructs_concrete_struct() -> Bool { - string_contains(s: emitted_rust(), pattern: "Probe {") -} - -// The synthetic phantom field for the unused `Q` must be populated at the -// construction site (E0063 if missing once the struct def carries it). -fn w_populates_phantom_field() -> Bool { - string_contains(s: emitted_rust(), pattern: "_phantom") -} - -// Must NOT construct through the alias name (`Rc>` is not -// brace-constructible -> E0560) ... -fn w_not_alias_constructor() -> Bool { - string_contains(s: emitted_rust(), pattern: "Gib {") == false -} - -// ... and must NOT prefix the struct as an enum variant (`Probe::Gib`). -fn w_not_enum_prefixed() -> Bool { - string_contains(s: emitted_rust(), pattern: "Probe::Gib") == false -} - -test fn measure_alias_emit_witnesses() -> Bool { - w_constructs_concrete_struct() && - w_populates_phantom_field() && - w_not_alias_constructor() && - w_not_enum_prefixed() -}