crates.sage_test_harness.compile_tests.target_line

For every directive, non-whitespace source content before the annotation comment makes its target the current line. Otherwise its target is the most recent preceding nonempty line that is not an annotation-only line. Blank lines and consecutive annotation-only lines are skipped; ordinary comments are not skipped. Absence of a target is an annotation error. The same rule applies to ty, sym, ERROR, and WARN; there is no caret or range syntax.

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

Implementation

Implemented crates/sage-test-harness/src/compile/annotations.rs:92–97

sage_test_harness::compile::annotations · lib:sage_test_harness

#![allow(unused)]
fn main() {
        // {anchor}`crates.sage_test_harness.compile_tests.target_line`
        let target = if !lines[row][..column].trim().is_empty() {
            Some(row)
        } else {
            (0..row)
                .rev()

}

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::all_directives_share_targets_and_reject_caret_and_range_syntax

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.target_line)]
    fn all_directives_share_targets_and_reject_caret_and_range_syntax() {
        for directive in ["ty", "sym", "ERROR", "WARN"] {
            let source = format!(
                "fn f() {{\n    value; //# {directive}\n\n    //# {directive}\n    //# {directive}\n}}"
            );
            let markers = parse("src/lib.rs", &source).unwrap();
            assert_eq!(
                markers.iter().map(|marker| marker.line).collect::<Vec<_>>(),
                vec![2, 2, 2],
                "{directive}"
            );
            assert!(
                parse("src/lib.rs", &format!("\n  //# {directive}"))
                    .unwrap_err()
                    .contains("annotation has no target"),
                "{directive}"
            );
            for suffix in ["^", "1..2"] {
                assert!(
                    parse(
                        "src/lib.rs",
                        &format!("fn f() {{}} //# {directive} {suffix}")
                    )
                    .unwrap_err()
                    .contains("malformed directive"),
                    "{directive} {suffix}"
                );
            }
        }
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::compile::annotations::tests::inline_stacked_and_blank_lines_use_one_rule

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.target_line)]
    #[sage::test(crates.sage_test_harness.compile_tests.coordinates)]
    fn inline_stacked_and_blank_lines_use_one_rule() {
        let markers = parse("src/lib.rs", "fn f() {\n    22; //# ty\n\n    //# ERROR\n    //# WARN\n    // ordinary comment\n    //# ERROR if rustc\n}").unwrap();
        assert_eq!(
            markers.iter().map(|m| m.line).collect::<Vec<_>>(),
            vec![2, 2, 2, 6]
        );
        assert!(!markers[3].applies_to(Compiler::Sage));
        assert!(markers[3].applies_to(Compiler::Rustc));
        assert!(
            parse("src/lib.rs", "fn f() {\t}")
                .unwrap_err()
                .contains("tabs")
        );
    }
}

Conditional source: #[cfg(test)]

See more source ↗

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 ↗

Review: Accepted · Codex subagent anchor_024.

Fresh review after adding target-line coverage: read the complete claim, the whole annotations.rs implementation, and all three associated tests printed by review start. The sole implementation association and all tests are ordinary; there are no TODO/N/A entries. All relevant helpers (tree construction, comment traversal, prefix classification, directive validation, target selection) are in the captured implementation file, so no additional production association is needed.

Implementation satisfies each requirement: real line comments yield byte-column prefixes; a non-whitespace prefix selects the current row. Otherwise reverse search selects the nearest preceding nonempty row outside annotation_only, skipping blank and consecutive annotation-only rows while retaining ordinary comments. No candidate produces an annotation-has-no-target error. All four kinds and conditional diagnostic forms pass through the same selection code and emit one-based target lines. Exact directive matching permits no caret/range arguments.

Test adequacy: all_directives_share_targets_and_reject_caret_and_range_syntax loops explicitly over ty, sym, ERROR, and WARN. Its visible source contains an inline marker, a blank row, and consecutive annotation-only markers; the asserted [2,2,2] verifies current-row selection and nearest-eligible backward selection for all four kinds. It separately checks the specific no-target error following leading blank/whitespace for each kind, and the specific malformed-directive error for caret and range suffixes for each kind. inline_stacked_and_blank_lines_use_one_rule asserts [2,2,2,6], additionally proving mixed marker kinds share selection and an ordinary comment is retained as the nearest target for a compiler-qualified ERROR. Its applies_to and tab checks are collateral assertions. only_real_line_comment_directives_are_interpreted rejects targetless ty/sym and malformed spellings, ignores string/block-comment lookalikes, and asserts an inline UTF-8 source target remains line 1. Together these tests cover every qualification in the claim and visibly assert expected outputs rather than relying on opaque verification helpers. No production defect or remaining coverage gap was identified.

Executed cargo fmt successfully and cargo test -p sage-test-harness --lib compile::annotations::tests: all three tests passed, zero failures (139 filtered out); existing sage-ir compiler warnings were emitted. Also executed fresh review start and review read of the review_scope claim. Workspace build and broader post-codegen/sanity checks are delegated to the coordinator and are not claimed as executed here.

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