crates.sage_test_harness.compile_tests.compiler_conditions

Both Sage and rustc run for every fixture. Unqualified ERROR/WARN markers apply independently to each compiler; if SAGE and if rustc apply only to the named compiler. Each compiler must have a complete one-to-one match against its applicable markers. One unqualified marker expects one diagnostic from each compiler, not two from either. rustc contributes diagnostic checks only, not observation, diagnostic-text, or query snapshots. Compiler-specific markers record intentional differences and require a semantic explanation when changed.

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

Implementation

Implemented crates/sage-test-harness/src/compile/annotations.rs:75–80

sage_test_harness::compile::annotations · lib:sage_test_harness

#![allow(unused)]
fn main() {
        // {anchor}`crates.sage_test_harness.compile_tests.compiler_conditions`
        let (kind, compiler) = match words.as_slice() {
            ["ty"] => (Kind::Type, Some(Compiler::Sage)),
            ["sym"] => (Kind::Symbol, Some(Compiler::Sage)),
            ["ERROR"] => (Kind::Error, None),
            ["ERROR", "if", "SAGE"] => (Kind::Error, Some(Compiler::Sage)),

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/observe.rs:4–9

sage_test_harness::compile::observe · lib:sage_test_harness

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.compiler_conditions`
// {anchor}`crates.sage_test_harness.compile_tests.fixtures`
use super::annotations::Compiler;
use super::types::FrozenType;
use super::{BTreeSet, Kind, Marker, Output};
use sage_host::driver::SageContext;

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/rustc.rs:16–21

sage_test_harness::compile::rustc · lib:sage_test_harness

#![allow(unused)]
fn main() {
// {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(
    project: &Path,
    files: &BTreeMap<String, String>,

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/mod.rs:138–143

sage_test_harness::compile · lib:sage_test_harness

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.

#![allow(unused)]
fn main() {
        // {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);
        let host = SageHost::try_open(project.path(), &[])?;

}

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::annotations::tests::only_real_line_comment_directives_are_interpreted

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.annotation_validation)]
    #[sage::test(crates.sage_test_harness.compile_tests.compiler_conditions)]
    #[sage::test(crates.sage_test_harness.compile_tests.target_line)]
    fn only_real_line_comment_directives_are_interpreted() {
        let markers = parse(
            "src/lib.rs",
            r##"fn f() { let s = r#"//# invalid"#; /* //# invalid */ }"##,
        )
        .unwrap();
        assert!(markers.is_empty());
        for bad in [
            "//# ty",
            "//# sym",
            "fn f() {} //# sym[slug]",
            "fn f() {} //# sym if SAGE",
            "fn f() {} //# ERROR[SAGE]",
            "fn f() {} //# ERROR if sage",
            "fn f() {} //# ty[slug]",
            "fn f() {} //# WARN if other",
        ] {
            assert!(parse("src/lib.rs", bad).is_err(), "{bad}");
        }
        assert_eq!(
            parse("src/lib.rs", "fn café() {} //# ty").unwrap()[0].line,
            1
        );
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::compile::compiler_conditions_review_tests::compiler_qualifiers_and_shared_counts_are_independent

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.compiler_conditions)]
    fn compiler_qualifiers_and_shared_counts_are_independent() {
        for (kind, severity) in [("ERROR", Severity::Error), ("WARN", Severity::Warning)] {
            for qualifier in ["", " if SAGE", " if rustc"] {
                let source = format!("fn f() {{}} //# {kind}{qualifier}");
                let markers = annotations::parse("src/lib.rs", &source).unwrap();
                let diagnostic = DiagnosticSnapshot {
                    severity: severity.clone(),
                    primary: vec![SourceLocation {
                        path: "src/lib.rs".into(),
                        source: source.clone(),
                        start: 0,
                        end: 1,
                    }],
                    message: "fixture diagnostic".into(),
                    labels: vec![],
                    notes: vec![],
                };
                for compiler in [Compiler::Sage, Compiler::Rustc] {
                    let applies = qualifier.is_empty()
                        || (qualifier == " if SAGE" && compiler == Compiler::Sage)
                        || (qualifier == " if rustc" && compiler == Compiler::Rustc);
                    assert_eq!(
                        observe::match_compiler_diagnostics(compiler, &markers, &[]).is_ok(),
                        !applies,
                    );
                    assert_eq!(
                        observe::match_compiler_diagnostics(
                            compiler,
                            &markers,
                            std::slice::from_ref(&diagnostic),
                        )
                        .is_ok(),
                        applies,
                    );
                    assert!(
                        observe::match_compiler_diagnostics(
                            compiler,
                            &markers,
                            &[diagnostic.clone(), diagnostic.clone()],
                        )
                        .is_err()
                    );
                }
            }
        }
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::compile::coordinate_review_tests::evaluated_source_retains_blank_lines_indentation_and_unicode

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.coordinates)]
    #[sage::test(crates.sage_test_harness.compile_tests.compiler_conditions)]
    #[sage::test(crates.sage_test_harness.compile_tests.rendering)]
    fn evaluated_source_retains_blank_lines_indentation_and_unicode() {
        let mut test = CompileTest::default();
        // Leading blank line and indentation are intentional fixture contents.
        // Both compilers must match the same physical line after the Unicode name.
        test.source("\n    fn café() -> u8 {\n        true //# ERROR\n    }\n");
        test.diagnostics(expect_test::expect![""]);
        let output = test.prepare().unwrap();
        assert!(
            output.diagnostics.contains("src/lib.rs:2:"),
            "{}",
            output.diagnostics
        );
        assert!(
            output.diagnostics.contains("2 |       fn café()"),
            "{}",
            output.diagnostics
        );
        assert!(
            output.diagnostics.contains("3 | |         true //# ERROR"),
            "{}",
            output.diagnostics
        );
    }
}

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 ↗

Implemented sage_test_harness::compile::rustc_tests::shared_markers_must_match_both_compilers

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.compiler_conditions)]
    fn shared_markers_must_match_both_compilers() {
        let mut test = CompileTest::default();
        test.source("#![warn(dead_code)]\nfn unused() {} //# WARN");
        let error = test.prepare().unwrap_err();
        assert!(
            error.contains("Sage diagnostic markers do not match: 1 markers, 0 diagnostics"),
            "{error}"
        );
        let mut test = CompileTest::default();
        test.source("fn unused() {} //# ERROR if rustc");
        let error = test.prepare().unwrap_err();
        assert!(
            error.contains("Rustc diagnostic markers do not match: 1 markers, 0 diagnostics"),
            "{error}"
        );
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::explicit_edition_and_rustc_warning_marker

crates/sage-test-harness/tests/compile_tests.rs · test:compile_tests

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.compiler_conditions)]
#[sage::test(crates.sage_test_harness.compile_tests.edition)]
fn explicit_edition_and_rustc_warning_marker() {
    compile_test! {
        diagnostics: expect![""],
        edition: "2021",
        source: "#[warn(dead_code)] fn example() {} //# WARN if rustc",
    }
}
}

See more source ↗

Review: Accepted · Codex anchor_004 final CI refresh.

Fresh source assessment of compiler_conditions: all four ordinary implementation entries and all six ordinary associated tests are accounted for; no TODO/N/A evidence is present. The claim requires both compilers to run, independent unconditional and qualified ERROR/WARN matching, exhaustive one-to-one matching per compiler, no pooling two diagnostics against one shared marker, Sage-only snapshots, and semantic justification for compiler-condition edits.

The annotations implementation parses both severities with exactly the three allowed qualification choices, and applies_to admits unqualified markers to either compiler while restricting qualified markers. mod.rs materializes a valid fixture, executes rustc::check without propagating its result early, then opens Sage and calls observe::collect. Combining both results requires both checks to succeed. Setup-invalid fixtures are rejected before compilation; source diagnostic failures do not suppress the other compiler. observe::match_compiler_diagnostics independently filters the marker set for its compiler, matches severity and location, finds an injective assignment with augmenting paths, and rejects any unmatched marker or diagnostic. rustc::check now delegates process execution and output validation to execute/validate_output; these preserve the Rustc selector and return only unit on success. Consequently rustc text cannot enter Output: the observations, rendered diagnostics, and query trace are constructed entirely by Sage collection. The contribution instructions captured separately require semantic explanation and diagnostic investigation before changing markers; this is an authoring/review requirement, not a runtime ability to infer intent.

The complete associated test set provides: (1) only_real_line_comment_directives_are_interpreted rejects unknown, incorrectly cased, and alternate condition syntax while excluding string and block-comment lookalikes; (2) compiler_qualifiers_and_shared_counts_are_independent parses ERROR and WARN with no condition, SAGE, and rustc, then verifies zero/one/two diagnostic outcomes for each compiler, demonstrating both restricted applicability and independent counts; (3) evaluated_source_retains_blank_lines_indentation_and_unicode supplies one shared ERROR to a real source type mismatch, successfully prepares both compilers, and asserts the Sage diagnostic source text; (4) rustc_is_mandatory_and_warnings_can_be_enabled_in_source checks quiet dead-code and naming lints, rejects an unmarked rustc warning, accepts the qualified warning while asserting empty Sage diagnostic text, and accepts a qualified deny-lint error; (5) shared_markers_must_match_both_compilers explicitly rejects a shared warning missing from Sage and a qualified rustc error missing from rustc; (6) explicit_edition_and_rustc_warning_marker drives the public macro and asserts an empty diagnostic snapshot despite the matched rustc warning. The matrix would detect treating SAGE as rustc, accepting two diagnostics for a shared marker, or requiring a nonselected marker; the integration assertions would detect bypassing mandatory rustc or applying shared markers only to rustc. The unit-return boundary and Sage-only output construction also substantiate isolation of observations and queries.

Final shared-file assertion edits were inspected: the unrelated missing/unselected diagnostic tests now require the Sage diagnostic prefix, improving their specificity without changing this anchor's execution or selection semantics. No source changes were made during this refresh. This is a source review, not a claim that I ran tests on the final snapshot; root centrally executes suites. I ran review start/read/record for this anchor. No behavioral violation or missing evidence requiring edits was identified.

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