Skip to content
Merged
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
76 changes: 70 additions & 6 deletions src/v1/05_emit_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -3438,6 +3438,44 @@ fn lib_rs_mod_name_from_path(path: String) -> String {

data hand_maintained_map_key_required_type_names: List<String> = ["ItemKind"]

// ONE AUTHORITY FOR THE LINT RELAXATION GENERATED RUST NEEDS, TWO RENDERINGS. Mechanically
// derived Rust carries artifacts no lint can inform an authoring decision about: parentheses
// the lowering adds to keep precedence safe, imports the emitter cannot know a body will not
// use, clones it cannot know are Copy. Relaxing those is a fact about GENERATED CODE, so it
// is spelled once here and rendered where it belongs, rather than copied per emitter -- it was
// spelled twice, here and in v1.compiler.stage0_crates, which is one concept with two names.
//
// THE RENDERING IS NOT COSMETIC. An inner `#![allow(..)]` at a crate root outranks `-D warnings`
// on the command line and reaches every module under that root, so a root that blankets on
// behalf of its generated modules also silences every HAND-MAINTAINED module sharing it. The
// v1-compiler root did exactly that: `cargo clippy --all-targets -- -D warnings`, one of the
// three checks DESIGN names, decided nothing over the 40 top-level and 27 cli_run modules
// written by hand. So the crate-root block is emitted only for a root whose modules are ALL
// generated, and where hand-maintained siblings share the root each generated item carries the
// relaxation as an outer attribute instead.
data generated_rust_lint_relaxations: List<String> = [
"unused_imports",
"unused_variables",
"unused_mut",
"unused_parens",
"dead_code",
"non_shorthand_field_patterns",
"suspicious_double_ref_op",
"clippy::all"
]

fn generated_rust_lint_arguments() -> String {
generated_rust_lint_relaxations |> join(separator: ", ")
}

fn generated_rust_crate_allow_block() -> String {
concat("#![allow(", generated_rust_lint_arguments(), ")]")
}

fn generated_rust_item_allow_attr() -> String {
concat("#[allow(", generated_rust_lint_arguments(), ")]\n")
}

// ONE role, TWO projections. Being a macro provider decides both how the module is
// RENDERED (`#[macro_use]`) and where it is ORDERED (ahead of its consumers), and the
// two were independently written comparisons against the same literal until this
Expand Down Expand Up @@ -3522,9 +3560,9 @@ fn stage0_package_name_to_crate_ident(package_name: String) -> String {
// shell's own definition leaves every `crate::NonEmptyVec` in the modules that stay bound to
// exactly the type it was bound to before this cut. Deleting it would silently repoint them at
// the foundation's, which is a carrier change wearing a re-export's clothes.
fn stage0_host_shell_partition_reexport_block() -> String {
fn stage0_host_shell_partition_reexport_block(item_attr: String) -> String {
generated_host_shell_partition_dependencies
|> map(pkg => concat("pub use ", stage0_package_name_to_crate_ident(package_name: pkg), "::*;"))
|> map(pkg => concat(item_attr, "pub use ", stage0_package_name_to_crate_ident(package_name: pkg), "::*;"))
|> join(separator: "\n")
}

Expand All @@ -3540,6 +3578,17 @@ fn stage0_host_shell_partition_reexport_block() -> String {
// the module NAME; it reads no module content and no rendered file, so a scoped emission still
// declares the whole population minus the partition-owned names. Ownership and scope are decided
// by different inputs and neither can shadow the other.
// A ROOT THAT MIXES AUTHORSHIP MAY NOT BLANKET ON ITS MODULES' BEHALF. `has_compiler_tests`
// selects the one root that declares hand-maintained modules beside generated ones -- the
// stage0 host shell -- and there the relaxation rides each generated item while the
// hand-maintained block is left bare, so `cargo clippy --all-targets -- -D warnings` reaches it.
// Every other root this function renders is wholly generated and keeps the crate-level block,
// which is honest because there is nothing under it the relaxation does not describe.
//
// The `im` alias carries the attribute because it is generated and one of its two names is
// unused; the NonEmpty* wrappers deliberately do NOT, because they are a fixed handful of items
// that are clean under the gate today, and leaving judged what can be judged keeps the excused
// set as small as the facts require rather than as large as the category.
fn emit_lib_rs_from_paths(all_module_paths: List<String>, has_compiler_tests: Bool) -> TextFile {
let file_derived_names = all_module_paths |> map(lib_rs_mod_name_from_path)
let shell_names = if has_compiler_tests {
Expand All @@ -3552,28 +3601,43 @@ fn emit_lib_rs_from_paths(all_module_paths: List<String>, has_compiler_tests: Bo
} else {
order_partial_lib_rs_mod_names(mod_names: shell_names)
}
let mod_decls = mod_names |> map(emit_lib_rs_mod_decl)
let root_is_mixed_authorship = has_compiler_tests
let generated_item_attr = if root_is_mixed_authorship {
generated_rust_item_allow_attr()
} else {
""
}
let root_allow_block = if root_is_mixed_authorship {
""
} else {
concat(generated_rust_crate_allow_block(), "\n")
}

let mod_decls = mod_names
|> map(n => concat(generated_item_attr, emit_lib_rs_mod_decl(mod_name: n)))

let hand_maintained_mods = if has_compiler_tests {
generated_pub_mod_block
} else {
""
}
let test_mod = if has_compiler_tests {
"\n\n#[cfg(test)]\nmod compiler_tests;"
concat("\n\n#[cfg(test)]\n", generated_item_attr, "mod compiler_tests;")
} else {
""
}
let partition_reexports = if has_compiler_tests {
concat(stage0_host_shell_partition_reexport_block(), "\n\n")
concat(stage0_host_shell_partition_reexport_block(item_attr: generated_item_attr), "\n\n")
} else {
""
}
let shared_types = emit_non_empty_wrappers()
let content = concat("// Generated by v1 compiler -- do not edit.\n\n",
"#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n#![deny(unreachable_patterns)]\n",
root_allow_block,
"#![deny(unreachable_patterns)]\n",

"#![recursion_limit = \"256\"]\n\n",
generated_item_attr,
"use im::\{OrdSet as BTreeSet, Vector as Vec\};\n\n",
partition_reexports,
mod_decls |> join(separator: "\n"),
Expand Down
15 changes: 14 additions & 1 deletion src/v1/stage0/src/behavioral_receipt_host.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#![allow(clippy::disallowed_macros)]
// CLIPPY ROSTER -- 6 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
clippy::clone_on_copy, // 1
clippy::disallowed_macros, // 0 -- pre-existing
clippy::enum_variant_names, // 1
clippy::needless_borrow, // 1
dead_code, // 3
)]

use crate::cli_run::namespace_wave_admission::git_stdout;
use std::fs;
Expand Down
11 changes: 11 additions & 0 deletions src/v1/stage0/src/bounded_shell_host_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
//! native serve and the shared `CapturedProcessStream` carrier land. `std.shell_stream_capture`
//! carries scaffold prose and predicate witnesses only — not parallel limits.

// CLIPPY ROSTER -- 2 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
clippy::io_other_error, // 2
)]

use std::io::Read;
use std::process::{Child, ExitStatus};

Expand Down
11 changes: 11 additions & 0 deletions src/v1/stage0/src/census_exclude_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
//! - (i) Silent live-importer loss → typed refusal.
//! - (ii) Derived closure exclusion of live importers → legitimate, reported in receipt.

// CLIPPY ROSTER -- 1 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
clippy::disallowed_macros, // 1
)]

use std::collections::{BTreeSet, VecDeque};
use std::path::{Path, PathBuf};
use std::sync::OnceLock;
Expand Down
39 changes: 38 additions & 1 deletion src/v1/stage0/src/cli_run.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
// CLIPPY ROSTER -- 256 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
clippy::assertions_on_constants, // 1
clippy::clone_on_copy, // 1
clippy::cloned_ref_to_slice_refs, // 2
clippy::collapsible_str_replace, // 1
clippy::disallowed_macros, // 94
clippy::doc_lazy_continuation, // 2
clippy::empty_line_after_doc_comments, // 4
clippy::enum_variant_names, // 1
clippy::iter_kv_map, // 1
clippy::manual_is_multiple_of, // 1
clippy::manual_strip, // 3
clippy::map_identity, // 2
clippy::missing_const_for_thread_local, // 2
clippy::needless_borrow, // 2
clippy::needless_lifetimes, // 1
clippy::only_used_in_recursion, // 1
clippy::ptr_arg, // 4
clippy::redundant_closure, // 3
clippy::single_char_add_str, // 2
clippy::too_many_arguments, // 2
clippy::type_complexity, // 7
clippy::unnecessary_to_owned, // 12
clippy::unneeded_struct_pattern, // 1
clippy::useless_vec, // 1
dead_code, // 88
unused_imports, // 14
unused_mut, // 3
)]

use im::HashMap;
use std::cell::{Cell, RefCell};
use std::collections::{BTreeMap, BTreeSet, HashSet, VecDeque};
Expand Down Expand Up @@ -1286,7 +1323,7 @@ mod process_cwd_mutation_reachability_gate {
// A raw-string opener: `r`, then zero or more `#`, then `"`, and not preceded by
// an identifier character (else it is the tail of a name like `attr`).
if c == 'r'
&& i.checked_sub(1).map_or(true, |prev| {
&& i.checked_sub(1).is_none_or(|prev| {
!(chars[prev].is_ascii_alphanumeric() || chars[prev] == '_')
})
{
Expand Down
45 changes: 44 additions & 1 deletion src/v1/stage0/src/cli_run/active_workset.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
// Split from cli_run.rs (pure code motion; no semantic change).
#![allow(unused_imports)]
// CLIPPY ROSTER -- 4 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
dead_code, // 4
unused_imports, // 0 -- pre-existing
)]
// cli_run.rs is this module's PARENT, and an `#![allow]` there reaches every module
// under it -- the same cascade this commit removed at the crate root, one level down.
// These are the names its roster carries that this module does not trip, restored to
// warn so `-D warnings` still judges them here. A name moves from this list to the
// allow list above only with a counted site, never silently.
#![warn(
clippy::assertions_on_constants,
clippy::clone_on_copy,
clippy::cloned_ref_to_slice_refs,
clippy::collapsible_str_replace,
clippy::disallowed_macros,
clippy::doc_lazy_continuation,
clippy::empty_line_after_doc_comments,
clippy::enum_variant_names,
clippy::iter_kv_map,
clippy::manual_is_multiple_of,
clippy::manual_strip,
clippy::map_identity,
clippy::missing_const_for_thread_local,
clippy::needless_borrow,
clippy::needless_lifetimes,
clippy::only_used_in_recursion,
clippy::ptr_arg,
clippy::redundant_closure,
clippy::single_char_add_str,
clippy::too_many_arguments,
clippy::type_complexity,
clippy::unnecessary_to_owned,
clippy::unneeded_struct_pattern,
clippy::useless_vec,
unused_mut
)]

use super::*;
use im::HashMap;
use std::cell::{Cell, RefCell};
Expand Down
45 changes: 44 additions & 1 deletion src/v1/stage0/src/cli_run/census_heads.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
// Split from cli_run.rs (pure code motion; no semantic change).
#![allow(unused_imports)]
// CLIPPY ROSTER -- 9 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
clippy::clone_on_copy, // 6
clippy::type_complexity, // 1
dead_code, // 2
unused_imports, // 0 -- pre-existing
)]
// cli_run.rs is this module's PARENT, and an `#![allow]` there reaches every module
// under it -- the same cascade this commit removed at the crate root, one level down.
// These are the names its roster carries that this module does not trip, restored to
// warn so `-D warnings` still judges them here. A name moves from this list to the
// allow list above only with a counted site, never silently.
#![warn(
clippy::assertions_on_constants,
clippy::cloned_ref_to_slice_refs,
clippy::collapsible_str_replace,
clippy::disallowed_macros,
clippy::doc_lazy_continuation,
clippy::empty_line_after_doc_comments,
clippy::enum_variant_names,
clippy::iter_kv_map,
clippy::manual_is_multiple_of,
clippy::manual_strip,
clippy::map_identity,
clippy::missing_const_for_thread_local,
clippy::needless_borrow,
clippy::needless_lifetimes,
clippy::only_used_in_recursion,
clippy::ptr_arg,
clippy::redundant_closure,
clippy::single_char_add_str,
clippy::too_many_arguments,
clippy::unnecessary_to_owned,
clippy::unneeded_struct_pattern,
clippy::useless_vec,
unused_mut
)]

use super::*;
use im::HashMap;
use std::cell::{Cell, RefCell};
Expand Down
45 changes: 44 additions & 1 deletion src/v1/stage0/src/cli_run/class_b_census.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
// Split from cli_run.rs (pure code motion; no semantic change).
#![allow(unused_imports)]
// CLIPPY ROSTER -- 7 finding(s) this module trips today, listed one lint per line with
// its count. Until this commit the generated crate root allowed `clippy::all` plus six
// rustc groups on behalf of every module under it, so `cargo clippy --all-targets -- -D
// warnings` decided nothing here; the root now excuses only the generated modules it
// speaks for (v1.compiler.emit_rust generated_rust_lint_relaxations), and this is what
// that leaves visible. The list is MONOTONE NON-INCREASING: a name leaves when its last
// site is repaired, and a lint not named below reds the build, which is the whole point.
#![allow(
clippy::disallowed_macros, // 7
unused_imports, // 0 -- pre-existing
)]
// cli_run.rs is this module's PARENT, and an `#![allow]` there reaches every module
// under it -- the same cascade this commit removed at the crate root, one level down.
// These are the names its roster carries that this module does not trip, restored to
// warn so `-D warnings` still judges them here. A name moves from this list to the
// allow list above only with a counted site, never silently.
#![warn(
clippy::assertions_on_constants,
clippy::clone_on_copy,
clippy::cloned_ref_to_slice_refs,
clippy::collapsible_str_replace,
clippy::doc_lazy_continuation,
clippy::empty_line_after_doc_comments,
clippy::enum_variant_names,
clippy::iter_kv_map,
clippy::manual_is_multiple_of,
clippy::manual_strip,
clippy::map_identity,
clippy::missing_const_for_thread_local,
clippy::needless_borrow,
clippy::needless_lifetimes,
clippy::only_used_in_recursion,
clippy::ptr_arg,
clippy::redundant_closure,
clippy::single_char_add_str,
clippy::too_many_arguments,
clippy::type_complexity,
clippy::unnecessary_to_owned,
clippy::unneeded_struct_pattern,
clippy::useless_vec,
dead_code,
unused_mut
)]

use super::*;
use im::HashMap;
use std::cell::{Cell, RefCell};
Expand Down
Loading
Loading