Skip to content

Complete configured lints and refresh test infrastructure - #45

Open
scottgerring wants to merge 11 commits into
mainfrom
sgg/sept-updates
Open

scottgerring wants to merge 11 commits into
mainfrom
sgg/sept-updates

Conversation

@scottgerring

@scottgerring scottgerring commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Complete configured lint behaviour

  • implement struct attribute matching, including attributes such as derive that rustc consumes during expansion
  • implement required and forbidden trait rules, plus logical And, Or, and Not struct rules
  • implement logical module rules with leaf-specific diagnostics and strongest-severity propagation
  • keep composite module rules inapplicable when an operand does not apply to the current item kind
  • improve logical-rule diagnostics so they identify the individual property that failed
  • explain why MustNotExist function rules matched, including module, async, unsafe, name-pattern, and return-type evidence

Discovery and self-linting

  • report trait lint applicability correctly in cargo pup print-traits
  • add end-to-end coverage for trait applicability output
  • update Cargo Pup's generated pup.ron to use current crate and trait paths
  • remove obsolete self-lint rules and enforce the current lint implementation naming and visibility conventions
  • deduplicate aggregated project contexts while preserving lint names and trait implementors

Cleanup and test infrastructure

  • remove the unused panicking configuration generator
  • expose LintConfigurationFactory through cargo_pup_lint_impl's public API and use that API from pup_driver
  • run standard tests with Nextest through a shared scripts/test.sh used both locally and in CI
  • retain Cargo's runner for doctests and the custom UI harness
  • pin the CI Nextest version and validate the local version
  • harden test_app cache handling, expected-output validation, temporary-directory usage, and print-traits validation
  • upgrade direct and transitive dependencies, including test_app, and remove unused proc-macro fixture dependencies

Validation

  • scripts/test.sh
    • 82 standard workspace tests through Nextest
    • 9 doctests
    • 29 UI tests
    • 2 test_app tests through Nextest
    • test_app expected-output validation
    • test_app print-traits validation
  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo outdated --workspace --root-deps-only
  • cargo outdated --workspace --root-deps-only in test_app

@scottgerring
scottgerring force-pushed the sgg/sept-updates branch 3 times, most recently from 64eb774 to 111d91c Compare September 17, 2026 12:41
@scottgerring
scottgerring requested a balanced review from Copilot September 17, 2026 14:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Attribute and trait matching have correctness gaps, and logical module severity propagation is not active in production.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Completes configured lint behavior, improves diagnostics and context discovery, and modernizes testing and dependencies.

Changes:

  • Implements logical, attribute, and trait-based lint rules.
  • Improves trait discovery, diagnostics, and context deduplication.
  • Adds shared Nextest infrastructure and refreshes dependencies.
File summaries
File Description
.github/workflows/pr.yaml Runs the shared Nextest-based suite.
.gitignore Ignores Sphinx artifacts.
Cargo.lock Refreshes workspace dependencies.
Cargo.toml Updates dependency versions.
README.md Documents the new test workflow.
cargo_pup_common/src/project_context.rs Merges duplicate context metadata.
cargo_pup_lint_config/src/module_lint/tests.rs Tests logical module configuration.
cargo_pup_lint_config/src/struct_lint/tests.rs Tests trait and logical struct builders.
cargo_pup_lint_impl/src/lints/configuration_factory.rs Removes the unused generator.
cargo_pup_lint_impl/src/lints/function_lint/lint.rs Adds detailed match evidence.
cargo_pup_lint_impl/src/lints/module_lint/lint.rs Implements logical module rules.
cargo_pup_lint_impl/src/lints/struct_lint/lint.rs Implements attribute, trait, and logical rules.
cargo_pup_lint_impl/src/lib.rs Exports the configuration factory.
pup.ron Updates self-lint rules and paths.
scripts/test.sh Adds the shared test runner.
src/pup_driver.rs Uses the public factory export.
test_app/Cargo.lock Refreshes test-app dependencies.
test_app/Cargo.toml Updates and adds test dependencies.
test_app/expected_output Records new lint diagnostics.
test_app/proc_macro_test/Cargo.toml Removes unused dependencies.
test_app/pup.ron Adds logical and struct rules.
test_app/scripts/validate-print-traits.sh Validates trait output.
test_app/src/configured_struct_rules.rs Adds struct-rule fixtures.
test_app/src/logical_module_rules.rs Adds module-rule fixtures.
test_app/src/main.rs Registers new fixtures.
test_app/tests/project_context_dedup_test.rs Tests cross-context deduplication.
test_app/tests/pup_ron_test.rs Generates expanded test configuration.
tests/ron_test.rs Updates generated self-lint configuration.
tests/ui/function_lint/builder_style.rs Updates diagnostic assertions.
tests/ui/function_lint/builder_style.stderr Records builder diagnostics.
tests/ui/function_lint/is_async.rs Updates async assertions.
tests/ui/function_lint/is_async.stderr Records async diagnostics.
tests/ui/function_lint/is_unsafe_match.rs Updates unsafe assertions.
tests/ui/function_lint/is_unsafe_match.stderr Records unsafe diagnostics.
tests/ui/module_lint_new/logical_rules.rs Adds logical module UI cases.
tests/ui/module_lint_new/logical_rules.stderr Records module-rule diagnostics.
tests/ui/module_lint_new/pup.ron Configures module UI rules.
tests/ui/struct_lint_new/attributes_and_configured_rules.rs Adds struct-rule UI cases.
tests/ui/struct_lint_new/attributes_and_configured_rules.stderr Records struct-rule diagnostics.
tests/ui/struct_lint_new/pup.ron Configures struct UI rules.
Review details

Suppressed comments (2)

cargo_pup_lint_impl/src/lints/struct_lint/lint.rs:388

  • Filtering out every trait with generic parameters makes ImplementsTrait deterministically return false for common traits such as From<T>, AsRef<T>, and Iterator<Item = T>. Consequently, required rules report valid implementations as missing and forbidden rules allow them. The implementation should inspect matching impls or construct a trait reference with inference variables instead of silently excluding generic traits.
                .filter(|&trait_def_id| {
                    // Traits with more than `Self` as a generic parameter (e.g.
                    // `From<T>`, `AsRef<T>`) can't be queried via `implements_trait`,
                    // which builds a `TraitRef` with exactly one type argument.
                    ctx.tcx.generics_of(trait_def_id).own_params.len() <= 1

cargo_pup_lint_impl/src/lints/struct_lint/lint.rs:479

  • Trait applicability only examines the matcher tree, so rule-only constraints are omitted from print-traits. For example, the newly added required_trait_rule_check, whose matcher is only a struct name, will not appear beside configured_struct_rules::RequiredTrait even though its ImplementsTrait rule directly constrains implementations of that trait. Include trait references from the rule tree as well.
    fn applies_to_trait(&self, trait_path: &str) -> bool {
        matcher_references_trait(&self.matches, trait_path)
  • Files reviewed: 37/40 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +931 to +935
if self.evaluate_module_rule(ctx, item, rule) == Some(false) {
let mut violations = Vec::new();
collect_module_rule_violations(rule, true, &evaluate_leaf, &mut violations);
for (leaf, expected) in violations {
self.render_module_rule_violation(ctx, item, leaf, expected);
Comment on lines +321 to +324
if let Some(source) = &local_position.sf.src
&& preceding_outer_attributes(source, local_position.pos.0 as usize)
.into_iter()
.any(|attribute| regex.is_match(attribute))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants