iter clippy-sweep: clear all 61 cargo clippy warnings
Hygiene sweep across the workspace under `cargo clippy --workspace
--all-targets`. Before: 61 warnings. After: zero. Tests stay 563
green, `cargo doc` stays at zero warnings, and all three bench
scripts exit 0 against existing baselines.
Twelve lint classes, three fix shapes:
- Documentation hygiene (~32 hits): `doc_lazy_continuation` resolved
by adding blank lines before continuation paragraphs or rephrasing
the offending line; plus four `empty_line_after_doc_comments` hits
in workspace.rs where eight `///` blocks left orphan by form-a.1
T5 test relocation were converted to plain `//`.
- Idiomatic refactors (~16 hits): `.err().expect()` → `.expect_err()`,
redundant `.into_iter()` and `.into()` removed, `|f| g(f)` →
`g`, `.trim().split_whitespace()` → `.split_whitespace()`,
`push_str("x")` → `push('x')`, two manual `impl Default` flipped
to `#[derive(Default)]` + `#[default]`, two nested `if let Some(_)
= …` collapsed.
- Block extraction (1 hit): a 13-line block inside an `else if`
condition in synth's Var-arm extracted to a new helper
`is_class_method_dispatch(name, env)` next to
`qualifier_is_class_shape`.
Three `#[allow]`s with inline rationale where clippy's suggestion
would lose meaning: `only_used_in_recursion` on walk_pattern (the
parameter preserves the five-fn walker-framework signature
uniformity), 2× `if_same_then_else` on qualify_local_types shapes
(two branches encode semantically distinct disqualification
reasons), `too_many_arguments` on `Emitter::new` (8 workspace-flat
tables; bundling would just rename boilerplate).
This commit is contained in:
@@ -1395,7 +1395,9 @@ where
|
||||
/// ct.1: Pattern::Ctor carries a `ctor` name (matches against a
|
||||
/// scrutinee's TypeDef) but NOT a type_name field — the type is
|
||||
/// inferred from the scrutinee. So Pattern walking only recurses;
|
||||
/// no canonical-form check fires here.
|
||||
/// no canonical-form check fires here. `f` is kept in the signature
|
||||
/// to match the sibling `walk_*` framework (uniform plumbing).
|
||||
#[allow(clippy::only_used_in_recursion)]
|
||||
fn walk_pattern<F>(p: &crate::ast::Pattern, f: &mut F) -> Result<(), WorkspaceLoadError>
|
||||
where
|
||||
F: FnMut(&str) -> Result<(), WorkspaceLoadError>,
|
||||
@@ -1670,13 +1672,13 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Iter 22b.1: a workspace whose own modules contain no
|
||||
/// `Def::Instance` defs produces no non-prelude registry entries.
|
||||
/// This is the happy-path baseline for the registry-build pass —
|
||||
/// every pre-22b workspace falls into this case. With the
|
||||
/// auto-loaded prelude (iter 23.2) the registry is no longer
|
||||
/// strictly empty, so the invariant is now "no entries whose
|
||||
/// `defining_module` is anything other than `prelude`".
|
||||
// Iter 22b.1: a workspace whose own modules contain no
|
||||
// `Def::Instance` defs produces no non-prelude registry entries.
|
||||
// This is the happy-path baseline for the registry-build pass —
|
||||
// every pre-22b workspace falls into this case. With the
|
||||
// auto-loaded prelude (iter 23.2) the registry is no longer
|
||||
// strictly empty, so the invariant is now "no entries whose
|
||||
// `defining_module` is anything other than `prelude`".
|
||||
// `iter22b1_workspace_with_no_classes_has_empty_registry` relocated
|
||||
// to `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
@@ -1690,50 +1692,50 @@ mod tests {
|
||||
.join("examples")
|
||||
}
|
||||
|
||||
/// Iter 22b.1: a coherent instance (in the class's module)
|
||||
/// loads cleanly and produces one registry entry from the
|
||||
/// fixture itself. With the auto-loaded prelude (iter 23.2)
|
||||
/// the registry also contains the prelude's own entries; the
|
||||
/// invariant is filtered to fixture-only entries.
|
||||
// Iter 22b.1: a coherent instance (in the class's module)
|
||||
// loads cleanly and produces one registry entry from the
|
||||
// fixture itself. With the auto-loaded prelude (iter 23.2)
|
||||
// the registry also contains the prelude's own entries; the
|
||||
// invariant is filtered to fixture-only entries.
|
||||
// `iter22b1_instance_in_class_module_loads_clean` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
/// Iter 22b.1: an instance declared in a module that is neither
|
||||
/// the class's module nor the type's module fires `OrphanInstance`.
|
||||
/// The fixture imports `test_22b1_orphan_third_classmod` (which
|
||||
/// owns `class TShow`) and the entry module declares `instance
|
||||
/// TShow Int` itself — but the entry is not the class's module
|
||||
/// and `Int` is primitive, so neither leg of coherence is
|
||||
/// satisfied. (24.2: class renamed `Show` → `TShow`.)
|
||||
// Iter 22b.1: an instance declared in a module that is neither
|
||||
// the class's module nor the type's module fires `OrphanInstance`.
|
||||
// The fixture imports `test_22b1_orphan_third_classmod` (which
|
||||
// owns `class TShow`) and the entry module declares `instance
|
||||
// TShow Int` itself — but the entry is not the class's module
|
||||
// and `Int` is primitive, so neither leg of coherence is
|
||||
// satisfied. (24.2: class renamed `Show` → `TShow`.)
|
||||
// `iter22b1_orphan_instance_fires_diagnostic` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
/// Iter 22b.1 / mq.1: two instances of the same `(class, type)`
|
||||
/// pair collide on the registry's uniqueness check.
|
||||
///
|
||||
/// Pre-mq.1 the test used a two-module fixture
|
||||
/// (`test_22b1_dup_a` declared the class + first instance,
|
||||
/// `test_22b1_dup_b` declared the type + second instance) which
|
||||
/// relied on bare cross-module class refs. The mq.1
|
||||
/// canonical-form rule makes that shape structurally
|
||||
/// unrepresentable (any second instance in a module that owns
|
||||
/// neither the class nor the type fires `OrphanInstance` first).
|
||||
/// Post-mq.1 the only way to land two instances on the same
|
||||
/// canonical key is to have them in the same module (the class's
|
||||
/// or the type's module). The fixture now declares both
|
||||
/// instances in `test_22b1_dup_same_module` — both class-leg
|
||||
/// coherent, both collide on `(test_22b1_dup_same_module.TShow,
|
||||
/// type_hash(Int))`. (24.2: class renamed `Show` → `TShow`.)
|
||||
// Iter 22b.1 / mq.1: two instances of the same `(class, type)`
|
||||
// pair collide on the registry's uniqueness check.
|
||||
//
|
||||
// Pre-mq.1 the test used a two-module fixture
|
||||
// (`test_22b1_dup_a` declared the class + first instance,
|
||||
// `test_22b1_dup_b` declared the type + second instance) which
|
||||
// relied on bare cross-module class refs. The mq.1
|
||||
// canonical-form rule makes that shape structurally
|
||||
// unrepresentable (any second instance in a module that owns
|
||||
// neither the class nor the type fires `OrphanInstance` first).
|
||||
// Post-mq.1 the only way to land two instances on the same
|
||||
// canonical key is to have them in the same module (the class's
|
||||
// or the type's module). The fixture now declares both
|
||||
// instances in `test_22b1_dup_same_module` — both class-leg
|
||||
// coherent, both collide on `(test_22b1_dup_same_module.TShow,
|
||||
// type_hash(Int))`. (24.2: class renamed `Show` → `TShow`.)
|
||||
// `iter22b1_duplicate_instance_fires_diagnostic` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
/// Iter 22b.1: an instance that omits a required (non-default)
|
||||
/// method of its class fires `MissingMethod`. The fixture's
|
||||
/// `class TEq` declares `teq` and `tne` as both non-default; the
|
||||
/// instance only specifies `tne`, leaving `teq` missing.
|
||||
/// (Class is `TEq` (and method `tne`) rather than `Eq` / `ne` to
|
||||
/// avoid colliding with the auto-loaded prelude's `class Eq` and
|
||||
/// — since iter 23.5 — the prelude's polymorphic free fn `ne`.)
|
||||
// Iter 22b.1: an instance that omits a required (non-default)
|
||||
// method of its class fires `MissingMethod`. The fixture's
|
||||
// `class TEq` declares `teq` and `tne` as both non-default; the
|
||||
// instance only specifies `tne`, leaving `teq` missing.
|
||||
// (Class is `TEq` (and method `tne`) rather than `Eq` / `ne` to
|
||||
// avoid colliding with the auto-loaded prelude's `class Eq` and
|
||||
// — since iter 23.5 — the prelude's polymorphic free fn `ne`.)
|
||||
// `iter22b1_missing_method_fires_diagnostic` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
@@ -1780,16 +1782,16 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Iter 22b.2: an instance that specifies a body for a method
|
||||
/// name the class never declared must fire
|
||||
/// `OverridingNonExistentMethod`. Symmetric counterpart to
|
||||
/// `MissingMethod`: the latter fires when the class declares a
|
||||
/// non-default method that the instance omits; this one fires
|
||||
/// when the instance provides a body the class did not ask for.
|
||||
/// Decision 11 forbids ad-hoc additions to a class's method set
|
||||
/// at the instance site.
|
||||
/// (Class is `TEq` rather than `Eq` to avoid colliding with the
|
||||
/// auto-loaded prelude's `class Eq`.)
|
||||
// Iter 22b.2: an instance that specifies a body for a method
|
||||
// name the class never declared must fire
|
||||
// `OverridingNonExistentMethod`. Symmetric counterpart to
|
||||
// `MissingMethod`: the latter fires when the class declares a
|
||||
// non-default method that the instance omits; this one fires
|
||||
// when the instance provides a body the class did not ask for.
|
||||
// Decision 11 forbids ad-hoc additions to a class's method set
|
||||
// at the instance site.
|
||||
// (Class is `TEq` rather than `Eq` to avoid colliding with the
|
||||
// auto-loaded prelude's `class Eq`.)
|
||||
// `instance_overriding_nonexistent_method_fires` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
@@ -1827,15 +1829,15 @@ mod tests {
|
||||
// observations move to `env.method_to_candidate_classes`
|
||||
// (multi-entry set) plus the call-site warning.
|
||||
|
||||
/// Iter 22b.2: an instance `C T` whose class `C` declares a
|
||||
/// superclass `S` requires that `instance S T` also exist in the
|
||||
/// workspace. The fixture declares `class TEq a`, `class TOrd a
|
||||
/// extends TEq a`, and `instance TOrd Int` — but no `instance TEq
|
||||
/// Int` — so registry build must fire
|
||||
/// `MissingSuperclassInstance`. Decision 11 single-superclass
|
||||
/// model requires `instance S T` whenever `instance C T` exists.
|
||||
/// (Classes are `TEq` / `TOrd` rather than `Eq` / `Ord` to avoid
|
||||
/// colliding with the auto-loaded prelude's `class Eq`.)
|
||||
// Iter 22b.2: an instance `C T` whose class `C` declares a
|
||||
// superclass `S` requires that `instance S T` also exist in the
|
||||
// workspace. The fixture declares `class TEq a`, `class TOrd a
|
||||
// extends TEq a`, and `instance TOrd Int` — but no `instance TEq
|
||||
// Int` — so registry build must fire
|
||||
// `MissingSuperclassInstance`. Decision 11 single-superclass
|
||||
// model requires `instance S T` whenever `instance C T` exists.
|
||||
// (Classes are `TEq` / `TOrd` rather than `Eq` / `Ord` to avoid
|
||||
// colliding with the auto-loaded prelude's `class Eq`.)
|
||||
// `instance_without_superclass_instance_fires` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
@@ -2494,12 +2496,12 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// mq.1: on-disk fixture pin — a workspace where the consumer's
|
||||
/// `Constraint.class` references a class in an imported module via
|
||||
/// the qualified form loads cleanly. Symmetric to ct.1's positive
|
||||
/// cross-module type-ref fixture (`ct1_validator_accepts_qualified_xmod_ref`
|
||||
/// in-test sibling). Guards the full load → validator → registry
|
||||
/// path on a real on-disk pair.
|
||||
// mq.1: on-disk fixture pin — a workspace where the consumer's
|
||||
// `Constraint.class` references a class in an imported module via
|
||||
// the qualified form loads cleanly. Symmetric to ct.1's positive
|
||||
// cross-module type-ref fixture (`ct1_validator_accepts_qualified_xmod_ref`
|
||||
// in-test sibling). Guards the full load → validator → registry
|
||||
// path on a real on-disk pair.
|
||||
// `mq1_xmod_constraint_class_fixture_loads` relocated to
|
||||
// `crates/ailang-core/tests/workspace_pin.rs` in iter form-a.1 Task 5.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user