From 41eb86b76f134279f07164e6e9a600af1c77e1bd Mon Sep 17 00:00:00 2001 From: Gaurav Agerwala Date: Sun, 7 Dec 2025 07:46:13 -0800 Subject: [PATCH] Update design for PR #16149: Add manual_checked_div lint --- pr-analysis-16149.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 pr-analysis-16149.md diff --git a/pr-analysis-16149.md b/pr-analysis-16149.md new file mode 100644 index 000000000000..b76e5420786c --- /dev/null +++ b/pr-analysis-16149.md @@ -0,0 +1,40 @@ +# PR #16149: Workflow Design Impact Analysis + +## Affected Workflows +- Lint Development (Workflow 5): The PR adds a new lint `manual_checked_div` by implementing it in `clippy_lints/src/manual_checked_div.rs`, registering it via updates to `declared_lints.rs` and `lib.rs` using `cargo dev update_lints`, adding corresponding UI tests in `tests/ui/manual_checked_div/`, and updating `CHANGELOG.md`. These actions directly correspond to the lint development process outlined in `.exp/workflows.json` under the "lint-development" workflow, which covers creating, registering, and testing new lints. + +- Testing (Workflow 4): New UI test files (`.rs`, `.stderr`, `.fixed`) are introduced for the new lint, which will be executed and verified as part of the comprehensive testing suite, including UI tests managed by `tests/compile-test.rs`. + +## Lint Development Analysis (Workflow 5) + +### Summary of design changes +The PR adheres to the existing lint-development design without introducing modifications to the workflow or its components. Specifically: +- A new lint pass is implemented manually (instead of using `cargo dev new_lint`), including the `declare_clippy_lint!` macro invocation and `LateLintPass` implementation in `manual_checked_div.rs`. +- UI test scaffolding is created manually in `tests/ui/manual_checked_div/`. +- Integration is achieved by running `cargo dev update_lints`, which parses the declaration, updates `declared_lints.rs` (adding to `LINTS` array), `lib.rs` (adding `mod` declaration), and refreshes documentation including `CHANGELOG.md` counts and links. +- A manual addition to `CHANGELOG.md` provides the specific description for the new lint, as the tool updates counts but not individual entries. + +No new steps are added, components modified, or interactions changed in the scaffolding or integration sequences. The design remains accurate and does not require updates. + +**Mermaid diagrams that need updating:** None. The existing diagrams in `.exp/design-workflow-5-lint-development.md` (Scaffolding Sequence and Integration and Execution Sequence) fully represent the process used, with the PR exemplifying a manual variant of scaffolding that fits within the described flexibility ("This design balances automation with flexibility"). + +Potential benefits: Introduces a new nursery-level lint that detects inefficient and error-prone manual zero-division checks for unsigned integers, suggesting the safer and more idiomatic `checked_div` method. This enhances Clippy's ability to promote safe arithmetic practices. + +## Testing Analysis (Workflow 4) + +### Summary of design changes +The PR extends the test suite by adding a dedicated UI test directory for `manual_checked_div`, including input code triggering the lint, expected stderr diagnostics, and fixed output for auto-fix verification. These tests integrate seamlessly into the existing UI testing infrastructure: +- During `cargo test`, `compile-test.rs` will configure `ui_test` for the `ui/` category. +- It spawns `clippy-driver` processes on the `.rs` files with appropriate flags. +- Outputs are compared against `.stderr` and `.fixed` (if present), ensuring the new lint emits correct diagnostics and suggestions. + +No alterations to the testing sequence, components (e.g., `compile-test.rs`, `ui_test` crate, diagnostic collection), or flows. The design accommodates arbitrary numbers of lint-specific tests without modification. + +**Mermaid diagrams that need updating:** None. The UI Tests Sequence Diagram in `.exp/design-workflow-4-testing.md` accurately depicts the process, with the new tests following the standard loop for each test case. + +Potential implications: Strengthens validation of the new lint across normal and fix scenarios, helping prevent regressions in future Clippy updates or Rust compiler changes. + +## Additional Notes +- **Other Workflows:** While files like `CHANGELOG.md` relate to release-process (Workflow 8) and `clippy_lints/src/` to cargo-clippy (1) and clippy-driver (2), the PR does not alter their designs—only utilizes them (e.g., new lint available in clippy runs, changelog entry for releases). +- No updates to `.exp` design documents or diagrams are necessary, as the PR reinforces existing designs without deviations requiring documentation. +- Validation: Existing Mermaid diagrams in affected design docs were reviewed; syntax is valid (no `mmdc` needed for unchanged diagrams). \ No newline at end of file