crates.sage_test_harness.compile_tests.rustc_execution

Every inline fixture is checked by both Sage and the rustc binary paired with Sage’s embedded compiler and standard-library sysroot. There is no implicit skip or opt-out. rustc checks the same materialized src/lib.rs, files, edition, and host target as an ordinary library, with no test configuration or enabled features. It emits metadata only; fixture code is never executed. rustc checking is separate from dependency metadata loading and Sage query capture. Source errors in either compiler do not prevent running the other compiler. Missing executables, malformed compiler output, abnormal termination, and an exit status inconsistent with the reported errors fail preparation as infrastructure errors.

Read in specification context · design/crates/sage_test_harness/compile-tests.md

Implementation

Implemented crates/sage-test-harness/src/compile/rustc.rs:14–19

sage_test_harness::compile::rustc · lib:sage_test_harness

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.rustc_execution`
// {anchor}`crates.sage_test_harness.compile_tests.rustc_lints`
// {anchor}`crates.sage_test_harness.compile_tests.compiler_conditions`
// {anchor}`crates.sage_test_harness.compile_tests.edition`
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
pub(super) fn check(

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/mod.rs:137–142

sage_test_harness::compile · lib:sage_test_harness

#![allow(unused)]
fn main() {
        // {anchor}`crates.sage_test_harness.compile_tests.rustc_execution`
        // {anchor}`crates.sage_test_harness.compile_tests.compiler_conditions`
        // Run rustc independently even when Sage will report source errors.
        // Keep its result until Sage has also completed preparation; neither
        // compiler's diagnostic mismatch can reach expectation updates.
        let rustc_result = rustc::check(project.path(), &files, edition, &markers);

}

See more source ↗

Implemented crates/sage-host/src/metadata.rs:1–6

sage_host::metadata · lib:sage_host

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.rustc_execution`
// {anchor}`crates.sage_test_harness.compile_tests.dependencies`
// {anchor}`crates.sage_test_harness.compile_tests.production_execution`
// {anchor}`crates.sage_test_harness.compile_tests.edition`
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
use std::collections::{HashMap, HashSet};

}

See more source ↗

Tests and review

Indexed tests and the implementation-completeness and test-adequacy review; no test run is implied.

Implemented sage_test_harness::compile::rustc::execution_review_tests::missing_compiler_and_abnormal_or_inconsistent_output_fail_preparation

crates/sage-test-harness/src/compile/rustc.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_execution)]
    fn missing_compiler_and_abnormal_or_inconsistent_output_fail_preparation() {
        let dir = tempfile::tempdir().unwrap();
        assert!(
            execute(&mut Command::new(dir.path().join("missing-rustc")))
                .unwrap_err()
                .contains("rustc could not start")
        );
        let files = BTreeMap::from([("src/lib.rs".into(), "x".into())]);
        let error = serde_json::json!({"$message_type":"diagnostic", "level":"error",
            "message":"fixture error", "code":null, "spans":[], "children":[]})
        .to_string();
        for (status, stderr, stdout, expected) in [
            (0, error.as_bytes(), vec![], "abnormal or inconsistent exit"),
            (
                1 << 8,
                b"".as_slice(),
                vec![],
                "abnormal or inconsistent exit",
            ),
            (
                2 << 8,
                error.as_bytes(),
                vec![],
                "abnormal or inconsistent exit",
            ),
            (9, b"".as_slice(), vec![], "abnormal or inconsistent exit"),
            (0, b"not json".as_slice(), vec![], "invalid rustc JSON"),
            (0, b"\xff".as_slice(), vec![], "non-UTF-8"),
            (0, b"".as_slice(), vec![b'x'], "unexpected stdout"),
        ] {
            let output = Output {
                status: ExitStatus::from_raw(status),
                stdout,
                stderr: stderr.to_vec(),
            };
            let actual = validate_output(output, &files, &[]).unwrap_err();
            assert!(actual.contains(expected), "{actual}");
        }
        let success = Output {
            status: ExitStatus::from_raw(0),
            stdout: vec![],
            stderr: vec![],
        };
        validate_output(success, &files, &[]).unwrap();
    }
}

Conditional source: #[cfg(all(test, unix))]

See more source ↗

Implemented sage_test_harness::compile::rustc::tests::malformed_compiler_output_and_invalid_fixture_offsets_fail

crates/sage-test-harness/src/compile/rustc.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_execution)]
    fn malformed_compiler_output_and_invalid_fixture_offsets_fail() {
        let files = BTreeMap::from([("src/lib.rs".into(), "x".into())]);
        assert!(parse("not json", &files).is_err());
        assert!(parse("{}", &files).is_err());
        assert!(parse(&diagnostic(vec![span(0, 2, true)]).to_string(), &files).is_err());
        let mut diag = diagnostic(vec![span(0, 1, true)]);
        diag["level"] = json!("unexpected");
        assert!(parse(&diag.to_string(), &files).is_err());
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::compile::rustc::tests::pinned_rustc_checks_errors_editions_and_normal_library_configuration

crates/sage-test-harness/src/compile/rustc.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_execution)]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_lints)]
    fn pinned_rustc_checks_errors_editions_and_normal_library_configuration() {
        assert!(
            run("fn f() -> u8 { true }", "2024")
                .unwrap_err()
                .contains("0 markers, 1 diagnostics")
        );
        run("fn f() -> u8 { true } //# ERROR", "2024").unwrap();
        run("fn f() -> u8 { 256 } //# ERROR", "2024").unwrap(); // deny-by-default overflow survives quiet lint policy
        run("fn f<T: IntoFuture>() {}", "2024").unwrap();
        run("fn f<T: IntoFuture>() {} //# ERROR", "2021").unwrap();
        run("#[cfg(test)] fn f() -> u8 { true }\n#[cfg(feature = \"unexpected\")] fn g() -> u8 { true }", "2024").unwrap();
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::compile::rustc_execution_review_tests::both_compilers_report_source_errors_from_materialized_modules

crates/sage-test-harness/src/compile/mod.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_execution)]
    fn both_compilers_report_source_errors_from_materialized_modules() {
        let mut test = CompileTest::default();
        test.files(vec![
            ("src/lib.rs".into(), "mod child;".into()),
            ("src/child.rs".into(), "fn bad() -> u8 { true }".into()),
        ]);
        let error = test.prepare().unwrap_err();
        assert!(
            error.contains("Sage diagnostic markers do not match: 0 markers, 1 diagnostics"),
            "{error}"
        );
        assert!(
            error.contains("Rustc diagnostic markers do not match: 0 markers, 1 diagnostics"),
            "{error}"
        );
        assert!(error.contains("src/child.rs"), "{error}");
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::compile::rustc_tests::rustc_is_mandatory_and_warnings_can_be_enabled_in_source

crates/sage-test-harness/src/compile/mod.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_execution)]
    #[sage::test(crates.sage_test_harness.compile_tests.rustc_lints)]
    #[sage::test(crates.sage_test_harness.compile_tests.compiler_conditions)]
    fn rustc_is_mandatory_and_warnings_can_be_enabled_in_source() {
        let mut quiet = CompileTest::default();
        quiet.source("fn unused() {}\nfn nonSnakeCase() {}");
        quiet.prepare().unwrap();

        let mut missing = CompileTest::default();
        missing.source("#![warn(dead_code)]\nfn unused() {}");
        let error = missing.prepare().unwrap_err();
        assert!(
            error.contains("Rustc diagnostic markers do not match: 0 markers, 1 diagnostics"),
            "{error}"
        );

        let mut expected = CompileTest::default();
        expected.source("#![warn(dead_code)]\nfn unused() {} //# WARN if rustc");
        assert!(expected.prepare().unwrap().diagnostics.is_empty());

        let mut denied = CompileTest::default();
        denied.source("#![deny(dead_code)]\nfn unused() {} //# ERROR if rustc");
        denied.prepare().unwrap();
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Review: Accepted · Codex anchor_021 refresh.

Fresh source review of crates.sage_test_harness.compile_tests.rustc_execution using the current start inputs, not the previous verdict. All three ordinary implementation associations and all five annotated test functions were examined. There are no TODO or N/A entries.

Mandatory checking and common inputs: CompileTest has files, edition, observations, diagnostics and queries fields, with no compiler skip option. prepare validates and materializes all files and a minimal dependency-free Cargo manifest, then unconditionally calls rustc::check with that same project, files, edition and markers. The rustc command reads src/lib.rs in that project as crate-type lib. It specifies the selected edition, emits fixture.rmeta with --emit=metadata, and supplies the pinned sysroot; it adds neither --test nor feature cfgs nor a target override. This checks an ordinary library for the compiler host and does not run fixture code. metadata.rs obtains host cfgs from the same compiler. our_sysroot reads the build-time SAGE_SYSROOT and our_rustc derives its bin/rustc path. Captured build.rs obtains and embeds the toolchain sysroot, so the binary and standard library are paired with the host compiler. Metadata-only execution and compiler identity are directly established by the fixed command construction and captured helpers.

Separation and failures: rustc_result is retained while SageHost opens and observe::collect checks the source. Both results are combined only afterward, preserving both source failures. metadata loading returns without compiling the selected crate when direct dependencies are empty, which applies to the generated fixture manifest. The rustc process executes before Sage context capture; prepare clears setup inspection events and observe::collect obtains the Sage check events, so rustc diagnostics checking is separate from dependency metadata and query capture. execute returns a preparation error if spawning fails. validate_output rejects invalid UTF-8 stderr and unexpected stdout, then parses diagnostics and accepts only exit 0 without errors or exit 1 with errors; signals, other exits and inconsistent error/status combinations fail. parse rejects invalid JSON, unexpected record shape/level and malformed fixture spans. quiet_lints also propagates failed compiler startup/inventory errors. Preparation errors cannot reach expectation assertions.

Complete associated test set: (1) pinned_rustc_checks_errors_editions_and_normal_library_configuration asserts an unmarked type error fails, marked type/overflow errors succeed, IntoFuture differs between editions 2024 and 2021, and erroneous test/feature-gated bodies remain disabled. These assertions detect absent rustc checking or accidental test/feature configuration. (2) rustc_is_mandatory_and_warnings_can_be_enabled_in_source asserts quiet ordinary fixtures succeed, an unmarked rustc warning makes prepare fail, a qualified warning succeeds with empty Sage diagnostics, and a qualified deny error succeeds. Thus independent rustc checking is mandatory even when Sage emits no diagnostic. (3) both_compilers_report_source_errors_from_materialized_modules asserts both compiler mismatch messages and the child path for one invalid materialized child module; an early source-error return or omitted child compilation would violate those assertions. (4) malformed_compiler_output_and_invalid_fixture_offsets_fail explicitly rejects non-JSON, empty objects, out-of-range offsets and unsupported diagnostic levels. (5) missing_compiler_and_abnormal_or_inconsistent_output_fail_preparation asserts startup failure on a nonexistent path and validates synthetic outputs for success-with-errors, error-exit-without-errors, unexpected exit 2, signal termination, invalid JSON, invalid UTF-8 and unexpected stdout, plus an accepted empty success control. This last test is Unix-gated because raw signal/status encodings use ExitStatusExt; the remaining associated tests are ordinary cfg(test) tests. Real negative source cases cover the accepted exit 1/error combination. Assertions and fixture setup are visible in the tests; the captured parser/matcher helpers explain their error-count expectations.

Additional dependencies were captured with review read: sage-host/build.rs, annotations.rs parser/compiler selection, and observe.rs collection and matching regions. Current metadata.rs and rustc.rs whole-file inputs contain the remaining execution helpers. No source edits or new behavioral concerns arose in this refresh. This is a source and test-adequacy assessment only: I ran review start/read/record, not behavior tests or a build in this refresh. Root is responsible for centrally running relevant suites under the captured coordinator instructions.

Browse crates anchors

139 anchors

Specification anchors and declared coverage
AnchorImplementationTests
crates (139)114 Implemented37 TODO2 N/A74 Implemented107 TODO
crates.sage_inspector (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
crates.sage_inspector.inspection (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
balanced_tracesImplementedTODO
canonical_ownershipImplementedImplementedTODO
derive_reflectionImplementedImplementedTODO
detail_free_indexImplementedTODO
deterministic_traceImplementedTODO
durable_navigationN/ATODO
generic_browserN/ATODO
owned_reflectionImplementedImplementedTODO
product_availabilityImplementedTODO
revision_and_demandImplementedTODO
semantic_phase_boundaryImplementedTODO
source_evidenceImplementedTODO
typed_serviceImplementedTODO
unknown_workImplementedTODOTODO
workspace_actorImplementedTODO
crates.sage_ir (90)67 Implemented34 TODO40 Implemented88 TODO
crates.sage_ir.checking (12)12 Implemented3 TODO5 Implemented12 TODO
crates.sage_ir.checking.body (5)5 Implemented2 TODO3 Implemented5 TODO
elaborationImplementedImplementedTODO
expected_typesImplementedTODOTODO
interface_dependenciesImplementedImplementedTODO
isolated_completionImplementedImplementedTODO
operator_callsImplementedTODOTODO
identity_mintingImplementedTODO
owned_productsImplementedImplementedTODO
crates.sage_ir.checking.signature (4)4 Implemented1 TODO1 Implemented4 TODO
body_independenceImplementedTODO
narrow_detailImplementedTODOTODO
owner_binderImplementedImplementedTODO
storageImplementedTODO
symbol_keyed_interfacesImplementedTODO
crates.sage_ir.crate (9)9 TODO9 TODO
explicit_restrictionsTODOTODO
identity_before_detailTODOTODO
incremental_evidenceTODOTODO
narrow_demandsTODOTODO
reexecution_and_invalidationTODOTODO
represented_completenessTODOTODO
restrictions_and_gapsTODOTODO
semantic_query_boundariesTODOTODO
terminal_incompletenessTODOTODO
crates.sage_ir.inference (8)8 Implemented6 Implemented8 TODO
atomic_checkingImplementedImplementedTODO
body_local_quiescenceImplementedImplementedTODO
canonical_boundaryImplementedImplementedTODO
completed_body_boundaryImplementedTODO
numeric_domainsImplementedImplementedTODO
subtyping_and_coercionImplementedImplementedTODO
terminal_obligationsImplementedTODO
transaction_isolationImplementedImplementedTODO
crates.sage_ir.metadata (4)4 Implemented1 TODO4 TODO
explicit_incompletenessImplementedTODO
keyed_reuseImplementedTODOTODO
product_boundariesImplementedTODO
provider_authorityImplementedTODO
crates.sage_ir.modules (8)7 Implemented1 TODO4 Implemented8 TODO
crates.sage_ir.modules.expand (4)4 Implemented2 Implemented4 TODO
completenessImplementedImplementedTODO
dependenciesImplementedTODO
direct_membersImplementedTODO
recursion_and_fixpointImplementedImplementedTODO
crates.sage_ir.modules.parse (4)3 Implemented1 TODO2 Implemented4 TODO
dependenciesImplementedTODO
detail_firewallImplementedImplementedTODO
recovery_completenessTODOTODO
syntax_identitiesImplementedImplementedTODO
crates.sage_ir.resolution (5)5 Implemented1 TODO3 Implemented4 TODO
crates.sage_ir.resolution.lookup (5)5 Implemented1 TODO3 Implemented4 TODO
completenessImplementedTODOImplementedTODO
dependenciesImplementedTODO
expansion_import_ambiguityImplementedImplemented
identity_onlyImplementedTODO
precedenceImplementedImplementedTODO
crates.sage_ir.solver (9)7 Implemented7 TODO5 Implemented9 TODO
alternative_isolationImplementedTODOImplementedTODO
bounded_completenessImplementedTODOTODO
candidate_completenessImplementedTODO
canonical_cyclesTODOTODO
canonical_outputsImplementedImplementedTODO
local_index_firewallTODOTODO
normalization_demandImplementedTODOImplementedTODO
schedule_independenceImplementedTODOImplementedTODO
shared_final_resultImplementedTODOImplementedTODO
crates.sage_ir.symbols (8)8 Implemented4 Implemented7 TODO
associated_identityImplementedImplemented
associated_interfacesImplementedTODO
body_interfacesImplementedImplementedTODO
definition_identityImplementedTODO
external_fact_queriesImplementedTODO
external_identityImplementedTODO
kind_wrappersImplementedImplementedTODO
local_identityImplementedImplementedTODO
crates.sage_ir.types (27)16 Implemented12 TODO13 Implemented27 TODO
crates.sage_ir.types.aliases (2)1 Implemented1 TODO1 Implemented2 TODO
identityImplementedImplementedTODO
revelationTODOTODO
crates.sage_ir.types.binder (1)1 Implemented1 TODO1 Implemented1 TODO
owner_parametersImplementedTODOImplementedTODO
crates.sage_ir.types.body (13)4 Implemented9 TODO3 Implemented13 TODO
awaitTODOTODO
closuresTODOTODO
conditional_patternsTODOTODO
coroutinesTODOTODO
diagnosed_recoveryImplementedImplementedTODO
elaboratedTODOImplementedTODO
for_iterationTODOTODO
indexingTODOTODO
macro_expansionTODOTODO
no_inferenceImplementedImplementedTODO
resolved_referencesImplementedTODO
try_residualTODOTODO
typed_provenanceImplementedTODO
crates.sage_ir.types.calls (2)1 Implemented1 TODO1 Implemented2 TODO
dispatch_familiesTODOTODO
selected_semanticsImplementedImplementedTODO
crates.sage_ir.types.lifetimes (2)2 Implemented2 Implemented2 TODO
dummyImplementedImplementedTODO
unchecked_borrowsImplementedImplementedTODO
crates.sage_ir.types.operators (2)2 Implemented1 Implemented2 TODO
lazy_control_flowImplementedTODO
trait_callsImplementedImplementedTODO
scoped_identitiesImplementedTODO
crates.sage_ir.types.spans (4)4 Implemented4 Implemented4 TODO
generated_identityImplementedImplementedTODO
item_originImplementedImplementedTODO
offset_reuseImplementedImplementedTODO
relative_compositionImplementedImplementedTODO
crates.sage_oracle_harness (4)4 Implemented2 TODO1 Implemented4 TODO
crates.sage_oracle_harness.crate (4)4 Implemented2 TODO1 Implemented4 TODO
deterministic_emissionImplementedTODO
exact_comparisonImplementedTODOImplementedTODO
fixed_projectionImplementedTODO
independent_coverageImplementedTODOTODO
crates.sage_stash (5)5 Implemented5 Implemented
crates.sage_stash.storage (5)5 Implemented5 Implemented
handle_ownershipImplementedImplemented
immutable_entriesImplementedImplemented
query_valueImplementedImplemented
rooted_equalityImplementedImplemented
typed_interningImplementedImplemented
crates.sage_test_harness (25)25 Implemented25 Implemented
crates.sage_test_harness.compile_tests (25)25 Implemented25 Implemented
annotation_validationImplementedImplemented
blessing_gateImplementedImplemented
callsite_updatesImplementedImplemented
checking_scopeImplementedImplemented
compiler_conditionsImplementedImplemented
completed_typesImplementedImplemented
coordinatesImplementedImplemented
dependenciesImplementedImplemented
diagnostic_countsImplementedImplemented
diagnostic_locationsImplementedImplemented
editionImplementedImplemented
fixturesImplementedImplemented
grouped_observationsImplementedImplemented
invocationImplementedImplemented
production_executionImplementedImplemented
project_isolationImplementedImplemented
query_captureImplementedImplemented
query_projectionImplementedImplemented
renderingImplementedImplemented
resolved_symbolsImplementedImplemented
review_visibilityImplementedImplemented
rustc_executionImplementedImplemented
rustc_lintsImplementedImplemented
starting_expressionsImplementedImplemented
target_lineImplementedImplemented