diff --git a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag index 3341724f584..54f81da886d 100644 --- a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag +++ b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag @@ -98,15 +98,20 @@ test fn w_host_arithmetic_on_peano_operands_refuses_in_the_bytes() -> Bool { ) } -// THE BOOL ROW ON THE EMITTED PATH: a kernel true at a v2.std.logic.Bool boundary emits the -// structural constructor. (The interpreter realizes Bool natively and never executes this image; -// the emitted bytes are the only place the image exists, so this row is its whole evidence.) -test fn w_kernel_bool_at_structural_bool_boundary_emits_its_constructor() -> Bool { +// THE BOOL ROW ON THE EMITTED PATH, re-pinned under the uniform kernel precedence +// (direct_import_export_precedence_note, kernel installation independent of import cardinality): +// a bare direct import of the kernel spelling `Bool` cannot displace kernel identity, so a kernel +// true at this boundary emits the host keyword. The pre-precedence expectation (structural +// constructor) held only by ancestry occupancy -- a single-import module skipped the kernel +// overlay, so v2.std.logic.Bool won by leak, not by rule. The structural Bool image becomes +// reachable again when namespace Rule-1 dissolves the union leak; until then this row is the +// discriminating red that fires if leak-dependent resolution is reintroduced. +test fn w_kernel_bool_at_structural_bool_spelling_boundary_stays_the_keyword() -> Bool { compile_dag_rust_emit_check( "module test.claim.structural_bool_probe\nimport v2.std.logic { Bool }\nfn probe() -> Bool { true }\nfn probe_false(b: Bool) -> Bool { false }\n", "src/test_claim_structural_bool_probe.rs", - ["Bool::True", "Bool::False"], - ["{\n true\n}", "{\n false\n}"] + ["{\n true\n}", "{\n false\n}"], + ["Bool::True", "Bool::False"] ) } diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index 78d339e6ef0..9f19b082d8b 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -11513,7 +11513,7 @@ fn symbol_index_with_qualified_fill(closure: SymbolIndex, fill: SymbolIndex) -> } } -data direct_import_export_precedence_note: String = "Direct-selected exports beat transitive leaks (2026-07-16, the #6663 x #6686 main-red). The ancestry union folds each direct import's WHOLE flattened cache (its own exports AND everything it inherited), so a later import's transitively-leaked homonym could overlay an earlier import's OWN export that this module's import statement explicitly selects - import v2.std.algebra { Monoid } lost 'Monoid' to dag-root std.algebra riding v2.std.node's ancestry via std.types, and #6663's field-presence wall read the wrong shape at 28 sites. This overlay re-applies, in import order, each direct import's OWN export surface (interface.env.str_bindings - locals only, never its ancestry) restricted to the names the import statement makes visible (specific_names; is_all = the parent's whole local surface, type-variable names filtered per the std.types precedent). Winner semantics: direct-selected vs transitive leak = direct wins (lexical nearest-wins, the containment ruling one hop out - the sanctioned 1c universe is own declarations UNION direct import lists); direct vs direct = unchanged import-order overlay-wins (the ledgered peer-fork ruling, 2026-07-11: later import wins, conflict stays LEDGERED on binding_forks); leak vs leak = unchanged union winner; KERNEL names are never overridden (overlay_skips_kernel_name: kernel_type_set, the container_type_arity names List/Set/Map/Witness, plus Unit/Optional/Present/Absent) - the kernel scope layer stays positionally above imports per the same ruling, because builtin typing (first, skip, string ops) grounds on kernel identities and the v2 substrate models of those concepts (v2.std.collection List=FreeMonoid, Optional; v2.std.text String) are the known dual-representation debt, resolved corpus-wide by kernel-wins today. Full precedence, nearest first: locals > kernel > direct-selected > transitive union. The fork LEDGER is untouched - rows still record every union conflict; this layer only corrects which binding serves lookups. DISSOLVES WHEN namespace Rule-1 lands (containment tree is the naming authority; imports become parse errors) - the union leak itself disappears and this overlay with it. Receipt: direct_import_precedence_over_transitive_leak_test (green arm = selected name resolves the selected module's shape regardless of import order; red control = the field wall still refuses the true shape's missing fields, with that arm's modules placed so the homonym is census-UNAMBIGUOUS by containment (realleaf under the consumer's own parent, leakleaf under a sibling parent) - a census-ambiguous name stands the wall down BY DESIGN (presence_check_census_gate_note), so without that placement the control asserts a diagnostic the gate exists to suppress and silently measures the gate instead of the overlay; ledger arm = the fork row is still recorded)." +data direct_import_export_precedence_note: String = "Direct-selected exports beat transitive leaks (2026-07-16, the #6663 x #6686 main-red). The ancestry union folds each direct import's WHOLE flattened cache (its own exports AND everything it inherited), so a later import's transitively-leaked homonym could overlay an earlier import's OWN export that this module's import statement explicitly selects - import v2.std.algebra { Monoid } lost 'Monoid' to dag-root std.algebra riding v2.std.node's ancestry via std.types, and #6663's field-presence wall read the wrong shape at 28 sites. This overlay re-applies, in import order, each direct import's OWN export surface (interface.env.str_bindings - locals only, never its ancestry) restricted to the names the import statement makes visible (specific_names; is_all = the parent's whole local surface, type-variable names filtered per the std.types precedent). Winner semantics: direct-selected vs transitive leak = direct wins (lexical nearest-wins, the containment ruling one hop out - the sanctioned 1c universe is own declarations UNION direct import lists); direct vs direct = unchanged import-order overlay-wins (the ledgered peer-fork ruling, 2026-07-11: later import wins, conflict stays LEDGERED on binding_forks); leak vs leak = unchanged union winner; KERNEL names are never overridden (overlay_skips_kernel_name: kernel_type_set, the container_type_arity names List/Set/Map/Witness, plus Unit/Optional/Present/Absent) - the kernel scope layer stays positionally above imports per the same ruling, because builtin typing (first, skip, string ops) grounds on kernel identities and the v2 substrate models of those concepts (v2.std.collection List=FreeMonoid, Optional; v2.std.text String) are the known dual-representation debt, resolved corpus-wide by kernel-wins today. KERNEL INSTALLATION IS INDEPENDENT OF IMPORT CARDINALITY (build_ancestry_precedence, 2026-08-31): the kernel overlay applies unconditionally over the import union and both type-env builders consume the one producer - the former shape skipped the overlay when a module had exactly one import, so kernel identity won or lost by ancestry occupancy (a leak-dependent regime: identical imports, different realizations). Full precedence, nearest first: locals > kernel > direct-selected > transitive union. The fork LEDGER is untouched - rows still record every union conflict; this layer only corrects which binding serves lookups. DISSOLVES WHEN namespace Rule-1 lands (containment tree is the naming authority; imports become parse errors) - the union leak itself disappears and this overlay with it. Receipt: direct_import_precedence_over_transitive_leak_test (green arm = selected name resolves the selected module's shape regardless of import order; red control = the field wall still refuses the true shape's missing fields, with that arm's modules placed so the homonym is census-UNAMBIGUOUS by containment (realleaf under the consumer's own parent, leakleaf under a sibling parent) - a census-ambiguous name stands the wall down BY DESIGN (presence_check_census_gate_note), so without that placement the control asserts a diagnostic the gate exists to suppress and silently measures the gate instead of the overlay; ledger arm = the fork row is still recorded)." fn overlay_skips_kernel_name(name: String) -> Bool { is_kernel_type(name: name) @@ -11549,6 +11549,41 @@ fn overlay_direct_import_exports(ancestry_str_bindings: Map ) } +type AncestryPrecedence { + cache: TypeEnvCache + ancestry_str_bindings: Map + conflicts: List +} + +// The kernel binding for Bool carries the coproduct structure its cited declaration has +// (std.types `type Bool = True | False`) -- the scalar synthetic stand-in erased the variants, +// and under the unconditional kernel overlay that erasure deleted the coproduct-payload refusal +// at kernel-Bool formals (discriminating red: test.claim.coproduct_payload_soundness_witness_test +// bcp_foreign_coproduct_where_bool_required_must_refuse). One constructor serves every +// kernel-environment producer, so the fact cannot fork (review 57892). +fn kernel_bool_type_node() -> Node { + let kernel_true_variant = Node { occurrence_identity: OccurrenceSynthetic, name: "True", span: kernel_span(name: "True"), ident_span: Present { value: kernel_span(name: "True") }, children: [], connective: NoConnective, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } + let kernel_false_variant = Node { occurrence_identity: OccurrenceSynthetic, name: "False", span: kernel_span(name: "False"), ident_span: Present { value: kernel_span(name: "False") }, children: [], connective: NoConnective, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } + Node { occurrence_identity: OccurrenceSynthetic, name: "Bool", span: kernel_span(name: "Bool"), ident_span: Present { value: kernel_span(name: "Bool") }, children: [kernel_true_variant, kernel_false_variant], connective: Disj, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } +} + +// THE PRECEDENCE IS PRODUCED ONCE, HERE, AND NOWHERE DOWNSTREAM. Both type-env builders consume +// this producer, so resolved and unresolved construction share one precedence chain: import +// union (fork ledger unchanged) -> kernel overlay UNCONDITIONALLY -> direct-selected overlay +// with kernel names skipped -> locals kept above by the str_bindings-first lookup. The former +// shape special-cased a single import by skipping the kernel overlay entirely, so with exactly +// one import the environment was that import's flattened cache alone -- kernel identity won or +// lost by ancestry occupancy, resolution by accident rather than by the declared precedence. +fn build_ancestry_precedence(resolved_imports: List, parent_index: Map, kernel_cache: TypeEnvCache) -> AncestryPrecedence { + let import_union = union_parent_type_env_caches(resolved_imports: resolved_imports, parent_index: parent_index) + let with_kernel = merge_type_env_cache(base: import_union.cache, overlay: kernel_cache) + AncestryPrecedence { + cache: with_kernel, + ancestry_str_bindings: overlay_direct_import_exports(ancestry_str_bindings: with_kernel.str_bindings, resolved_imports: resolved_imports, parent_index: parent_index), + conflicts: import_union.conflicts + } +} + // THE AUTHORED HALF OF THIS FUNCTION'S VISIBILITY MAPS, KEPT SEPARATE BECAUSE THE UNION DESTROYS IT. // `build_type_env` folds BOTH import arms into one `source_visible_names` map: an is_all import // contributes every name in the imported module's interface AND every name that module itself @@ -11568,7 +11603,7 @@ fn build_type_env(module: ResolvedModule, parent_index: Map let source_indices = fold(map_keys(kernel_type_set), init: source_indices, f: (acc, name) => map_insert(acc, concat(""), build_newline_index(file: concat(""), source: name)) ) - let source_indices = fold(["Optional", "Present", "Absent", "value", "none"], init: source_indices, f: (acc, name) => + let source_indices = fold(["Optional", "Present", "Absent", "value", "none", "True", "False"], init: source_indices, f: (acc, name) => map_insert(acc, concat(""), build_newline_index(file: concat(""), source: name)) ) let intern_table = seed_kernel_intern_table(intern_table: intern_table) @@ -11592,6 +11627,7 @@ fn build_type_env(module: ResolvedModule, parent_index: Map let absent_variant = Node { occurrence_identity: OccurrenceSynthetic, name: "Absent", span: kernel_span(name: "Absent"), ident_span: Present { value: kernel_span(name: "Absent") }, children: [], connective: NoConnective, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } let kernel_optional = Node { occurrence_identity: OccurrenceSynthetic, name: "Optional", span: kernel_span(name: "Optional"), ident_span: Present { value: kernel_span(name: "Optional") }, children: [present_variant, absent_variant], connective: Disj, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } let kernel_bindings = map_insert(kernel_bindings, intern(table: intern_table, s: "Optional").id, TypeBinding { name: "Optional", resolved: kernel_optional, provenance: SubValueUnknown }) + let kernel_bindings = map_insert(kernel_bindings, intern(table: intern_table, s: "Bool").id, TypeBinding { name: "Bool", resolved: kernel_bool_type_node(), provenance: SubValueUnknown }) let node_fields = inductive_fields_list_to_map(fields: compiler_inductive_fields) let kernel_recursive_types = map_keys(compiler_recursive_types) |> map(name => intern(table: intern_table, s: name).id) @@ -11662,14 +11698,9 @@ fn build_type_env(module: ResolvedModule, parent_index: Map source_indices: source_indices, cycle_set_str: compiler_recursive_name_set() ) - let import_union = union_parent_type_env_caches(resolved_imports: module.resolved_imports, parent_index: parent_index) - let import_cache = import_union.cache - let binding_forks = import_union.conflicts - let ancestry_cache = if module.resolved_imports |> count == 1 { - import_cache - } else { - merge_type_env_cache(base: import_cache, overlay: kernel_cache) - } + let ancestry_precedence = build_ancestry_precedence(resolved_imports: module.resolved_imports, parent_index: parent_index, kernel_cache: kernel_cache) + let ancestry_cache = ancestry_precedence.cache + let binding_forks = ancestry_precedence.conflicts let local_deps_map = fold(all_local_bindings |> map_values, init: empty_map(), f: (acc, b) => map_insert(acc, b.name, deps_excluding_leaf_self(b: b, source_indices: source_indices)) @@ -11694,11 +11725,7 @@ fn build_type_env(module: ResolvedModule, parent_index: Map Absent => empty_map() } let merged_inductive_fields = merge_inductive_fields(left: parent_inductive_fields, right: local_inductive_fields) - let ancestry_str_bindings = overlay_direct_import_exports( - ancestry_str_bindings: ancestry_cache.str_bindings, - resolved_imports: module.resolved_imports, - parent_index: parent_index - ) + let ancestry_str_bindings = ancestry_precedence.ancestry_str_bindings let svn_local = fold(map_keys(local_str_bindings), init: empty_map(), f: (acc, n) => map_insert(acc, n, true)) let svn_kernel = fold(map_keys(kernel_type_set), init: svn_local, f: (acc, n) => map_insert(acc, n, true)) let source_visible_names = fold(module.resolved_imports, init: svn_kernel, f: (acc, imp) => @@ -11768,6 +11795,7 @@ fn build_type_env_unresolved(module: ResolvedModule, parent_index: Map count == 1 { - import_cache - } else { - merge_type_env_cache(base: import_cache, overlay: kernel_cache) - } + let ancestry_precedence = build_ancestry_precedence(resolved_imports: module.resolved_imports, parent_index: parent_index, kernel_cache: kernel_cache) + let ancestry_cache = ancestry_precedence.cache let local_deps_map = fold(local_bindings |> map_values, init: empty_map(), f: (acc, b) => map_insert(acc, b.name, deps_excluding_leaf_self(b: b, source_indices: source_indices)) @@ -11836,7 +11860,7 @@ fn build_type_env_unresolved(module: ResolvedModule, parent_index: Map empty_map() } let merged_inductive_fields = merge_inductive_fields(left: parent_inductive_fields, right: local_inductive_fields) - let ancestry_str_bindings = ancestry_cache.str_bindings + let ancestry_str_bindings = ancestry_precedence.ancestry_str_bindings let visible_str_bindings = map_merge(ancestry_str_bindings, local_str_bindings) let module_variant_index = build_unit_variant_index(str_bindings: local_str_bindings, parents: scope_parents, source_indices: source_indices) let unresolved_env = TypeEnv { module_path: module_name_str, bindings: local_bindings, str_bindings: local_str_bindings, ancestry_str_bindings: ancestry_str_bindings, parents: scope_parents, recursive_types: cycle_set, recursive_type_set: cross_type_set, inductive_fields: merged_inductive_fields, source_indices: source_indices, intern_table: intern_table, source_visible_names: empty_map(), authored_import_names: empty_map(), symbol_index: empty_symbol_index(), unit_variant_index: module_variant_index } @@ -12724,7 +12748,7 @@ fn build_emit_graph_info(modules: List) -> EmitGraphInfo { fn seed_kernel_intern_table(intern_table: InternTable) -> InternTable { let intern_table = fold(map_keys(kernel_type_set), init: intern_table, f: (t, name) => intern(table: t, s: name).table) - let intern_table = fold(["Optional", "Present", "Absent", "value", "none"], init: intern_table, f: (t, name) => intern(table: t, s: name).table) + let intern_table = fold(["Optional", "Present", "Absent", "value", "none", "True", "False"], init: intern_table, f: (t, name) => intern(table: t, s: name).table) fold(map_keys(compiler_recursive_types), init: intern_table, f: (t, name) => intern(table: t, s: name).table) } @@ -13099,6 +13123,7 @@ fn compiler_kernel_type_env(source_indices: Map, intern_ta let absent_variant = Node { occurrence_identity: OccurrenceSynthetic, name: "Absent", span: kernel_span(name: "Absent"), ident_span: Present { value: kernel_span(name: "Absent") }, children: [], connective: NoConnective, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } let kernel_optional = Node { occurrence_identity: OccurrenceSynthetic, name: "Optional", span: kernel_span(name: "Optional"), ident_span: Present { value: kernel_span(name: "Optional") }, children: [present_variant, absent_variant], connective: Disj, params: [], inferred: none, return_cardinality: Required, uses: [], body: none, transport: none, properties: [], type_annotation: none, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: none, expr_data: NoExprData } let kernel_bindings = map_insert(kernel_bindings, intern(table: intern_table, s: "Optional").id, TypeBinding { name: "Optional", resolved: kernel_optional, provenance: SubValueUnknown }) + let kernel_bindings = map_insert(kernel_bindings, intern(table: intern_table, s: "Bool").id, TypeBinding { name: "Bool", resolved: kernel_bool_type_node(), provenance: SubValueUnknown }) let node_fields = inductive_fields_list_to_map(fields: compiler_inductive_fields) let kernel_recursive_types = map_keys(compiler_recursive_types) |> map(name => intern(table: intern_table, s: name).id) let kernel_recursive_type_set = fold(map_keys(compiler_recursive_types), init: empty_map(), f: (acc, name) => map_insert(acc, intern(table: intern_table, s: name).id, true)) diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index c31b9a4e80b..f2438d5d531 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -116,12 +116,9 @@ pub fn rust_method_wraps_result() -> Rc> { }) .iter() .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, spec: _| { - v1_rt::rc_map_insert(acc, spec.method_name.clone(), true) - }, - ) + .fold(v1_rt::rc_empty_map::(), |acc: _, spec: _| { + v1_rt::rc_map_insert(acc, spec.method_name.clone(), true) + }) } pub fn rust_reserved() -> Rc> { @@ -532,12 +529,12 @@ pub fn rt_function_registry() -> Rc>> { } pub fn rt_functions() -> Rc> { - rt_function_registry().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, entry: Rc| { + rt_function_registry() + .iter() + .cloned() + .fold(v1_rt::rc_empty_map::(), |acc: _, entry: _| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) - }, - ) + }) } pub fn rt_ref_map_functions() -> Rc> { @@ -552,12 +549,9 @@ pub fn rt_ref_map_functions() -> Rc> { }) .iter() .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, entry: Rc| { - v1_rt::rc_map_insert(acc, entry.name.clone(), true) - }, - ) + .fold(v1_rt::rc_empty_map::(), |acc: _, entry: _| { + v1_rt::rc_map_insert(acc, entry.name.clone(), true) + }) } pub fn rt_wraps_result() -> Rc> { @@ -572,12 +566,9 @@ pub fn rt_wraps_result() -> Rc> { }) .iter() .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, entry: Rc| { - v1_rt::rc_map_insert(acc, entry.name.clone(), true) - }, - ) + .fold(v1_rt::rc_empty_map::(), |acc: _, entry: _| { + v1_rt::rc_map_insert(acc, entry.name.clone(), true) + }) } pub fn rt_bridge_function_names() -> Rc> { @@ -594,7 +585,7 @@ pub fn rt_bridge_function_names() -> Rc> { .cloned() .fold( v1_rt::rc_empty_map::(), - |acc: Rc>, entry: Rc| { + |acc: Rc>, entry: _| { v1_rt::rc_map_insert(acc, entry.name.clone(), entry.bridge_name.clone()) }, ) diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index fb589759e2e..b2c58049e77 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -766,10 +766,10 @@ pub fn carrier_container_alias_rows() -> Rc> { pub fn carrier_container_roster_map() -> Rc> { algebra_carriers().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, carrier: Rc| { + |acc: _, carrier: Rc| { carrier.spellings.clone().iter().cloned().fold( acc, - |inner: Rc>, spelling: Rc| { + |inner: _, spelling: Rc| { if carrier_spelling_row_present(spelling.container_roster_name.clone()) { v1_rt::rc_map_insert(inner.clone(), spelling.text.clone(), true) } else { @@ -838,10 +838,10 @@ pub fn algebra_profile_equality_extensional(profile: AlgebraProfile) -> bool { pub fn carrier_container_equality_rows() -> Rc> { algebra_carriers().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, carrier: Rc| { + |acc: _, carrier: Rc| { carrier.spellings.clone().iter().cloned().fold( acc, - |inner: Rc>, spelling: Rc| { + |inner: _, spelling: Rc| { if carrier_spelling_row_present(spelling.container_algebra_row.clone()) { v1_rt::rc_map_insert( inner.clone(), diff --git a/src/v1/stage0/src/std_logic.rs b/src/v1/stage0/src/std_logic.rs index bb425ac1571..6884033445a 100644 --- a/src/v1/stage0/src/std_logic.rs +++ b/src/v1/stage0/src/std_logic.rs @@ -38,8 +38,3 @@ pub fn classical_or(a: Classical, b: Classical) -> Classical { Classical::False => b, } } - -#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct True; -#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct False; diff --git a/src/v1/stage0/src/std_occurrence_binding_candidates.rs b/src/v1/stage0/src/std_occurrence_binding_candidates.rs index ddbfd5161b9..de26af82019 100644 --- a/src/v1/stage0/src/std_occurrence_binding_candidates.rs +++ b/src/v1/stage0/src/std_occurrence_binding_candidates.rs @@ -3358,23 +3358,26 @@ pub fn section13_observation_joins_receipt( observations: Rc>>, required_head: String, ) -> Option { - observations.iter().cloned().fold( - std::option::Option::None, - |found: _, observation: Rc| match found.clone() { - Some(_) => found.clone(), - std::option::Option::None => { - if (crate::std_decl_ref::declaration_ref_eq( - observation.declaration.clone(), - receipt.clone(), - ) && (observation.head.clone() == required_head.clone())) - { - Some(observation.passed.clone()) - } else { - std::option::Option::None + observations + .iter() + .cloned() + .fold( + std::option::Option::None, + |found: _, observation: _| match found.clone() { + Some(_) => found.clone(), + std::option::Option::None => { + if (crate::std_decl_ref::declaration_ref_eq( + observation.declaration.clone(), + receipt.clone(), + ) && (observation.head.clone() == required_head.clone())) + { + Some(observation.passed.clone()) + } else { + std::option::Option::None + } } - } - }, - ) + }, + ) } pub fn section13_adjudicate_row( diff --git a/src/v1/stage0/src/std_occurrence_identity.rs b/src/v1/stage0/src/std_occurrence_identity.rs index f74e96b5526..b8fa01bbd6f 100644 --- a/src/v1/stage0/src/std_occurrence_identity.rs +++ b/src/v1/stage0/src/std_occurrence_identity.rs @@ -477,7 +477,7 @@ pub fn occurrence_id_list_is_prefix_of( prefix.iter().cloned().fold(Rc::new(OccurrenceIdListPrefixAcc { path_remaining: path.clone(), ok: true, -}), |acc: Rc, expected: OccurrenceId| if !acc.ok.clone() { +}), |acc: _, expected: OccurrenceId| if !acc.ok.clone() { acc.clone() } else { if ((acc.path_remaining.clone().len() as i64) == 0) { diff --git a/src/v1/stage0/src/std_pareto.rs b/src/v1/stage0/src/std_pareto.rs index 89ca4ac33bb..e5e8cc14d00 100644 --- a/src/v1/stage0/src/std_pareto.rs +++ b/src/v1/stage0/src/std_pareto.rs @@ -122,7 +122,7 @@ pub fn dominance_of_comparisons(comparisons: Rc>) -> Dominan saw_better: false, saw_worse: false, }, - |acc: DominanceTally, c: AxisComparison| tally_step(acc, c.clone()), + |acc: _, c: AxisComparison| tally_step(acc, c.clone()), )) } @@ -478,9 +478,7 @@ pub fn compare_pair( a_worse_somewhere: false, winning_axes: no_axis_ids(), }), - |acc: Rc, axis: Rc| { - axis_pair_step(acc, axis.clone(), a.clone(), b.clone()) - }, + |acc: _, axis: Rc| axis_pair_step(acc, axis.clone(), a.clone(), b.clone()), )) } diff --git a/src/v1/stage0/src/std_source_annotation.rs b/src/v1/stage0/src/std_source_annotation.rs index 45efbc48f1c..54977710955 100644 --- a/src/v1/stage0/src/std_source_annotation.rs +++ b/src/v1/stage0/src/std_source_annotation.rs @@ -178,7 +178,7 @@ pub fn advance_line_prefix_indent_only(previous: bool, code_points: Rc> code_points .iter() .cloned() - .fold(previous.clone(), |acc: bool, cp: i64| { + .fold(previous.clone(), |acc: _, cp: i64| { if code_point_is_line_feed(cp.clone()) { true } else { @@ -265,10 +265,12 @@ pub fn module_root_pick_step( pub fn module_root_subject( subjects: Rc>>, ) -> Option> { - subjects.iter().cloned().fold( - std::option::Option::None, - |acc: _, row: Rc| module_root_pick_step(acc.clone(), row.clone()), - ) + subjects + .iter() + .cloned() + .fold(std::option::Option::None, |acc: _, row: _| { + module_root_pick_step(acc.clone(), row.clone()) + }) } pub fn earliest_member_start_after( @@ -279,7 +281,7 @@ pub fn earliest_member_start_after( subjects .iter() .cloned() - .fold(fallback.clone(), |best: i64, row: Rc| { + .fold(fallback.clone(), |best: i64, row: _| { if ((row.span.clone().start.clone() > after.clone()) && (row.span.clone().start.clone() < best.clone())) { @@ -340,7 +342,7 @@ pub fn annotation_subject_pick( contained: false, following: std::option::Option::None, }), - |acc: Rc, subject: Rc| { + |acc: _, subject: _| { if ((origin.start.clone() >= subject.span.clone().start.clone()) && (origin.end.clone() <= subject.span.clone().end.clone())) { @@ -399,12 +401,7 @@ pub fn keyed_annotation_rows_agree( rest: right.clone(), agreed: true, }), - |acc: Rc, row: Rc| match acc - .rest - .clone() - .first() - .cloned() - { + |acc: _, row: Rc| match acc.rest.clone().first().cloned() { std::option::Option::None => Rc::new(KeyedAnnotationRowWalk { rest: Rc::new(vec![]), agreed: false, @@ -600,9 +597,7 @@ pub fn attach_annotations( pending: std::option::Option::None, pending_adjacent: false, }), - |acc: Rc, capture: Rc| { - annotation_attach_step(acc, capture.clone(), subjects.clone()) - }, + |acc: _, capture: _| annotation_attach_step(acc, capture.clone(), subjects.clone()), ); Rc::new(AnnotationAttachmentResult { graph: Rc::new(SourceAnnotationGraph { diff --git a/src/v1/stage0/src/v1_compiler_annotation_bind.rs b/src/v1/stage0/src/v1_compiler_annotation_bind.rs index 5928359b6bf..758d7364713 100644 --- a/src/v1/stage0/src/v1_compiler_annotation_bind.rs +++ b/src/v1/stage0/src/v1_compiler_annotation_bind.rs @@ -111,7 +111,7 @@ pub fn annotation_subjects( let items = module_item_entries(transport.clone()); entries.clone().iter().cloned().fold( Rc::new(vec![]), - |acc: Rc>>, entry: Rc| { + |acc: _, entry: Rc| { let depth = entry_ancestor_depth(entry.clone()); let span = entry.projection.clone().diagnostic_span.clone(); if (depth.clone() == 0) { @@ -356,13 +356,12 @@ pub fn bind_annotations( source_length: i64, ) -> Rc { crate::std_source_annotation::attach_annotations( - captures.iter().cloned().fold( - Rc::new(vec![]), - |acc: Rc>>, - capture: Rc| { + captures + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: _, capture: _| { v1_rt::rc_list_push(acc, normalize_dag_annotation(capture.clone())) - }, - ), + }), annotation_subjects(transport.clone(), source_length.clone()), ) } diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index c79d8cb7aee..1463acb1876 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -623,9 +623,9 @@ pub fn copy_tests() -> Rc>> { pub fn unique_inhabitants_for_template_tests( inhs: Rc>>, ) -> Rc>> { - inhs.iter().cloned().fold( - Rc::new(vec![]), - |acc: Rc>>, inh: Rc| { + inhs.iter() + .cloned() + .fold(Rc::new(vec![]), |acc: _, inh: _| { if { let mut __found = false; for prev in acc.iter().cloned() { @@ -642,8 +642,7 @@ pub fn unique_inhabitants_for_template_tests( } else { v1_rt::concat(acc.clone(), Rc::new(vec![inh.clone()])) } - }, - ) + }) } pub fn template_application_tests() -> Rc>> { diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 80ee6336f92..0b5cc24b8c1 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -646,7 +646,7 @@ pub fn build_dag_key_to_id(order: Rc>>) -> Rc) -> Rc>> { typed.modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { + |acc: Rc>>, m: _| { v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) }, ) @@ -2498,9 +2498,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc }); let intern_table = prepared.iter().cloned().fold( crate::v1_std_core::empty_intern_table(), - |t: Rc, p: Rc| { - crate::v1_std_core::pre_intern_tokens(p.tokens.clone(), t) - }, + |t: Rc, p: _| crate::v1_std_core::pre_intern_tokens(p.tokens.clone(), t), ); let parsed = prepared.iter().cloned().fold( Rc::new(FrontendAccum { @@ -2513,7 +2511,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc annotations: crate::std_source_annotation::source_annotation_graph_empty(), annotation_diagnostics: Rc::new(vec![]), }), - |acc: Rc, p: Rc| { + |acc: Rc, p: _| { let parsed = crate::v1_compiler_parse::parse_with_table_in_occurrence_scope( p.tokens.clone(), v1_rt::rc_map_insert( @@ -2641,9 +2639,7 @@ pub fn parse_census_fill_sources(sources: Rc>>) -> Rc, p: Rc| { - crate::v1_std_core::pre_intern_tokens(p.tokens.clone(), t) - }, + |t: Rc, p: _| crate::v1_std_core::pre_intern_tokens(p.tokens.clone(), t), ); let parsed = prepared.iter().cloned().fold( Rc::new(FrontendAccum { @@ -2656,7 +2652,7 @@ pub fn parse_census_fill_sources(sources: Rc>>) -> Rc, p: Rc| { + |acc: Rc, p: _| { let parsed = crate::v1_compiler_parse::parse_with_table_in_occurrence_scope( p.tokens.clone(), v1_rt::rc_map_insert( diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index d09893e0900..e993ca256ef 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -3319,12 +3319,12 @@ pub fn collect_field_binding_names( MatchPattern::VariantPattern { field_bindings: nested, .. - } => nested.iter().cloned().fold( - vars.clone(), - |inner: Rc>, nested_fb: Rc| { + } => nested + .iter() + .cloned() + .fold(vars.clone(), |inner: _, nested_fb: Rc| { collect_field_binding_names(nested_fb.clone(), inner) - }, - ), + }), _ => vars.clone(), } }) @@ -3405,7 +3405,7 @@ pub fn is_match_option_descent( } => { let binding_names = bindings.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, fb: Rc| { + |acc: _, fb: Rc| { collect_field_binding_names(fb.clone(), acc) }, ); @@ -3701,57 +3701,51 @@ pub fn collect_descent_vars( crate::v1_std_core::match_arm_nodes(body.clone()) .iter() .cloned() - .fold( - vars.clone(), - |acc: Rc>, arm_node: Rc| { - match (*crate::v1_std_core::arm_pattern(arm_node.clone())).clone() { - MatchPattern::VariantPattern { - field_bindings: bindings, - .. - } => bindings.iter().cloned().fold( - acc.clone(), - |inner: Rc>, fb: Rc| { - collect_field_binding_names(fb.clone(), inner) - }, - ), - MatchPattern::Bind { - declaration: declaration, - .. - } => { - if scrut_is_descent.clone() { - v1_rt::rc_map_insert( - acc.clone(), - declaration.name.clone(), - true, - ) - } else { - acc.clone() - } + .fold(vars.clone(), |acc: _, arm_node: Rc| { + match (*crate::v1_std_core::arm_pattern(arm_node.clone())).clone() { + MatchPattern::VariantPattern { + field_bindings: bindings, + .. + } => bindings.iter().cloned().fold( + acc.clone(), + |inner: _, fb: Rc| { + collect_field_binding_names(fb.clone(), inner) + }, + ), + MatchPattern::Bind { + declaration: declaration, + .. + } => { + if scrut_is_descent.clone() { + v1_rt::rc_map_insert( + acc.clone(), + declaration.name.clone(), + true, + ) + } else { + acc.clone() } - _ => acc.clone(), } - }, - ) + _ => acc.clone(), + } + }) } else { vars.clone() }; crate::v1_std_core::match_arm_nodes(body.clone()) .iter() .cloned() - .fold( - with_patterns.clone(), - |acc: Rc>, arm_node: Rc| { - let arm_result = collect_descent_vars( - crate::v1_std_core::arm_body(arm_node.clone()), - param_name.clone(), - with_patterns.clone(), - check_child.clone(), - check_list.clone(), - si.clone(), - ); - v1_rt::rc_map_merge(acc, arm_result.clone()) - }, - ) + .fold(with_patterns.clone(), |acc: _, arm_node: Rc| { + let arm_result = collect_descent_vars( + crate::v1_std_core::arm_body(arm_node.clone()), + param_name.clone(), + with_patterns.clone(), + check_child.clone(), + check_list.clone(), + si.clone(), + ); + v1_rt::rc_map_merge(acc, arm_result.clone()) + }) } ExprData::ExprIf => { let then_vars = collect_descent_vars( @@ -3777,7 +3771,7 @@ pub fn collect_descent_vars( } ExprData::ExprBlock => body.children.clone().iter().cloned().fold( vars.clone(), - |acc: Rc>, stmt: Rc| { + |acc: _, stmt: Rc| { collect_descent_vars( stmt.clone(), param_name.clone(), @@ -3962,7 +3956,7 @@ pub fn all_self_calls_descend_inc( .. } => bindings.iter().cloned().fold( vars.clone(), - |inner: Rc>, fb: Rc| { + |inner: _, fb: Rc| { collect_field_binding_names(fb.clone(), inner) }, ), @@ -4042,7 +4036,7 @@ pub fn all_self_calls_descend_inc( ok: true, vars: vars.clone(), }), - |acc: Rc, stmt: Rc| { + |acc: _, stmt: Rc| { if (acc.ok.clone() == false) { acc.clone() } else { @@ -4891,7 +4885,7 @@ pub fn collect_evidence_incremental( .. } => bindings.iter().cloned().fold( vars.clone(), - |inner: Rc>, fb: Rc| { + |inner: _, fb: Rc| { collect_field_binding_names(fb.clone(), inner) }, ), @@ -5045,7 +5039,7 @@ pub fn collect_evidence_incremental( evidence: std::option::Option::None, vars: vars.clone(), }), - |acc: Rc, stmt: Rc| { + |acc: _, stmt: Rc| { let stmt_ev = collect_evidence_incremental( stmt.clone(), func_name.clone(), @@ -6694,7 +6688,7 @@ pub fn collect_scc_child_edges( edges: Rc::new(vec![]), vars: descent_vars.clone(), }), - |acc: Rc, stmt: Rc| { + |acc: _, stmt: Rc| { let stmt_edges = collect_scc_child_edges( stmt.clone(), caller.clone(), @@ -9092,10 +9086,7 @@ pub fn deduplicate(items: Rc>) -> Rc> { seen: v1_rt::rc_empty_map::(), out: Rc::new(vec![]), }), - |acc: Rc, item: String| match v1_rt::map_get( - &acc.seen.clone(), - item.clone(), - ) { + |acc: _, item: String| match v1_rt::map_get(&acc.seen.clone(), item.clone()) { Some(_) => acc.clone(), std::option::Option::None => Rc::new(DeduplicateAcc { seen: v1_rt::rc_map_insert(acc.seen.clone(), item.clone(), true), @@ -10301,7 +10292,7 @@ pub fn analyze_structural_bounds( ) -> Rc>> { func_entries.iter().cloned().fold( Rc::new(vec![]), - |acc: Rc>>, entry: Rc| { + |acc: Rc>>, entry: _| { let all_calls = collect_self_call_evidence(entry.body.clone(), entry.name.clone(), si.clone()); if ((all_calls.clone().len() as i64) == 0) { @@ -10431,16 +10422,14 @@ pub fn build_complexity_report( let si = source_indices.clone(); let func_index = func_entries.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, entry: Rc| { - v1_rt::rc_map_insert(acc, entry.name.clone(), entry.clone()) - }, + |acc: _, entry: _| v1_rt::rc_map_insert(acc, entry.name.clone(), entry.clone()), ); let scc_result = build_scc_index(func_entries.clone(), func_index.clone(), si.clone()); let parser_always_advancing = infer_all_parser_always_advancing(func_index.clone(), si.clone()); let full_scc_index = func_entries.iter().cloned().fold( scc_result.index.clone(), - |acc: Rc>>, entry: Rc| match v1_rt::map_get( + |acc: Rc>>, entry: _| match v1_rt::map_get( &acc, entry.name.clone(), ) { @@ -10484,7 +10473,7 @@ pub fn build_complexity_report( ); let fan_in = func_entries.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, entry: Rc| { + |acc: Rc>, entry: _| { let callees = match v1_rt::map_get(&call_forward, entry.name.clone()) { Some(cs) => cs.clone(), std::option::Option::None => Rc::new(vec![]), @@ -10517,10 +10506,7 @@ pub fn build_complexity_report( fan_in: fan_in.clone(), processed: v1_rt::rc_empty_map::(), }), - |acc: Rc, func_name: String| match v1_rt::map_get( - &func_index, - func_name.clone(), - ) { + |acc: _, func_name: String| match v1_rt::map_get(&func_index, func_name.clone()) { Some(entry) => { let sr = get_or_compute_summary( func_name.clone(), diff --git a/src/v1/stage0/src/v1_compiler_dag_collect.rs b/src/v1/stage0/src/v1_compiler_dag_collect.rs index 53c26413df3..c958e8894f0 100644 --- a/src/v1/stage0/src/v1_compiler_dag_collect.rs +++ b/src/v1/stage0/src/v1_compiler_dag_collect.rs @@ -289,7 +289,7 @@ pub fn collect_dag_nodes(typed: Rc) -> Rc { let collision_errors = Rc::new(vec![]); let slots = typed.modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::>(), - |s: Rc>>, m: Rc| { + |s: Rc>>, m: _| { dag_collect_from_module(m.clone(), s, collision_errors.clone()) }, ); diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index b4b95d081e4..7e1d288d207 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -92,7 +92,7 @@ pub fn module_filename_collision_diagnostics(typed: Rc) -> Rc(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, tm: Rc| { + |acc: Rc, tm: _| { let module_name = crate::v1_std_core::authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), @@ -154,7 +154,7 @@ pub fn unique_strings(items: Rc>) -> Rc> { seen: v1_rt::rc_empty_map::(), result: Rc::new(vec![]), }), - |acc: Rc, item: String| { + |acc: _, item: String| { if crate::v1_compiler_infer_types::emit_map_has(acc.seen.clone(), item.clone()) { acc.clone() } else { diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 372b0125783..52609764d31 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -1203,17 +1203,17 @@ pub fn emit_go_func_def( let body_scope = crate::v1_compiler_infer::build_params_scope(scope.clone(), params.clone()); let si = scope.type_env.clone().source_indices.clone(); - let body_scope = - uses.iter() - .cloned() - .fold(body_scope.clone(), |s: Rc, u: Rc| { - crate::v1_compiler_infer::extend_scope( - s, - crate::v1_std_core::resource_use_name_at(u.clone(), si.clone()), - crate::v1_std_core::resource_use_resource(u.clone()), - Rc::new(SubValueRelation::SubValueUnknown), - ) - }); + let body_scope = uses + .iter() + .cloned() + .fold(body_scope.clone(), |s: _, u: Rc| { + crate::v1_compiler_infer::extend_scope( + s, + crate::v1_std_core::resource_use_name_at(u.clone(), si.clone()), + crate::v1_std_core::resource_use_resource(u.clone()), + Rc::new(SubValueRelation::SubValueUnknown), + ) + }); let body_str = crate::v1_compiler_emit::emit_unified_typed_func_body( body.clone(), RenderTarget::Go, diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 14bd50c7aeb..dce9f0db937 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -1099,17 +1099,17 @@ pub fn emit_py_func_def( let body_scope = crate::v1_compiler_infer::build_params_scope(scope.clone(), params.clone()); let si = scope.type_env.clone().source_indices.clone(); - let body_scope = - uses.iter() - .cloned() - .fold(body_scope.clone(), |s: Rc, u: Rc| { - crate::v1_compiler_infer::extend_scope( - s, - crate::v1_std_core::resource_use_name_at(u.clone(), si.clone()), - crate::v1_std_core::resource_use_resource(u.clone()), - Rc::new(SubValueRelation::SubValueUnknown), - ) - }); + let body_scope = uses + .iter() + .cloned() + .fold(body_scope.clone(), |s: _, u: Rc| { + crate::v1_compiler_infer::extend_scope( + s, + crate::v1_std_core::resource_use_name_at(u.clone(), si.clone()), + crate::v1_std_core::resource_use_resource(u.clone()), + Rc::new(SubValueRelation::SubValueUnknown), + ) + }); let body_str = crate::v1_compiler_emit::emit_unified_typed_func_body( body.clone(), RenderTarget::Python, diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 28ce3707d3e..1dbf67bed3d 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -4752,7 +4752,7 @@ pub fn resolve_local_coproduct_wire_policy( pub fn build_data_item_index(modules: Rc>>) -> Rc>> { modules.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, tm: Rc| { + |acc: Rc>>, tm: _| { let module_name = crate::v1_std_core::authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), @@ -4791,7 +4791,7 @@ pub fn build_qualified_item_registry( ) -> Rc>> { modules.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, tm: Rc| { + |acc: _, tm: _| { let module_name = crate::v1_std_core::authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), @@ -4799,34 +4799,31 @@ pub fn build_qualified_item_registry( Rc::new(v1_rt::map_keys(&tm.item_registry.clone())) .iter() .cloned() - .fold( - acc, - |acc2: Rc>>, item_name: String| { - match v1_rt::map_get(&tm.item_registry.clone(), item_name.clone()) { - Some(info) => { - let qualified_name = v1_rt::concat( - v1_rt::concat(module_name.clone(), ".".to_string()), - item_name.clone(), - ); - match v1_rt::map_get(&acc2, qualified_name.clone()) { - Some(_) => v1_rt::rc_map_insert( - acc2.clone(), - qualified_name.clone(), - duplicate_qualified_item_registry_marker( - qualified_name.clone(), - ), - ), - std::option::Option::None => v1_rt::rc_map_insert( - acc2.clone(), + .fold(acc, |acc2: _, item_name: String| { + match v1_rt::map_get(&tm.item_registry.clone(), item_name.clone()) { + Some(info) => { + let qualified_name = v1_rt::concat( + v1_rt::concat(module_name.clone(), ".".to_string()), + item_name.clone(), + ); + match v1_rt::map_get(&acc2, qualified_name.clone()) { + Some(_) => v1_rt::rc_map_insert( + acc2.clone(), + qualified_name.clone(), + duplicate_qualified_item_registry_marker( qualified_name.clone(), - info.clone(), ), - } + ), + std::option::Option::None => v1_rt::rc_map_insert( + acc2.clone(), + qualified_name.clone(), + info.clone(), + ), } - std::option::Option::None => acc2.clone(), } - }, - ) + std::option::Option::None => acc2.clone(), + } + }) }, ) } @@ -4837,10 +4834,7 @@ pub fn merge_item_registries( ) -> Rc>> { Rc::new(v1_rt::map_keys(&qualified)).iter().cloned().fold( bare.clone(), - |acc: Rc>>, key: String| match v1_rt::map_get( - &qualified, - key.clone(), - ) { + |acc: _, key: String| match v1_rt::map_get(&qualified, key.clone()) { Some(info) => v1_rt::rc_map_insert(acc.clone(), key.clone(), info.clone()), std::option::Option::None => acc.clone(), }, @@ -5556,7 +5550,7 @@ pub fn build_shared_types( .cloned() .fold( v1_rt::rc_empty_set::(), - |acc: Rc>, summary: Rc| { + |acc: Rc>, summary: _| { maybe_mark_shared_type( acc, summary.clone(), @@ -5604,31 +5598,32 @@ pub struct OwnershipBuildResult { pub fn build_ownership_results(modules: Rc>>) -> Rc { { - let callable_set = modules.iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |acc: _, m: Rc| { - Rc::new({ - let mut __result = Vec::new(); - for item in m.items.clone().iter().cloned() { - if (item.body.clone() != std::option::Option::None) { - __result.push(item); - } - } - __result - }) + let callable_set = + modules .iter() .cloned() - .fold(acc, |inner: _, item: Rc| { - v1_rt::rc_set_union( - inner, - crate::v1_compiler_ownership::collect_callable_refs( - item.body.clone().clone().unwrap(), - m.type_env.clone().source_indices.clone(), - ), - ) - }) - }, - ); + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, m: _| { + Rc::new({ + let mut __result = Vec::new(); + for item in m.items.clone().iter().cloned() { + if (item.body.clone() != std::option::Option::None) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + .fold(acc, |inner: _, item: Rc| { + v1_rt::rc_set_union( + inner, + crate::v1_compiler_ownership::collect_callable_refs( + item.body.clone().clone().unwrap(), + m.type_env.clone().source_indices.clone(), + ), + ) + }) + }); let proofs = Rc::new({ let mut __result = Vec::new(); for m in modules.iter().cloned() { @@ -5699,7 +5694,7 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>>(), read_only_params_index: v1_rt::rc_empty_map::>>(), }), - |acc: Rc, entry: Rc| { + |acc: Rc, entry: _| { let acc = v1_rt::take_owned(acc); { let read_only = if v1_rt::set_contains( @@ -5831,7 +5826,7 @@ pub fn merged_module_source_indices( ) -> Rc>> { modules.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { + |acc: Rc>>, m: _| { v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) }, ) @@ -5944,7 +5939,7 @@ pub fn build_emit_rust_context(typed: Rc) -> Rc }); let svc_module_map = typed.modules.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, tm: Rc| { + |acc: Rc>, tm: _| { let svc_items = Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { @@ -6908,7 +6903,7 @@ pub fn build_module_export_sets( ) -> Rc>>> { modules.iter().cloned().fold( v1_rt::rc_empty_map::>>(), - |acc: Rc>>>, tm: Rc| { + |acc: _, tm: _| { let m_name = crate::v1_std_core::authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), @@ -10072,7 +10067,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc { let by_name = modules.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, tm: Rc| { + |acc: _, tm: _| { let nm = crate::v1_std_core::authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), @@ -10087,7 +10082,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc ); let by_filename = modules.iter().cloned().fold( v1_rt::rc_empty_map::>>>(), - |acc: Rc>>>>, tm: Rc| { + |acc: _, tm: _| { let fname = crate::v1_compiler_emit_core_support::module_to_filename( crate::v1_std_core::authored_name_at( tm.type_env.clone().source_indices.clone(), @@ -12973,7 +12968,7 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc, u: Rc| { - crate::v1_compiler_infer::extend_scope( - s, - crate::v1_std_core::resource_use_name_at(u.clone(), si.clone()), - crate::v1_std_core::resource_use_resource(u.clone()), - Rc::new(SubValueRelation::SubValueUnknown), - ) - }); + let body_scope = uses + .iter() + .cloned() + .fold(body_scope.clone(), |s: _, u: Rc| { + crate::v1_compiler_infer::extend_scope( + s, + crate::v1_std_core::resource_use_name_at(u.clone(), si.clone()), + crate::v1_std_core::resource_use_resource(u.clone()), + Rc::new(SubValueRelation::SubValueUnknown), + ) + }); let body_str = emit_func_body( body.clone(), registry.clone(), @@ -24216,7 +24211,7 @@ pub fn lambda_scope_from_children( ) .iter() .cloned() - .fold(scope.clone(), |acc: Rc, pair: (i64, String)| { + .fold(scope.clone(), |acc: _, pair: (i64, String)| { let idx = pair.0.clone(); let param_name = pair.1.clone(); let param_type = match param_nodes @@ -27432,7 +27427,7 @@ pub fn emit_typed_match_arm_strs( seen: Rc::new(vec![]), out: Rc::new(vec![]), }), - |acc: Rc, e: Rc| { + |acc: Rc, e: _| { let representative = if e.plan.clone().groupable.clone() { rc_group_representative(entries.clone(), e.plan.clone().variant.clone()) } else { @@ -33502,7 +33497,7 @@ pub fn emit_wire_struct_path_chain( node: Some(wire_node.clone()), ok: true, }), - |acc: Rc, seg: String| { + |acc: _, seg: String| { advance_wire_path_projection( acc, seg.clone(), @@ -35968,9 +35963,10 @@ pub fn record_data_decl( } pub fn build_data_decl_index(modules: Rc>>) -> Rc { - modules.iter().cloned().fold( - empty_data_decl_index(), - |acc: Rc, tm: Rc| { + modules + .iter() + .cloned() + .fold(empty_data_decl_index(), |acc: _, tm: _| { let si = tm.type_env.clone().source_indices.clone(); let module_path = crate::v1_std_core::authored_name_at(si.clone(), tm.module.clone()); let seeded = Rc::new(DataDeclIndex { @@ -35986,9 +35982,11 @@ pub fn build_data_decl_index(modules: Rc>>) -> Rc, i: Rc| { + tm.items + .clone() + .iter() + .cloned() + .fold(seeded.clone(), |inner: _, i: Rc| { if (crate::v1_compiler_infer_items::item_kind(i.clone()) != ItemKind::DataItem) { inner.clone() @@ -36003,10 +36001,8 @@ pub fn build_data_decl_index(modules: Rc>>) -> Rc inner.clone(), } } - }, - ) - }, - ) + }) + }) } pub fn data_decl_in_module( @@ -36110,20 +36106,17 @@ pub fn data_decl_reexporting_modules( }) .iter() .cloned() - .fold( - empty_data_decl_reach(), - |acc: Rc, e: Rc| { - merge_data_decl_reach( - acc, - data_decl_reexporting_modules( - index.clone(), - e.module_path.clone(), - name.clone(), - (depth.clone() + 1), - ), - ) - }, - ), + .fold(empty_data_decl_reach(), |acc: _, e: _| { + merge_data_decl_reach( + acc, + data_decl_reexporting_modules( + index.clone(), + e.module_path.clone(), + name.clone(), + (depth.clone() + 1), + ), + ) + }), } } }) @@ -36154,20 +36147,17 @@ pub fn data_decl_visible_modules( }) .iter() .cloned() - .fold( - empty_data_decl_reach(), - |acc: Rc, e: Rc| { - merge_data_decl_reach( - acc, - data_decl_reexporting_modules( - index.clone(), - e.module_path.clone(), - name.clone(), - 1, - ), - ) - }, - ); + .fold(empty_data_decl_reach(), |acc: _, e: _| { + merge_data_decl_reach( + acc, + data_decl_reexporting_modules( + index.clone(), + e.module_path.clone(), + name.clone(), + 1, + ), + ) + }); Rc::new(DataDeclReach { modules: crate::v1_compiler_emit_core_support::unique_strings( reached.modules.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index a4f6db3e2ab..266b79227fc 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -7473,19 +7473,20 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R ) }, ); - let new_body_locals = params.iter().cloned().fold( - scope.body_locals.clone(), - |acc: Rc>, p: Rc| { - v1_rt::rc_map_insert( - acc, - crate::v1_std_core::param_node_name_at( - p.clone(), - scope.type_env.clone().source_indices.clone(), - ), - true, - ) - }, - ); + let new_body_locals = + params + .iter() + .cloned() + .fold(scope.body_locals.clone(), |acc: _, p: Rc| { + v1_rt::rc_map_insert( + acc, + crate::v1_std_core::param_node_name_at( + p.clone(), + scope.type_env.clone().source_indices.clone(), + ), + true, + ) + }); Rc::new(InferScope { type_env: scope.type_env.clone(), func_env: scope.func_env.clone(), @@ -7577,10 +7578,12 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) ) }, ); - let new_body_locals = params.iter().cloned().fold( - scope.body_locals.clone(), - |acc: Rc>, p: String| v1_rt::rc_map_insert(acc, p.clone(), true), - ); + let new_body_locals = params + .iter() + .cloned() + .fold(scope.body_locals.clone(), |acc: _, p: String| { + v1_rt::rc_map_insert(acc, p.clone(), true) + }); Rc::new(InferScope { type_env: scope.type_env.clone(), func_env: scope.func_env.clone(), @@ -7733,7 +7736,7 @@ pub fn extend_scope_with_pattern_node( scope: scope.clone(), diagnostics: variant_diags.clone(), }), - |acc: Rc, fb: Rc| { + |acc: _, fb: Rc| { let field_name = crate::v1_std_core::field_binding_name_at( fb.clone(), scope.type_env.clone().source_indices.clone(), @@ -10785,7 +10788,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), .cloned() .fold( scope.clone(), - |acc: Rc, pair: (i64, String)| { + |acc: _, pair: (i64, String)| { let param_prov = if (pair.0.clone() == ((lam_params.clone().len() as i64) - 1)) { @@ -10857,7 +10860,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), .cloned() .fold( scope.clone(), - |acc: Rc, pair: (i64, String)| { + |acc: _, pair: (i64, String)| { let param_prov = if (pair.0.clone() == ((lam_params.clone().len() as i64) - 1)) { @@ -15018,16 +15021,16 @@ pub fn descent_ctx_shadowing_names( scope_locals: ctx.scope_locals.clone(), func_env: ctx.func_env.clone(), per_field_vars: ctx.per_field_vars.clone(), - body_locals: names.iter().cloned().fold( - ctx.body_locals.clone(), - |acc: Rc>, n: String| { + body_locals: names + .iter() + .cloned() + .fold(ctx.body_locals.clone(), |acc: _, n: String| { if (n.clone() == "".to_string()) { acc.clone() } else { v1_rt::rc_map_insert(acc.clone(), n.clone(), true) } - }, - ), + }), }) } @@ -15289,7 +15292,7 @@ let arm_ctx = match variant_arm_ctx.clone() { match (*crate::v1_std_core::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()) { - bindings.iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*crate::v1_std_core::field_binding_pattern(fb.clone())).clone() { + bindings.iter().cloned().fold(ctx.clone(), |c: _, fb: Rc| match (*crate::v1_std_core::field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { declaration: declaration, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: v1_rt::rc_map_insert(c.param_names.clone(), declaration.name.clone(), ind_field.element_type.clone()), @@ -15307,7 +15310,7 @@ let arm_ctx = match variant_arm_ctx.clone() { }), MatchPattern::VariantPattern { name: inner_vname, field_bindings: inner_bindings, .. } => { let inner_ind_fields = crate::v1_compiler_infer_env::inductive_fields_for(c.type_env.clone(), ind_field.element_type.clone()); -inner_bindings.iter().cloned().fold(c.clone(), |ic: Rc, inner_fb: Rc| { +inner_bindings.iter().cloned().fold(c.clone(), |ic: _, inner_fb: Rc| { let inner_field_name = crate::v1_std_core::field_binding_name_at(inner_fb.clone(), ctx.type_env.clone().source_indices.clone()); let inner_bind_name = match (*crate::v1_std_core::field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { declaration: declaration, .. } => declaration.name.clone(), @@ -15345,7 +15348,7 @@ match inner_matching.clone() { }, std::option::Option::None => { let ind_fields = crate::v1_compiler_infer_env::inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()); -bindings.iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| { +bindings.iter().cloned().fold(ctx.clone(), |c: _, fb: Rc| { let field_name = crate::v1_std_core::field_binding_name_at(fb.clone(), ctx.type_env.clone().source_indices.clone()); let bind_name = match (*crate::v1_std_core::field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { declaration: declaration, .. } => declaration.name.clone(), @@ -15576,7 +15579,7 @@ crate::v1_std_core::make_arm_node(arm_node.occurrence_identity.clone(), crate::v let threaded = body.children.clone().iter().cloned().fold(Rc::new(BlockAnnotateAcc { ctx: ctx.clone(), children: Rc::new(vec![]), -}), |acc: Rc, child: Rc| { +}), |acc: _, child: Rc| { let annotated = annotate_descent(child.clone(), acc.ctx.clone()); let next_ctx = match (*child.expr_data.clone()).clone() { ExprData::ExprLet => { @@ -16962,9 +16965,10 @@ pub fn arm_ctx_from_variant_provenance( Some(variant_field_map) => { let call_args = call_args_by_name(scrut.clone(), ctx.type_env.clone().source_indices.clone()); - let extended = bindings.iter().cloned().fold( - ctx.clone(), - |c: Rc, fb: Rc| { + let extended = bindings + .iter() + .cloned() + .fold(ctx.clone(), |c: _, fb: Rc| { let field_label = crate::v1_std_core::field_binding_name_at( fb.clone(), ctx.type_env.clone().source_indices.clone(), @@ -17038,8 +17042,7 @@ pub fn arm_ctx_from_variant_provenance( std::option::Option::None => c.clone(), } } - }, - ); + }); Some(extended.clone()) } std::option::Option::None => std::option::Option::None, @@ -17559,70 +17562,161 @@ pub fn populate_output_provenance( locals: Rc>>, ) -> Rc { { - let updated_local = typed_items.iter().cloned().fold( - func_env.local.clone(), - |acc: Rc>>, item: Rc| { - if ((item.params.clone().len() as i64) > 0) { - { - let fn_name = crate::v1_std_core::authored_name_at( - type_env.source_indices.clone(), - item.clone(), - ); - if (crate::v1_std_core::is_child_accessor_in_model(fn_name.clone()) - || crate::v1_std_core::is_tree_size_reducing(fn_name.clone())) + let updated_local = + typed_items + .iter() + .cloned() + .fold(func_env.local.clone(), |acc: _, item: Rc| { + if ((item.params.clone().len() as i64) > 0) { { - match item.params.clone().first().cloned() { - Some(first_param) => { - let pname = crate::v1_std_core::param_node_name_at( - first_param.clone(), - type_env.source_indices.clone(), - ); - let ptype = resolved_type_name( - first_param.clone(), - type_env.source_indices.clone(), - ); - if ((ptype.clone() != "".to_string()) - && (pname.clone() != "".to_string())) - { + let fn_name = crate::v1_std_core::authored_name_at( + type_env.source_indices.clone(), + item.clone(), + ); + if (crate::v1_std_core::is_child_accessor_in_model(fn_name.clone()) + || crate::v1_std_core::is_tree_size_reducing(fn_name.clone())) + { + match item.params.clone().first().cloned() { + Some(first_param) => { + let pname = crate::v1_std_core::param_node_name_at( + first_param.clone(), + type_env.source_indices.clone(), + ); + let ptype = resolved_type_name( + first_param.clone(), + type_env.source_indices.clone(), + ); + if ((ptype.clone() != "".to_string()) + && (pname.clone() != "".to_string())) { - let fields = + { + let fields = crate::v1_compiler_infer_env::inductive_fields_for( type_env.clone(), ptype.clone(), ); - let list_field = Rc::new({ - let mut __result = Vec::new(); - for f in fields.iter().cloned() { - if match f.shape.clone() { - RecursionShape::ListRecursion => true, - _ => false, - } { - __result.push(f); + let list_field = Rc::new({ + let mut __result = Vec::new(); + for f in fields.iter().cloned() { + if match f.shape.clone() { + RecursionShape::ListRecursion => true, + _ => false, + } { + __result.push(f); + } } - } - __result - }) - .first() - .cloned(); - match list_field.clone() { - Some(ind_field) => { - let relation = - Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), - factor: Rc::new( - ShrinkFactor::UnitShrink, - ), - }); - let provenance = - Rc::new(vec![v1_rt::rc_map_insert( - v1_rt::rc_empty_map::< - String, - Rc, - >( + __result + }) + .first() + .cloned(); + match list_field.clone() { + Some(ind_field) => { + let relation = Rc::new( + SubValueRelation::StrictSubValue { + field: ind_field.clone(), + factor: Rc::new( + ShrinkFactor::UnitShrink, + ), + }, + ); + let provenance = + Rc::new(vec![v1_rt::rc_map_insert( + v1_rt::rc_empty_map::< + String, + Rc, + >( + ), + pname.clone(), + relation.clone(), + )]); + match v1_rt::map_get(&acc, fn_name.clone()) + { + Some(sig) => v1_rt::rc_map_insert( + acc.clone(), + fn_name.clone(), + Rc::new(ResolvedFuncSig { + name: sig.name.clone(), + params: sig.params.clone(), + inferred: sig.inferred.clone(), + is_async: sig.is_async.clone(), + output_provenance: provenance + .clone(), + variant_provenance: sig + .variant_provenance + .clone(), + }), ), - pname.clone(), - relation.clone(), - )]); + std::option::Option::None => { + acc.clone() + } + } + } + std::option::Option::None => acc.clone(), + } + } + } else { + acc.clone() + } + } + std::option::Option::None => acc.clone(), + } + } else { + match item.body.clone() { + Some(body) => { + if !crate::v1_std_core::expr_has_self_call( + body.clone(), + fn_name.clone(), + type_env.source_indices.clone(), + ) { + { + let working_env = Rc::new(ResolvedFuncEnv { + name: func_env.name.clone(), + local: acc.clone(), + parents: func_env.parents.clone(), + }); + let provenance = infer_output_provenance( + body.clone(), + item.params.clone(), + type_env.clone(), + locals.clone(), + working_env.clone(), + ); + let variant_prov = + match item.inferred.clone().as_deref().cloned() + { + Some(InferredNode::Resolved { + node: rt, + .. + }) => compute_variant_provenance( + body.clone(), + rt.clone(), + item.params.clone(), + type_env.clone(), + working_env.clone(), + ), + _ => v1_rt::rc_empty_map::< + String, + Rc< + HashMap< + String, + Rc< + HashMap< + String, + Rc, + >, + >, + >, + >, + >( + ), + }; + let has_scalar = + ((provenance.clone().len() as i64) > 0); + let has_variant = + ((Rc::new(v1_rt::map_keys(&variant_prov)).len() + as i64) + > 0); + if (has_scalar.clone() || has_variant.clone()) { match v1_rt::map_get(&acc, fn_name.clone()) { Some(sig) => v1_rt::rc_map_insert( acc.clone(), @@ -17632,124 +17726,40 @@ pub fn populate_output_provenance( params: sig.params.clone(), inferred: sig.inferred.clone(), is_async: sig.is_async.clone(), - output_provenance: provenance - .clone(), - variant_provenance: sig - .variant_provenance - .clone(), + output_provenance: if has_scalar + .clone() + { + provenance.clone() + } else { + sig.output_provenance.clone() + }, + variant_provenance: if has_variant + .clone() + { + variant_prov.clone() + } else { + sig.variant_provenance.clone() + }, }), ), std::option::Option::None => acc.clone(), } + } else { + acc.clone() } - std::option::Option::None => acc.clone(), - } - } - } else { - acc.clone() - } - } - std::option::Option::None => acc.clone(), - } - } else { - match item.body.clone() { - Some(body) => { - if !crate::v1_std_core::expr_has_self_call( - body.clone(), - fn_name.clone(), - type_env.source_indices.clone(), - ) { - { - let working_env = Rc::new(ResolvedFuncEnv { - name: func_env.name.clone(), - local: acc.clone(), - parents: func_env.parents.clone(), - }); - let provenance = infer_output_provenance( - body.clone(), - item.params.clone(), - type_env.clone(), - locals.clone(), - working_env.clone(), - ); - let variant_prov = - match item.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { - node: rt, - .. - }) => compute_variant_provenance( - body.clone(), - rt.clone(), - item.params.clone(), - type_env.clone(), - working_env.clone(), - ), - _ => v1_rt::rc_empty_map::< - String, - Rc< - HashMap< - String, - Rc< - HashMap< - String, - Rc, - >, - >, - >, - >, - >( - ), - }; - let has_scalar = - ((provenance.clone().len() as i64) > 0); - let has_variant = - ((Rc::new(v1_rt::map_keys(&variant_prov)).len() - as i64) - > 0); - if (has_scalar.clone() || has_variant.clone()) { - match v1_rt::map_get(&acc, fn_name.clone()) { - Some(sig) => v1_rt::rc_map_insert( - acc.clone(), - fn_name.clone(), - Rc::new(ResolvedFuncSig { - name: sig.name.clone(), - params: sig.params.clone(), - inferred: sig.inferred.clone(), - is_async: sig.is_async.clone(), - output_provenance: if has_scalar.clone() - { - provenance.clone() - } else { - sig.output_provenance.clone() - }, - variant_provenance: if has_variant - .clone() - { - variant_prov.clone() - } else { - sig.variant_provenance.clone() - }, - }), - ), - std::option::Option::None => acc.clone(), - } - } else { - acc.clone() } + } else { + acc.clone() } - } else { - acc.clone() } + std::option::Option::None => acc.clone(), } - std::option::Option::None => acc.clone(), } } + } else { + acc.clone() } - } else { - acc.clone() - } - }, - ); + }); Rc::new(ResolvedFuncEnv { name: func_env.name.clone(), local: updated_local.clone(), @@ -17801,7 +17811,7 @@ pub fn annotate_descent_evidence( ), body_locals: params.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, p: Rc| { + |acc: _, p: Rc| { v1_rt::rc_map_insert( acc, crate::v1_std_core::param_node_name_at( @@ -18110,7 +18120,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let fn_scope = build_params_scope(scope.clone(), item.params.clone()); let fn_scope = item.uses.clone().iter().cloned().fold( fn_scope.clone(), - |s: Rc, u: Rc| { + |s: _, u: Rc| { extend_scope( s, crate::v1_std_core::resource_use_name_at( @@ -18997,9 +19007,7 @@ pub fn compiler_recursive_name_set() -> Rc> { .cloned() .fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert(acc, name.clone(), true) - }, + |acc: _, name: String| v1_rt::rc_map_insert(acc, name.clone(), true), ) } @@ -19082,7 +19090,7 @@ pub fn union_parent_type_env_caches( cache: head.cache.clone(), conflicts: Rc::new(vec![]), }), - |acc: Rc, row: Rc| { + |acc: _, row: _| { crate::v1_compiler_infer_env::merge_type_env_cache_guarded( acc.cache.clone(), row.cache.clone(), @@ -21120,7 +21128,7 @@ pub fn symbol_index_with_qualified_fill( pub fn direct_import_export_precedence_note() -> String { thread_local! { static CACHED: String = { - "Direct-selected exports beat transitive leaks (2026-07-16, the #6663 x #6686 main-red). The ancestry union folds each direct import's WHOLE flattened cache (its own exports AND everything it inherited), so a later import's transitively-leaked homonym could overlay an earlier import's OWN export that this module's import statement explicitly selects - import v2.std.algebra { Monoid } lost 'Monoid' to dag-root std.algebra riding v2.std.node's ancestry via std.types, and #6663's field-presence wall read the wrong shape at 28 sites. This overlay re-applies, in import order, each direct import's OWN export surface (interface.env.str_bindings - locals only, never its ancestry) restricted to the names the import statement makes visible (specific_names; is_all = the parent's whole local surface, type-variable names filtered per the std.types precedent). Winner semantics: direct-selected vs transitive leak = direct wins (lexical nearest-wins, the containment ruling one hop out - the sanctioned 1c universe is own declarations UNION direct import lists); direct vs direct = unchanged import-order overlay-wins (the ledgered peer-fork ruling, 2026-07-11: later import wins, conflict stays LEDGERED on binding_forks); leak vs leak = unchanged union winner; KERNEL names are never overridden (overlay_skips_kernel_name: kernel_type_set, the container_type_arity names List/Set/Map/Witness, plus Unit/Optional/Present/Absent) - the kernel scope layer stays positionally above imports per the same ruling, because builtin typing (first, skip, string ops) grounds on kernel identities and the v2 substrate models of those concepts (v2.std.collection List=FreeMonoid, Optional; v2.std.text String) are the known dual-representation debt, resolved corpus-wide by kernel-wins today. Full precedence, nearest first: locals > kernel > direct-selected > transitive union. The fork LEDGER is untouched - rows still record every union conflict; this layer only corrects which binding serves lookups. DISSOLVES WHEN namespace Rule-1 lands (containment tree is the naming authority; imports become parse errors) - the union leak itself disappears and this overlay with it. Receipt: direct_import_precedence_over_transitive_leak_test (green arm = selected name resolves the selected module's shape regardless of import order; red control = the field wall still refuses the true shape's missing fields, with that arm's modules placed so the homonym is census-UNAMBIGUOUS by containment (realleaf under the consumer's own parent, leakleaf under a sibling parent) - a census-ambiguous name stands the wall down BY DESIGN (presence_check_census_gate_note), so without that placement the control asserts a diagnostic the gate exists to suppress and silently measures the gate instead of the overlay; ledger arm = the fork row is still recorded).".to_string() + "Direct-selected exports beat transitive leaks (2026-07-16, the #6663 x #6686 main-red). The ancestry union folds each direct import's WHOLE flattened cache (its own exports AND everything it inherited), so a later import's transitively-leaked homonym could overlay an earlier import's OWN export that this module's import statement explicitly selects - import v2.std.algebra { Monoid } lost 'Monoid' to dag-root std.algebra riding v2.std.node's ancestry via std.types, and #6663's field-presence wall read the wrong shape at 28 sites. This overlay re-applies, in import order, each direct import's OWN export surface (interface.env.str_bindings - locals only, never its ancestry) restricted to the names the import statement makes visible (specific_names; is_all = the parent's whole local surface, type-variable names filtered per the std.types precedent). Winner semantics: direct-selected vs transitive leak = direct wins (lexical nearest-wins, the containment ruling one hop out - the sanctioned 1c universe is own declarations UNION direct import lists); direct vs direct = unchanged import-order overlay-wins (the ledgered peer-fork ruling, 2026-07-11: later import wins, conflict stays LEDGERED on binding_forks); leak vs leak = unchanged union winner; KERNEL names are never overridden (overlay_skips_kernel_name: kernel_type_set, the container_type_arity names List/Set/Map/Witness, plus Unit/Optional/Present/Absent) - the kernel scope layer stays positionally above imports per the same ruling, because builtin typing (first, skip, string ops) grounds on kernel identities and the v2 substrate models of those concepts (v2.std.collection List=FreeMonoid, Optional; v2.std.text String) are the known dual-representation debt, resolved corpus-wide by kernel-wins today. KERNEL INSTALLATION IS INDEPENDENT OF IMPORT CARDINALITY (build_ancestry_precedence, 2026-08-31): the kernel overlay applies unconditionally over the import union and both type-env builders consume the one producer - the former shape skipped the overlay when a module had exactly one import, so kernel identity won or lost by ancestry occupancy (a leak-dependent regime: identical imports, different realizations). Full precedence, nearest first: locals > kernel > direct-selected > transitive union. The fork LEDGER is untouched - rows still record every union conflict; this layer only corrects which binding serves lookups. DISSOLVES WHEN namespace Rule-1 lands (containment tree is the naming authority; imports become parse errors) - the union leak itself disappears and this overlay with it. Receipt: direct_import_precedence_over_transitive_leak_test (green arm = selected name resolves the selected module's shape regardless of import order; red control = the field wall still refuses the true shape's missing fields, with that arm's modules placed so the homonym is census-UNAMBIGUOUS by containment (realleaf under the consumer's own parent, leakleaf under a sibling parent) - a census-ambiguous name stands the wall down BY DESIGN (presence_check_census_gate_note), so without that placement the control asserts a diagnostic the gate exists to suppress and silently measures the gate instead of the overlay; ledger arm = the fork row is still recorded).".to_string() }; } CACHED.with(|c: &String| c.clone()) @@ -21142,7 +21150,7 @@ pub fn overlay_direct_import_exports( ) -> Rc>> { resolved_imports.iter().cloned().fold( ancestry_str_bindings.clone(), - |acc: Rc>>, imp: Rc| match v1_rt::map_get( + |acc: Rc>>, imp: _| match v1_rt::map_get( &parent_index, imp.module_path.clone(), ) { @@ -21191,6 +21199,108 @@ pub fn overlay_direct_import_exports( ) } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct AncestryPrecedence { + pub cache: Rc, + pub ancestry_str_bindings: Rc>>, + pub conflicts: Rc>>, +} + +pub fn kernel_bool_type_node() -> Rc { + { + let kernel_true_variant = Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: "True".to_string(), + span: kernel_span("True".to_string()), + ident_span: Some(kernel_span("True".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: std::option::Option::None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: std::option::Option::None, + transport: std::option::Option::None, + properties: Rc::new(vec![]), + type_annotation: std::option::Option::None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + let kernel_false_variant = Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: "False".to_string(), + span: kernel_span("False".to_string()), + ident_span: Some(kernel_span("False".to_string())), + children: Rc::new(vec![]), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: std::option::Option::None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: std::option::Option::None, + transport: std::option::Option::None, + properties: Rc::new(vec![]), + type_annotation: std::option::Option::None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }); + Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: "Bool".to_string(), + span: kernel_span("Bool".to_string()), + ident_span: Some(kernel_span("Bool".to_string())), + children: Rc::new(vec![ + kernel_true_variant.clone(), + kernel_false_variant.clone(), + ]), + connective: Connective::Disj, + params: Rc::new(vec![]), + inferred: std::option::Option::None, + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: std::option::Option::None, + transport: std::option::Option::None, + properties: Rc::new(vec![]), + type_annotation: std::option::Option::None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }) + } +} + +pub fn build_ancestry_precedence( + resolved_imports: Rc>>, + parent_index: Rc>>, + kernel_cache: Rc, +) -> Rc { + { + let import_union = + union_parent_type_env_caches(resolved_imports.clone(), parent_index.clone()); + let with_kernel = crate::v1_compiler_infer_env::merge_type_env_cache( + import_union.cache.clone(), + kernel_cache.clone(), + ); + Rc::new(AncestryPrecedence { + cache: with_kernel.clone(), + ancestry_str_bindings: overlay_direct_import_exports( + with_kernel.str_bindings.clone(), + resolved_imports.clone(), + parent_index.clone(), + ), + conflicts: import_union.conflicts.clone(), + }) + } +} + pub fn build_type_env( module: Rc, parent_index: Rc>>, @@ -21227,6 +21337,8 @@ pub fn build_type_env( "Absent".to_string(), "value".to_string(), "none".to_string(), + "True".to_string(), + "False".to_string(), ]) .iter() .cloned() @@ -21420,6 +21532,17 @@ pub fn build_type_env( provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + crate::v1_std_core::intern(intern_table.clone(), "Bool".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Bool".to_string(), + resolved: kernel_bool_type_node(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); let node_fields = crate::v1_compiler_infer_env::inductive_fields_list_to_map(compiler_inductive_fields()); let kernel_recursive_types = Rc::new({ @@ -21664,18 +21787,13 @@ pub fn build_type_env( source_indices.clone(), compiler_recursive_name_set(), ); - let import_union = - union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()); - let import_cache = import_union.cache.clone(); - let binding_forks = import_union.conflicts.clone(); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache.clone() - } else { - crate::v1_compiler_infer_env::merge_type_env_cache( - import_cache.clone(), - kernel_cache.clone(), - ) - }; + let ancestry_precedence = build_ancestry_precedence( + module.resolved_imports.clone(), + parent_index.clone(), + kernel_cache.clone(), + ); + let ancestry_cache = ancestry_precedence.cache.clone(); + let binding_forks = ancestry_precedence.conflicts.clone(); let local_deps_map = Rc::new(v1_rt::map_values(&all_local_bindings)) .iter() .cloned() @@ -21785,11 +21903,7 @@ pub fn build_type_env( parent_inductive_fields.clone(), local_inductive_fields.clone(), ); - let ancestry_str_bindings = overlay_direct_import_exports( - ancestry_cache.str_bindings.clone(), - module.resolved_imports.clone(), - parent_index.clone(), - ); + let ancestry_str_bindings = ancestry_precedence.ancestry_str_bindings.clone(); let svn_local = Rc::new(v1_rt::map_keys(&local_str_bindings)) .iter() .cloned() @@ -21810,7 +21924,7 @@ pub fn build_type_env( ); let source_visible_names = module.resolved_imports.clone().iter().cloned().fold( svn_kernel.clone(), - |acc: Rc>, imp: Rc| { + |acc: Rc>, imp: _| { if imp.is_all.clone() { match v1_rt::map_get(&parent_index, imp.module_path.clone()) { Some(parent_mod) => { @@ -21863,7 +21977,7 @@ pub fn build_type_env( ); let authored_import_names = module.resolved_imports.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, imp: Rc| { + |acc: Rc>, imp: _| { if imp.is_all.clone() { acc.clone() } else { @@ -22101,6 +22215,17 @@ pub fn build_type_env_unresolved( provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + crate::v1_std_core::intern(intern_table.clone(), "Bool".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Bool".to_string(), + resolved: kernel_bool_type_node(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); let kernel_str_bindings = crate::v1_compiler_infer_env::str_bindings_from_bindings(kernel_bindings.clone()); let kernel = Rc::new(TypeEnv { @@ -22305,18 +22430,12 @@ pub fn build_type_env_unresolved( source_indices.clone(), compiler_recursive_name_set(), ); - let import_cache = - union_parent_type_env_caches(module.resolved_imports.clone(), parent_index.clone()) - .cache - .clone(); - let ancestry_cache = if ((module.resolved_imports.clone().len() as i64) == 1) { - import_cache.clone() - } else { - crate::v1_compiler_infer_env::merge_type_env_cache( - import_cache.clone(), - kernel_cache.clone(), - ) - }; + let ancestry_precedence = build_ancestry_precedence( + module.resolved_imports.clone(), + parent_index.clone(), + kernel_cache.clone(), + ); + let ancestry_cache = ancestry_precedence.cache.clone(); let local_deps_map = Rc::new(v1_rt::map_values(&local_bindings)) .iter() .cloned() @@ -22426,7 +22545,7 @@ pub fn build_type_env_unresolved( parent_inductive_fields.clone(), local_inductive_fields.clone(), ); - let ancestry_str_bindings = ancestry_cache.str_bindings.clone(); + let ancestry_str_bindings = ancestry_precedence.ancestry_str_bindings.clone(); let visible_str_bindings = v1_rt::rc_map_merge(ancestry_str_bindings.clone(), local_str_bindings.clone()); let module_variant_index = crate::v1_compiler_infer_env::build_unit_variant_index( @@ -23076,9 +23195,10 @@ pub fn build_imported_variants( module_name: String, init: Rc, ) -> Rc { - resolved_imports.iter().cloned().fold( - init.clone(), - |acc: Rc, imp: Rc| { + resolved_imports + .iter() + .cloned() + .fold(init.clone(), |acc: Rc, imp: _| { let with_glob = if imp.is_all.clone() { { let source_items = match v1_rt::map_get(&parent_index, imp.module_path.clone()) @@ -23122,8 +23242,7 @@ pub fn build_imported_variants( ) }, ) - }, - ) + }) } pub fn selective_func_env_view( @@ -23133,10 +23252,7 @@ pub fn selective_func_env_view( { let selected = names.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| match v1_rt::map_get( - &env.local.clone(), - name.clone(), - ) { + |acc: _, name: String| match v1_rt::map_get(&env.local.clone(), name.clone()) { Some(sig) => v1_rt::rc_map_insert(acc.clone(), name.clone(), sig.clone()), std::option::Option::None => acc.clone(), }, @@ -23182,10 +23298,7 @@ pub fn merge_func_sig_maps( ) -> Rc>> { Rc::new(v1_rt::map_keys(&incoming)).iter().cloned().fold( base.clone(), - |acc: Rc>>, name: String| match v1_rt::map_get( - &incoming, - name.clone(), - ) { + |acc: _, name: String| match v1_rt::map_get(&incoming, name.clone()) { Some(sig) => v1_rt::rc_map_insert(acc.clone(), name.clone(), sig.clone()), std::option::Option::None => acc.clone(), }, @@ -24095,7 +24208,7 @@ pub fn build_enum_variant_shape_sets( fielded: v1_rt::rc_empty_set::(), positional_payload: v1_rt::rc_empty_set::(), }), - |acc: Rc, m: Rc| { + |acc: Rc, m: _| { m.items.clone().iter().cloned().fold( acc, |inner: Rc, item: Rc| { @@ -24120,12 +24233,13 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>(), structural_alias_direct_fn_names: v1_rt::rc_empty_set::(), }); - let built_raw = modules.iter().cloned().fold( - init.clone(), - |state: Rc, typed_module: Rc| { + let built_raw = modules + .iter() + .cloned() + .fold(init.clone(), |state: _, typed_module: _| { typed_module.items.clone().iter().cloned().fold( state, - |inner_state: Rc, item: Rc| { + |inner_state: _, item: Rc| { crate::v1_compiler_infer_emit_info::add_emit_item_summary( inner_state, item.clone(), @@ -24133,8 +24247,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>) -> Rc(), - |acc: _, m: Rc| { - Rc::new(v1_rt::map_keys( - &m.type_env.clone().recursive_type_set.clone(), - )) + let all_recursive = + modules .iter() .cloned() - .fold(acc, |inner: _, ident: i64| { - v1_rt::rc_set_insert( - inner, - crate::v1_std_core::intern_str( - m.type_env.clone().intern_table.clone(), - ident.clone(), - ), - ) - }) - }, - ); + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, m: _| { + Rc::new(v1_rt::map_keys( + &m.type_env.clone().recursive_type_set.clone(), + )) + .iter() + .cloned() + .fold(acc, |inner: _, ident: i64| { + v1_rt::rc_set_insert( + inner, + crate::v1_std_core::intern_str( + m.type_env.clone().intern_table.clone(), + ident.clone(), + ), + ) + }) + }); let variant_shapes = build_enum_variant_shape_sets(modules.clone(), built.type_summaries.clone()); let vtoe = crate::v1_compiler_infer_emit_info::derive_variant_to_enum( @@ -24209,6 +24323,8 @@ pub fn seed_kernel_intern_table(intern_table: Rc) -> Rc>(), - |acc: Rc>>, rm: Rc| { + |acc: _, rm: _| { v1_rt::rc_map_insert( acc, crate::v1_std_core::authored_name_at(source_indices.clone(), rm.module.clone()), @@ -24280,7 +24396,7 @@ pub fn typecheck_with_census_extra( item_registry: v1_rt::rc_empty_map::>(), diags_by_name: v1_rt::rc_empty_map::>>>(), }), - |st: Rc, rm: Rc| { + |st: _, rm: _| { realize_module( crate::v1_std_core::authored_name_at(source_indices.clone(), rm.module.clone()), resolved_by_name.clone(), @@ -24366,7 +24482,7 @@ pub fn realize_module( Some(resolved) => { let dep_state = resolved.resolved_imports.clone().iter().cloned().fold( state, - |st: Rc, imp: Rc| { + |st: _, imp: _| { realize_module( imp.module_path.clone(), resolved_by_name.clone(), @@ -24468,7 +24584,7 @@ pub fn export_index_module_state( index: acc.clone(), seen_names: v1_rt::rc_empty_map::(), }), - |state: Rc, binding: Rc| { + |state: _, binding: Rc| { let name = binding.name.clone(); if v1_rt::map_contains_key(&state.seen_names.clone(), name.clone()) { state.clone() @@ -24532,9 +24648,7 @@ pub fn build_export_indexes( by_name: v1_rt::rc_empty_map::>(), by_module: v1_rt::rc_empty_map::>>(), }), - |acc: Rc, m: Rc| { - export_index_merge_module_both(acc, m.clone(), source_indices.clone()) - }, + |acc: _, m: _| export_index_merge_module_both(acc, m.clone(), source_indices.clone()), ) } @@ -24544,9 +24658,7 @@ pub fn module_exported_type_names(m: Rc) -> Rc(), - |acc: Rc>, b: Rc| { - v1_rt::rc_map_insert(acc, b.name.clone(), true) - }, + |acc: _, b: Rc| v1_rt::rc_map_insert(acc, b.name.clone(), true), ) } @@ -24582,7 +24694,7 @@ pub fn direct_import_exporter_counts( ) -> Rc> { import_export_names.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, names: Rc>| { + |acc: Rc>, names: _| { Rc::new(v1_rt::map_keys(&names)).iter().cloned().fold( acc, |inner: Rc>, name: String| match v1_rt::map_get( @@ -24949,6 +25061,17 @@ pub fn compiler_kernel_type_env( provenance: Rc::new(SubValueRelation::SubValueUnknown), }), ); + let kernel_bindings = v1_rt::rc_map_insert( + kernel_bindings.clone(), + crate::v1_std_core::intern(intern_table.clone(), "Bool".to_string()) + .id + .clone(), + Rc::new(TypeBinding { + name: "Bool".to_string(), + resolved: kernel_bool_type_node(), + provenance: Rc::new(SubValueRelation::SubValueUnknown), + }), + ); let node_fields = crate::v1_compiler_infer_env::inductive_fields_list_to_map(compiler_inductive_fields()); let kernel_recursive_types = Rc::new({ @@ -25012,7 +25135,7 @@ pub fn rewire_type_env_parent_links( { let index = modules.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { + |acc: _, m: _| { v1_rt::rc_map_insert( acc, crate::v1_std_core::authored_name_at(source_indices.clone(), m.module.clone()), @@ -25130,7 +25253,7 @@ pub fn rewire_func_env_parent_links( { let index = modules.iter().cloned().fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, m: Rc| { + |acc: _, m: _| { v1_rt::rc_map_insert( acc, crate::v1_std_core::authored_name_at(source_indices.clone(), m.module.clone()), diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b26bf0fe63a..bcbc74eeb55 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -88,7 +88,7 @@ pub fn dedupe_nonempty_strings(items: Rc>) -> Rc> { seen: v1_rt::rc_empty_map::(), result: Rc::new(vec![]), }), - |inner: Rc, item: String| { + |inner: _, item: String| { if ((item.clone() == "".to_string()) || crate::v1_compiler_infer_types::emit_map_has( inner.seen.clone(), @@ -357,11 +357,7 @@ pub fn derive_variant_to_enum( .cloned() .fold( v1_rt::rc_empty_map::(), - |acc: Rc>, summary: Rc| match (*summary - .repr - .clone()) - .clone() - { + |acc: Rc>, summary: _| match (*summary.repr.clone()).clone() { TypeRepr::EnumRepr { unit_only: _, .. } => { Rc::new(v1_rt::map_keys(&summary.variant_name_set.clone())) .iter() @@ -827,7 +823,7 @@ pub fn build_type_summary( ), variant_name_set: item.children.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, child: Rc| { + |acc: _, child: Rc| { v1_rt::rc_map_insert( acc, crate::v1_std_core::authored_name_at( @@ -970,10 +966,7 @@ pub fn close_fn_fields( ) -> Rc>> { Rc::new(v1_rt::map_keys(&summaries)).iter().cloned().fold( summaries.clone(), - |acc: Rc>>, name: String| match v1_rt::map_get( - &summaries, - name.clone(), - ) { + |acc: _, name: String| match v1_rt::map_get(&summaries, name.clone()) { Some(s) => { if (!s.has_fn_fields.clone() && type_summary_or_structural_alias_reaches_fn( @@ -1100,80 +1093,66 @@ pub fn add_emit_item_summary( }; match build_type_summary(item.clone(), source_indices.clone()) { Some(summary) => { - let with_variants = - match (*summary.repr.clone()).clone() { - TypeRepr::EnumRepr { unit_only: _, .. } => { - item.children.clone().iter().cloned().fold( - state.type_summaries.clone(), - |acc: Rc>>, variant: Rc| { - if ((variant.children.clone().len() as i64) > 0) { - { - let v_has_fn = { - let mut __found = false; - for vc in variant.children.clone().iter().cloned() { - if match vc.inferred.clone().as_deref().cloned() - { - Some(InferredNode::Resolved { - node: rt, - .. - }) => { - (rt.connective.clone() - == Connective::Arrow) - } - _ => false, - } { - __found = true; - break; - } - } - __found - }; - let vname = crate::v1_std_core::authored_name_at( - source_indices.clone(), + let with_variants = match (*summary.repr.clone()).clone() { + TypeRepr::EnumRepr { unit_only: _, .. } => item + .children + .clone() + .iter() + .cloned() + .fold(state.type_summaries.clone(), |acc: _, variant: Rc| { + if ((variant.children.clone().len() as i64) > 0) { + { + let v_has_fn = { + let mut __found = false; + for vc in variant.children.clone().iter().cloned() { + if match vc.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { + node: rt, .. + }) => (rt.connective.clone() == Connective::Arrow), + _ => false, + } { + __found = true; + break; + } + } + __found + }; + let vname = crate::v1_std_core::authored_name_at( + source_indices.clone(), + variant.clone(), + ); + let qualified_vname = + variant_summary_key(summary.name.clone(), vname.clone()); + let variant_field_types = build_field_type_map( + variant.children.clone(), + source_indices.clone(), + ); + v1_rt::rc_map_insert( + acc.clone(), + qualified_vname.clone(), + Rc::new(TypeSummary { + name: qualified_vname.clone(), + repr: Rc::new(TypeRepr::StructRepr), + field_summaries: build_struct_field_summaries( variant.clone(), - ); - let qualified_vname = variant_summary_key( - summary.name.clone(), - vname.clone(), - ); - let variant_field_types = build_field_type_map( - variant.children.clone(), source_indices.clone(), - ); - v1_rt::rc_map_insert( - acc.clone(), - qualified_vname.clone(), - Rc::new(TypeSummary { - name: qualified_vname.clone(), - repr: Rc::new(TypeRepr::StructRepr), - field_summaries: build_struct_field_summaries( - variant.clone(), - source_indices.clone(), - ), - field_type_map: variant_field_types - .field_types - .clone(), - field_import_surface_names: variant_field_types - .import_surface_names - .clone(), - variant_name_set: v1_rt::rc_empty_map::< - String, - bool, - >( - ), - generic_param_names: Rc::new(vec![]), - has_fn_fields: v_has_fn.clone(), - }), - ) - } - } else { - acc.clone() - } - }, - ) - } - _ => state.type_summaries.clone(), - }; + ), + field_type_map: variant_field_types.field_types.clone(), + field_import_surface_names: variant_field_types + .import_surface_names + .clone(), + variant_name_set: v1_rt::rc_empty_map::(), + generic_param_names: Rc::new(vec![]), + has_fn_fields: v_has_fn.clone(), + }), + ) + } + } else { + acc.clone() + } + }), + _ => state.type_summaries.clone(), + }; let next_summaries = v1_rt::rc_map_insert( with_variants.clone(), summary.name.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index e9b659c9f8c..43c959b4e37 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -636,10 +636,7 @@ pub fn guarded_union_str_bindings_into_acc( bindings: acc.clone(), conflicts: conflicts.clone(), }), - |state: Rc, name: String| match v1_rt::map_get( - &overlay, - name.clone(), - ) { + |state: _, name: String| match v1_rt::map_get(&overlay, name.clone()) { std::option::Option::None => state.clone(), Some(incoming) => match v1_rt::map_get(&state.bindings.clone(), name.clone()) { std::option::Option::None => Rc::new(GuardedStrBindingsUnion { @@ -706,8 +703,7 @@ pub fn guarded_union_str_bindings_into_overlay( bindings: overlay.clone(), conflicts: conflicts.clone(), }), - |state: Rc, name: String| match v1_rt::map_get(&acc, name.clone()) - { + |state: _, name: String| match v1_rt::map_get(&acc, name.clone()) { std::option::Option::None => state.clone(), Some(accumulated) => match v1_rt::map_get(&state.bindings.clone(), name.clone()) { std::option::Option::None => Rc::new(GuardedStrBindingsUnion { @@ -851,40 +847,44 @@ pub fn union_bool_set_into_acc( acc: Rc>, overlay: Rc>, ) -> Rc> { - Rc::new(v1_rt::map_keys(&overlay)).iter().cloned().fold( - acc.clone(), - |m: Rc>, name: String| match v1_rt::map_get(&m, name.clone()) { - Some(_) => m.clone(), - std::option::Option::None => match v1_rt::map_get(&overlay, name.clone()) { - Some(v) => v1_rt::rc_map_insert(m.clone(), name.clone(), v.clone()), - std::option::Option::None => m.clone(), - }, - }, - ) + Rc::new(v1_rt::map_keys(&overlay)) + .iter() + .cloned() + .fold(acc.clone(), |m: _, name: String| { + match v1_rt::map_get(&m, name.clone()) { + Some(_) => m.clone(), + std::option::Option::None => match v1_rt::map_get(&overlay, name.clone()) { + Some(v) => v1_rt::rc_map_insert(m.clone(), name.clone(), v.clone()), + std::option::Option::None => m.clone(), + }, + } + }) } pub fn union_bool_set_into_overlay( acc: Rc>, overlay: Rc>, ) -> Rc> { - Rc::new(v1_rt::map_keys(&acc)).iter().cloned().fold( - overlay.clone(), - |m: Rc>, name: String| match v1_rt::map_get(&acc, name.clone()) { - std::option::Option::None => m.clone(), - Some(accumulated) => match v1_rt::map_get(&m, name.clone()) { - std::option::Option::None => { - v1_rt::rc_map_insert(m.clone(), name.clone(), accumulated.clone()) - } - Some(incoming) => { - if (incoming.clone() == accumulated.clone()) { - m.clone() - } else { + Rc::new(v1_rt::map_keys(&acc)) + .iter() + .cloned() + .fold(overlay.clone(), |m: _, name: String| { + match v1_rt::map_get(&acc, name.clone()) { + std::option::Option::None => m.clone(), + Some(accumulated) => match v1_rt::map_get(&m, name.clone()) { + std::option::Option::None => { v1_rt::rc_map_insert(m.clone(), name.clone(), accumulated.clone()) } - } - }, - }, - ) + Some(incoming) => { + if (incoming.clone() == accumulated.clone()) { + m.clone() + } else { + v1_rt::rc_map_insert(m.clone(), name.clone(), accumulated.clone()) + } + } + }, + } + }) } pub fn union_bool_set_skip_equal( @@ -1116,7 +1116,7 @@ pub fn segment_lcp_len(a: Rc>, b: Rc>) -> i64 { matched: 0, live: true, }), - |acc: Rc, seg: String| { + |acc: _, seg: String| { if acc.live.clone() { match acc.remaining.clone().first().cloned() { Some(bh) => { @@ -1182,7 +1182,7 @@ pub fn global_bare_nearest_ancestor_candidate( best: std::option::Option::None, tie: false, }), - |acc: Rc, cand: Rc| { + |acc: _, cand: Rc| { let l = segment_lcp_len( env_segs.clone(), crate::v1_std_core::module_path_segments(cand.module_path.clone()), @@ -1393,7 +1393,7 @@ pub fn borrowed_generic_param_names( ) -> Rc> { params.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, p: Rc| { + |acc: _, p: Rc| { let pt = crate::v1_std_core::param_node_type_expr(p.clone()); let pname = crate::v1_std_core::param_node_name_at(p.clone(), source_indices.clone()); let tname = crate::v1_std_core::authored_name_at(source_indices.clone(), pt.clone()); diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index b19362c8046..dc2083e3a1b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -159,7 +159,7 @@ pub fn collect_typed_service_calls_into( }; let result = texpr.children.clone().iter().cloned().fold( this_acc.clone(), - |a: Rc, child: Rc| { + |a: _, child: Rc| { collect_typed_service_calls_into(child.clone(), a, source_indices.clone()) }, ); @@ -190,7 +190,7 @@ pub fn collect_called_func_names_into( }; let result = texpr.children.clone().iter().cloned().fold( this_acc.clone(), - |a: Rc, child: Rc| { + |a: _, child: Rc| { collect_called_func_names_into(child.clone(), a, source_indices.clone()) }, ); @@ -275,7 +275,7 @@ pub fn expand_transitive_services_once( module_callees: Rc>>, registry: Rc>>, ) -> Rc>> { - module_callees.iter().cloned().fold(registry.clone(), |reg: Rc>>, m: Rc| m.items.clone().iter().cloned().fold(reg, |reg2: Rc>>, entry: Rc| { + module_callees.iter().cloned().fold(registry.clone(), |reg: _, m: _| m.items.clone().iter().cloned().fold(reg, |reg2: _, entry: _| { let item_name = entry.item_name.clone(); match v1_rt::map_get(®2, item_name.clone()) { Some(info) => { @@ -321,7 +321,7 @@ pub fn total_service_count(registry: Rc>>) -> i64 { Rc::new(v1_rt::map_values(®istry)) .iter() .cloned() - .fold(0, |acc: i64, info: Rc| { + .fold(0, |acc: i64, info: _| { (acc + (info.service_names.clone().len() as i64)) }) } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 0f27beb9509..4b66a476605 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -87,7 +87,7 @@ pub fn flatten_parent_envs( seen: v1_rt::rc_empty_map::(), out: Rc::new(vec![]), }), - |acc: Rc, p: Rc| { + |acc: _, p: Rc| { if crate::v1_compiler_infer_types::emit_map_has(acc.seen.clone(), p.name.clone()) { acc.clone() } else { @@ -227,27 +227,28 @@ pub fn parent_closure_callable_candidates( env: Rc, name: String, ) -> Rc>> { - env.parents.clone().iter().cloned().fold( - Rc::new(vec![]), - |acc: Rc>>, p: Rc| match v1_rt::map_get( - &p.local.clone(), - name.clone(), - ) { - Some(sig) => v1_rt::concat( - acc.clone(), - Rc::new(vec![Rc::new(CallableCandidate { - identity: Rc::new(CallableIdentity::DeclaredCallable { - identity: Rc::new(DeclaredCallableIdentity { - owner_module_path: p.name.clone(), - decl_name: name.clone(), + env.parents + .clone() + .iter() + .cloned() + .fold( + Rc::new(vec![]), + |acc: _, p: Rc| match v1_rt::map_get(&p.local.clone(), name.clone()) { + Some(sig) => v1_rt::concat( + acc.clone(), + Rc::new(vec![Rc::new(CallableCandidate { + identity: Rc::new(CallableIdentity::DeclaredCallable { + identity: Rc::new(DeclaredCallableIdentity { + owner_module_path: p.name.clone(), + decl_name: name.clone(), + }), }), - }), - sig: sig.clone(), - })]), - ), - std::option::Option::None => acc.clone(), - }, - ) + sig: sig.clone(), + })]), + ), + std::option::Option::None => acc.clone(), + }, + ) } pub fn decide_callable_candidates(candidates: Rc>>) -> Rc { @@ -306,10 +307,7 @@ pub fn lookup_resolved_sig_with_telemetry( match_count: 0, first_parent: std::option::Option::None, }), - |acc: Rc, p: Rc| match v1_rt::map_get( - &p.local.clone(), - name.clone(), - ) { + |acc: _, p: Rc| match v1_rt::map_get(&p.local.clone(), name.clone()) { Some(sig) => Rc::new(ParentSigScan { sig: if (acc.sig.clone() != std::option::Option::None) { acc.sig.clone() @@ -369,17 +367,15 @@ pub fn lookup_resolved_sig(env: Rc, name: String) -> Rc>, p: Rc| { - match acc.clone() { - Some(found) => Some(found.clone()), - std::option::Option::None => { - match v1_rt::map_get(&p.local.clone(), name.clone()) { - Some(sig) => Some(Rc::new(ResolvedSigWithOwner { - sig: sig.clone(), - owner_module_path: p.name.clone(), - })), - std::option::Option::None => std::option::Option::None, - } + |acc: _, p: Rc| match acc.clone() { + Some(found) => Some(found.clone()), + std::option::Option::None => { + match v1_rt::map_get(&p.local.clone(), name.clone()) { + Some(sig) => Some(Rc::new(ResolvedSigWithOwner { + sig: sig.clone(), + owner_module_path: p.name.clone(), + })), + std::option::Option::None => std::option::Option::None, } } }, @@ -534,9 +530,7 @@ pub fn func_reaches_self( pub fn build_name_set(names: Rc>) -> Rc> { names.iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - v1_rt::rc_map_insert(acc, name.clone(), true) - }, + |acc: _, name: String| v1_rt::rc_map_insert(acc, name.clone(), true), ) } @@ -558,20 +552,17 @@ pub fn merge_remaining_declared( Rc::new(v1_rt::map_values(&declared_sigs)) .iter() .cloned() - .fold( - resolved.clone(), - |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != std::option::Option::None) { - v1_rt::rc_map_insert( - acc.clone(), - dsig.name.clone(), - declared_to_resolved(dsig.clone()), - ) - } else { - acc.clone() - } - }, - ) + .fold(resolved.clone(), |acc: _, dsig: Rc| { + if (dsig.inferred.clone() != std::option::Option::None) { + v1_rt::rc_map_insert( + acc.clone(), + dsig.name.clone(), + declared_to_resolved(dsig.clone()), + ) + } else { + acc.clone() + } + }) } pub fn topo_resolve_loop( @@ -591,21 +582,17 @@ pub fn topo_resolve_loop( let all_resolved = Rc::new(v1_rt::map_values(&declared_sigs)) .iter() .cloned() - .fold( - resolved.clone(), - |acc: Rc>>, - dsig: Rc| { - if (dsig.inferred.clone() != std::option::Option::None) { - v1_rt::rc_map_insert( - acc.clone(), - dsig.name.clone(), - declared_to_resolved(dsig.clone()), - ) - } else { - acc.clone() - } - }, - ); + .fold(resolved.clone(), |acc: _, dsig: Rc| { + if (dsig.inferred.clone() != std::option::Option::None) { + v1_rt::rc_map_insert( + acc.clone(), + dsig.name.clone(), + declared_to_resolved(dsig.clone()), + ) + } else { + acc.clone() + } + }); return Rc::new(ResolveFuncSigsResult { func_env: Rc::new(ResolvedFuncEnv { name: module_name.clone(), @@ -676,10 +663,8 @@ pub fn topo_resolve_loop( signatures: resolved.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, fn_name: String| match v1_rt::map_get( - &declared_sigs, - fn_name.clone(), - ) { + |acc: _, fn_name: String| match v1_rt::map_get(&declared_sigs, fn_name.clone()) + { Some(dsig) => { if (dsig.inferred.clone() != std::option::Option::None) { Rc::new(SigsAccum { @@ -715,8 +700,7 @@ pub fn topo_resolve_loop( .cloned() .fold( cycle_accum.signatures.clone(), - |acc: Rc>>, - dsig: Rc| { + |acc: _, dsig: Rc| { if (dsig.inferred.clone() != std::option::Option::None) { v1_rt::rc_map_insert( acc.clone(), @@ -746,10 +730,7 @@ pub fn topo_resolve_loop( signatures: resolved.clone(), diagnostics: diagnostics.clone(), }), - |acc: Rc, fn_name: String| match v1_rt::map_get( - &declared_sigs, - fn_name.clone(), - ) { + |acc: _, fn_name: String| match v1_rt::map_get(&declared_sigs, fn_name.clone()) { Some(dsig) => { if (dsig.inferred.clone() != std::option::Option::None) { Rc::new(SigsAccum { diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 9685edc7d7b..61d31997665 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -1094,7 +1094,7 @@ pub fn summarize_fold_acc_uses( } else { node.children.clone().iter().cloned().fold( empty_fold_acc_use_summary(), - |acc: Rc, child: Rc| { + |acc: _, child: Rc| { merge_fold_acc_use_summaries( acc, summarize_fold_acc_uses( @@ -1157,7 +1157,7 @@ pub fn summarize_fold_acc_uses( } _ => node.children.clone().iter().cloned().fold( empty_fold_acc_use_summary(), - |acc: Rc, child: Rc| { + |acc: _, child: Rc| { merge_fold_acc_use_summaries( acc, summarize_fold_acc_uses( diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 51f7bc52a99..09db17ddf74 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -2800,7 +2800,7 @@ pub fn stamp_parsed_node_list( ctx: ctx.clone(), err: std::option::Option::None, }), - |acc: Rc, node: Rc| { + |acc: _, node: Rc| { if has_err(acc.err.clone()) { acc.clone() } else { diff --git a/src/v1/stage0/src/v1_compiler_resolve.rs b/src/v1/stage0/src/v1_compiler_resolve.rs index 760b7c573c7..2fb806e3fa3 100644 --- a/src/v1/stage0/src/v1_compiler_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_resolve.rs @@ -144,7 +144,7 @@ pub fn resolve_modules_with_occurrence_transport( imports_by_name: v1_rt::rc_empty_map::>>>(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, m: Rc| { + |acc: _, m: Rc| { let acc = v1_rt::take_owned(acc); { let result = resolve_module_imports( @@ -612,7 +612,7 @@ pub fn check_duplicate_modules( seen_names: v1_rt::rc_empty_map::(), diagnostics: Rc::new(vec![]), }), - |state: Rc, m: Rc| { + |state: _, m: Rc| { let m_name = crate::v1_std_core::authored_name_at(source_indices.clone(), m.clone()); let is_dup = map_has(state.seen_names.clone(), m_name.clone()); @@ -661,7 +661,7 @@ pub fn check_duplicate_declarations( seen_names: v1_rt::rc_empty_map::(), diagnostics: Rc::new(vec![]), }), - |state: Rc, item: Rc| { + |state: _, item: Rc| { let item_name = crate::v1_std_core::authored_name_at(source_indices.clone(), item.clone()); if map_has(state.seen_names.clone(), item_name.clone()) { diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index 1168bcaa916..0a28c2b3913 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -909,7 +909,7 @@ pub fn stage0_crate_plan_outcome() -> Rc { crates: Rc::new(vec![]), }), }), - |acc: Rc, row: _| match (*acc).clone() { + |acc: _, row: _| match (*acc).clone() { Stage0CratePlanOutcome::Stage0CratePlanRefused { cause: cause, .. } => { Rc::new(Stage0CratePlanOutcome::Stage0CratePlanRefused { cause: cause.clone(), @@ -943,7 +943,7 @@ pub fn emit_stage0_crate_boundary_files_outcome( Rc::new(Stage0CrateBoundaryEmitOutcome::Stage0CrateBoundaryEmitOk { files: Rc::new(vec![]), }), - |acc: Rc, spec: Rc| match (*acc).clone() { + |acc: Rc, spec: _| match (*acc).clone() { Stage0CrateBoundaryEmitOutcome::Stage0CrateBoundaryEmitRefused { cause: cause, .. } => Rc::new(