Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 159 additions & 4 deletions dag/gunbc/emitted_closure_compile_seed_growth.dag

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions fixtures/fixture_closure_rustc/green_probe.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module fixture.closure.rustc_green_probe

// The positive control for the fixture-callable emitted-crate compilation route
// (v1_compiler.emitted_closure_compile_host fixture_closure_rustc_verdict). No imports, so its
// emitted closure is its own module plus the runtime -- the smallest subject that still proves
// the crate writer, the manifest and the emitter reached a crate rustc accepts. Without it the
// red arm beside it could pass for a reason that has nothing to do with its fixture.
data rustc_green_probe_value: Int = 424242
26 changes: 26 additions & 0 deletions fixtures/fixture_closure_rustc/text_nonliteral_probe.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module fixture.closure.rustc_text_nonliteral_probe

import v2.std.text { string_is_empty }

// The MEANING-LEVEL red arm, and the fixture gunbc.rung_drop text_boundary_identity_wall names.
// `concat` answers the kernel string; the return boundary declares the structural
// v2.std.text.String; no homomorphism row stands between them, and the corpus-wide compatibility
// relation admits the pairing by leaf-name spelling. A substring oracle over the emitted text
// cannot see this -- the emitted bytes contain every substring a spelling assertion would look
// for -- which is why the subject needs rustc rather than a text check.
//
// THE IMPORT ABOVE IS LOAD-BEARING AND MUST NOT BE DELETED AS UNUSED. It binds a name this module
// never mentions again, so every reader -- and review 58161, which is why this note exists -- sees
// dead weight. It is the opposite: `v1_compiler.cli_run` `resolve_virtual_source_with_imports`
// builds this fixture's source set ONLY by following import statements transitively, so the import
// is the single mechanism that puts v2.std.text into the resolved closure at all. Without it the
// qualified return type has nothing to resolve against.
//
// MEASURED RATHER THAN ASSERTED, by running the route on this file with the import stripped:
// WITHOUT IMPORT => SourceRefused hard=1
// UnresolvedType { name: "v2.std.text.String" } | reached_rustc=false
// So deleting it does not tidy the fixture; it converts the red arm from a RUSTC VERDICT into a
// GUNBC REFUSAL and destroys the discrimination, while looking like cleanup. The pair does go red
// if anyone does it -- `fixture_closure_reached_rustc` refuses to count an arm that never reached
// rustc -- so the wall holds; this note exists so the wall is not hit in the first place.
fn rustc_text_nonliteral_probe() -> v2.std.text.String { concat("x", "y") }
44 changes: 44 additions & 0 deletions src/v1/compiler_tests_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,49 @@ fn ct_parse_tests() -> String {
" }\n\n")
}

fn ct_fixture_closure_rustc_discrimination_test() -> String {
concat(
" /// THE EMITTED CLOSURE, HANDED TO RUSTC, OVER FIXTURES A TEST CAN AUTHOR.\n",
" ///\n",
" /// Every other emitted-bytes assertion in this file is a SPELLING oracle: it reads the\n",
" /// emitted text and asserts on substrings. A meaning-level emitter defect is invisible to\n",
" /// that whenever the wrong bytes still contain the right substring -- and it is exactly\n",
" /// what rustc's type checker refuses. This arm is the one that asks rustc.\n",
" ///\n",
" /// THE PAIR IS THE SUBJECT, NOT EITHER ARM. The control must COMPILE, or a red below\n",
" /// proves only that something in the tree is broken. The red must be refused BY RUSTC and\n",
" /// ATTRIBUTED to the fixture's own emitted module, or a non-zero status from any of the\n",
" /// hundreds of modules in its closure would pass for the fixture's own defect.\n",
" ///\n",
" /// #[ignore] AND WHY, STATED RATHER THAN LEFT TO BE DISCOVERED: this arm spawns cargo and\n",
" /// compiles two emitted crates, which is minutes rather than milliseconds, and\n",
" /// `repo_self_test_command` runs the whole --lib suite on every push and pull request. It\n",
" /// is therefore ENROLLED AND OPT-IN: `cargo test --release -p v1-compiler --lib\n",
" /// fixture_closure_rustc_discrimination -- --ignored`. An #[ignore] is a cost decision and\n",
" /// NOT a rung: nothing here may be cited as coverage that executes on the merge path.\n",
" #[test]\n",
" #[ignore]\n",
" fn fixture_closure_rustc_discrimination() {\n",
" let probe_root = crate::cli_run::local_emit_compile_probe_root();\n",
" let pair = crate::cli_run::run_fixture_closure_discrimination(&probe_root);\n",
" for line in crate::cli_run::fixture_discrimination_report(&pair) {\n",
" eprintln!(\"{}\", line);\n",
" }\n",
" assert!(\n",
" crate::cli_run::fixture_closure_reached_rustc(&pair.red),\n",
" \"the red arm never reached a rustc verdict, so nothing about the emitted bytes was measured: {}\",\n",
" crate::cli_run::fixture_closure_summary(&pair.red)\n",
" );\n",
" assert!(\n",
" crate::cli_run::fixture_discrimination_passed(&pair),\n",
" \"the control must compile and the meaning-level red must be refused by rustc and attributed to its own emitted module; control={} red={} attribution={:?}\",\n",
" crate::cli_run::fixture_closure_summary(&pair.green),\n",
" crate::cli_run::fixture_closure_summary(&pair.red),\n",
" crate::cli_run::fixture_closure_attributed_line(&pair.red)\n",
" );\n",
" }\n\n")
}

fn ct_import_lines_follow_resolved_binding_identity_test() -> String {
concat(
" #[test]\n",
Expand Down Expand Up @@ -3079,6 +3122,7 @@ fn compiler_tests_source() -> String {
ct_parse_tests(),
ct_pipeline_test(),
ct_import_lines_follow_resolved_binding_identity_test(),
ct_fixture_closure_rustc_discrimination_test(),
ct_unlisted_import_use_witness_test(),
ct_call_shape_wall_witness_test(),
ct_call_deficit_red_witness_test(),
Expand Down
17 changes: 16 additions & 1 deletion src/v1/stage0/src/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ fn collect_module_binding_manifest_rows(source_roots: &[String]) -> Vec<ModuleBi
/// `resolve_imports_transitively` — the same BFS over `extract_import_paths` on the same module
/// index the floor uses, so a `.dag` witness can compile an arbitrary in-memory program without
/// a second resolver.
fn resolve_virtual_source_with_imports(
pub(crate) fn resolve_virtual_source_with_imports(
entry_path: &str,
entry_content: &str,
module_index: &HashMap<String, String>,
Expand Down Expand Up @@ -38762,6 +38762,21 @@ pub use emitted_closure_compile_host::{
EmitCompileSelection, MutationVerdict,
};

/// THE FIXTURE ROUTE IS TEST-FACING ONLY, AND THAT IS WHY IT HAS ITS OWN `use` RATHER THAN A LINE
/// IN THE LIST ABOVE.
///
/// `pub(crate)` under `#[cfg(test)]`: the generated `compiler_tests` module is a sibling module in
/// this crate, so it needs crate visibility to reach the route and needs nothing wider. Putting
/// these names in the production list would place them on the emitted seed's exported surface --
/// PublicSurfaceGrowth against a seed frozen for growth. An internal test function does not become
/// public surface merely because Rust needs a path to it.
#[cfg(test)]
pub(crate) use emitted_closure_compile_host::{
fixture_arm_diagnostic_lines, fixture_closure_attributed_line, fixture_closure_reached_rustc,
fixture_closure_rustc_verdict, fixture_closure_summary, fixture_discrimination_passed,
fixture_discrimination_report, run_fixture_closure_discrimination, FixtureClosureOutcome,
};

/// The authority's own declared module path, for consumers outside this module.
///
/// Exposed rather than re-implemented: a second parser for `module <path>` would be a second
Expand Down
40 changes: 40 additions & 0 deletions src/v1/stage0/src/compiler_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,46 @@ mod compiler_tests {
result.expect("emit_import_lines_follow_resolved_binding_identity panicked");
}

/// THE EMITTED CLOSURE, HANDED TO RUSTC, OVER FIXTURES A TEST CAN AUTHOR.
///
/// Every other emitted-bytes assertion in this file is a SPELLING oracle: it reads the
/// emitted text and asserts on substrings. A meaning-level emitter defect is invisible to
/// that whenever the wrong bytes still contain the right substring -- and it is exactly
/// what rustc's type checker refuses. This arm is the one that asks rustc.
///
/// THE PAIR IS THE SUBJECT, NOT EITHER ARM. The control must COMPILE, or a red below
/// proves only that something in the tree is broken. The red must be refused BY RUSTC and
/// ATTRIBUTED to the fixture's own emitted module, or a non-zero status from any of the
/// hundreds of modules in its closure would pass for the fixture's own defect.
///
/// #[ignore] AND WHY, STATED RATHER THAN LEFT TO BE DISCOVERED: this arm spawns cargo and
/// compiles two emitted crates, which is minutes rather than milliseconds, and
/// `repo_self_test_command` runs the whole --lib suite on every push and pull request. It
/// is therefore ENROLLED AND OPT-IN: `cargo test --release -p v1-compiler --lib
/// fixture_closure_rustc_discrimination -- --ignored`. An #[ignore] is a cost decision and
/// NOT a rung: nothing here may be cited as coverage that executes on the merge path.
#[test]
#[ignore]
fn fixture_closure_rustc_discrimination() {
let probe_root = crate::cli_run::local_emit_compile_probe_root();
let pair = crate::cli_run::run_fixture_closure_discrimination(&probe_root);
for line in crate::cli_run::fixture_discrimination_report(&pair) {
eprintln!("{}", line);
}
assert!(
crate::cli_run::fixture_closure_reached_rustc(&pair.red),
"the red arm never reached a rustc verdict, so nothing about the emitted bytes was measured: {}",
crate::cli_run::fixture_closure_summary(&pair.red)
);
assert!(
crate::cli_run::fixture_discrimination_passed(&pair),
"the control must compile and the meaning-level red must be refused by rustc and attributed to its own emitted module; control={} red={} attribution={:?}",
crate::cli_run::fixture_closure_summary(&pair.green),
crate::cli_run::fixture_closure_summary(&pair.red),
crate::cli_run::fixture_closure_attributed_line(&pair.red)
);
}

#[test]
fn unlisted_import_use_witness() {
// Discriminating witness for the selective-import fail-closed mask
Expand Down
Loading
Loading