Skip to content

chore - 1480 incan_ir and incan_emit are crates - #1577

Open
dannymeijer wants to merge 3 commits into
0.6.0-dev.5from
chore/1480-incan-ir-and-incan-emit-crates
Open

dannymeijer wants to merge 3 commits into
0.6.0-dev.5from
chore/1480-incan-ir-and-incan-emit-crates

Conversation

@dannymeijer

Copy link
Copy Markdown
Member

Summary

backend/ir splits along the line the measurement on #1480 drew. loaves/compiler/incan_ir is the IR and the lowering to it: lib.rs (the old ir/mod.rs with IrProgram, FunctionRegistry, the checked-C types), types, expr, stmt, decl, visit, surface_semantics, scanners, borrow_inference, lower/, and the IR-side numeric adapters — the analyses that read only the IR. loaves/compiler/incan_emit is everything that turns IR into Rust and everything built on conversions (2.7k lines that LAYOUT already put on the emit side): emit/, codegen, conversions, ownership, reference_shape, trait_bound_inference, emit_service, facade, prelude, the replacement backend (backend/replacement/) and backend selection (backend/selection.rs), plus the checked_program tests. The root keeps backend::ir as a shim module that re-exports both crates under their old paths, so crate::backend::ir::… in the driver, CLI and LSP and incan::backend::ir::… in tests/ keep resolving; backend::replacement and backend::selection re-export the same way.

One function crossed the line the wrong way and moves: manifest_type_ref_from_ir, the IR→manifest type projection, was in codegen but lowering needs it too, so it lives in incan_ir::types now. Five things the emit side reached in the root move below it: oven::compiler_suite_env (131 lines, std and serde only) and OVEN_LOAF_ENV become oven_model::compiler_suite_env; oven::{digest_bytes, digest_content} become oven_model::digest; SDK_PROVIDER_BUILD_ENV joins the frontend's provider contract; the root re-exports all of them under their old names. Tests that cross the cut move to the side that has everything they need: the four codegen tests that drive the project generator go to backend::project::tests::codegen_generator in the root, the two lowering tests that need an emission pass or plan to incan_emit::tests::lowering_through_emission, and the one executable-resolution test that needs a compilation session to driver::tests::executable_session. The codegen test helpers those root tests share become incan_emit::test_support behind a test_support feature, the pattern #1576 set; IrCodegen::{external_rust_functions, collect_external_rust_functions} become pub for the one moved test that reads them.

Facts the split carries, each fixed here:

  • A blanket pub(crate) → pub and the crate::provider:: rewrite reached into quote! bodies and assertion strings and changed generated Rust — ten codegen snapshots caught it. Every rewrite in the split script now skips string literals, comments and quote!/quote_spanned!/parse_quote! bodies, and the snapshots are byte-identical.
  • cargo test -p incan_emit runs from the crate directory: read_stdlib_program and the rust-inspect workspace a test points at CARGO_MANIFEST_DIR now anchor at oven_model::toolchain_layout::development_root(); include_str! of zen.txt and the include! of tests/support/canonical_projection.rs climb one more level.
  • cargo test -p <crate> sees no stdlib semantics packs unless the crate says so: incan_ir and incan_emit default to rust_inspect + std_* like the frontend does, and the root depends on both with default-features = false and forwards its own features.
  • Two integration tests #[path]-included src/oven/compiler_suite_env.rs; they use oven_model::compiler_suite_env now.
  • The semantic-string audit's roots and fixture entries follow the files; backend/replacement was never in its roots, so its 17 sites are classified for the first time. Five functions the rustdoc gate sees as new get the rustdoc they never had.

Type of change

  • Bug fix
  • New feature
  • Refactor / maintenance
  • Documentation
  • CI / tooling
  • RFC (adds/updates docs/RFCs/*)

Area(s)

  • Incan Language (syntax/semantics)
  • Compiler (frontend/backend/codegen)
  • Tooling (CLI/formatter/test runner)
  • Editor integration (LSP/VS Code extension)
  • Runtime / Core crates (stdlib/core/derive)
  • Documentation

Key details

  • User-facing behavior: none; codegen snapshots unchanged.
  • Internals: two new workspace members; incan_ir depends on the kernel crates, incan_frontend, oven_model and rust_inspect; incan_emit on those plus incan_ir, syn/quote/proc-macro2/prettyplease, sha2/hex, regex. Cargo.lock gains both.
  • Risks: the blanket pub is wider than the crates' eventual surface. backend/project/{generator,plan,lock_projection,cargo_toml,runner}.rs and backend/shadow stay in the root for the driver and Oven steps.

Testing / verification

  • cargo check -p incan in the six feature configurations; cargo clippy -p incan -p incan_ir -p incan_emit -p oven_model --all-targets default and --all-features with -D warnings; rustdoc gate last
  • cargo test -p incan_ir — 140 tests; cargo test -p incan_emit — 519 tests; cargo test -p oven_model — 121
  • cargo test --test codegen_snapshot_tests — 266 unchanged
  • cargo test --test cli_layering_guardrails --test vocab_guardrails --test layering_guard
  • root unit tests with the CLI built for backend::project::tests, driver::tests, backend, driver::build
  • make check-oven-ring
  • one exact Oven root: make test-one TEST_ROOT=tests/cli_surface_tests.rs TEST_EXACT=a_cargo_manifest_beside_a_loaf_manifest_warns_without_stopping_the_build

Docs impact

  • No docs changes needed (crate READMEs lose their "skeleton" line; the ring documentation is step 6)
  • Docs updated
  • Docs follow Divio intent (tutorial/how-to/reference/explanation) where applicable

Checklist

  • I kept public docs user-focused and moved internals to contributing docs when appropriate
  • I avoided duplicating canonical install/run instructions in multiple places
  • I added/updated tests where it materially reduces regressions

Part of #1480 (slice 5, #1478). Builds on #1576: the branch carries its commit, so the diff shows both steps until #1576 lands and a merge-commit sync narrows it to this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

incan compiler Suggestions, features, or bugs related to the Compiler (frontend/backend/codegen)

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant