Skip to content

Commit 41eb86b

Browse files
Update design for PR rust-lang#16149: Add manual_checked_div lint
1 parent 4d6fa3c commit 41eb86b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

pr-analysis-16149.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# PR #16149: Workflow Design Impact Analysis
2+
3+
## Affected Workflows
4+
- 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.
5+
6+
- 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`.
7+
8+
## Lint Development Analysis (Workflow 5)
9+
10+
### Summary of design changes
11+
The PR adheres to the existing lint-development design without introducing modifications to the workflow or its components. Specifically:
12+
- 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`.
13+
- UI test scaffolding is created manually in `tests/ui/manual_checked_div/`.
14+
- 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.
15+
- A manual addition to `CHANGELOG.md` provides the specific description for the new lint, as the tool updates counts but not individual entries.
16+
17+
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.
18+
19+
**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").
20+
21+
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.
22+
23+
## Testing Analysis (Workflow 4)
24+
25+
### Summary of design changes
26+
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:
27+
- During `cargo test`, `compile-test.rs` will configure `ui_test` for the `ui/` category.
28+
- It spawns `clippy-driver` processes on the `.rs` files with appropriate flags.
29+
- Outputs are compared against `.stderr` and `.fixed` (if present), ensuring the new lint emits correct diagnostics and suggestions.
30+
31+
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.
32+
33+
**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.
34+
35+
Potential implications: Strengthens validation of the new lint across normal and fix scenarios, helping prevent regressions in future Clippy updates or Rust compiler changes.
36+
37+
## Additional Notes
38+
- **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).
39+
- No updates to `.exp` design documents or diagrams are necessary, as the PR reinforces existing designs without deviations requiring documentation.
40+
- Validation: Existing Mermaid diagrams in affected design docs were reviewed; syntax is valid (no `mmdc` needed for unchanged diagrams).

0 commit comments

Comments
 (0)