|
| 1 | +# PR #16172: Workflow Design Impact Analysis |
| 2 | + |
| 3 | +## Affected Workflows |
| 4 | +- **Workflow 5: lint-development**: The PR modifies the `use_self` lint implementation in `clippy_lints/src/use_self.rs` to fix a false positive on types in const generics, and updates corresponding UI tests. This directly impacts lint development and integration processes, as `clippy_lints/src/` and `tests/ui/` are key relevant files for this workflow. |
| 5 | +- **Workflow 4: testing**: Updates to `tests/ui/use_self.rs`, `tests/ui/use_self.fixed`, and `tests/ui/use_self.stderr` affect the UI test execution, validation, and blessing mechanisms in the testing workflow. |
| 6 | + |
| 7 | +## Workflow 5 Analysis (lint-development) |
| 8 | +### Summary of design changes |
| 9 | +Specific aspects affected: The lint implementation for `use_self` (a `LateLintPass`) is updated to handle types in const generic parameters correctly, avoiding false positive suggestions of `Self` in those contexts. This refines the analysis logic during the compilation pipeline's lint execution phase. |
| 10 | + |
| 11 | +How the PR implements these changes: |
| 12 | +- Adds import of `rustc_hir::Node`. |
| 13 | +- Introduces `ty_is_in_generic_args` function using HIR parent iteration to detect if the type is used in impl const params. |
| 14 | +- Adds `ty_contains_ty` for recursive type search in common container types. |
| 15 | +- Inserts condition `&& !ty_is_in_generic_args(cx, hir_ty)` in the type checking predicate. |
| 16 | + |
| 17 | +Potential benefits: Increases lint precision for code using const generics, reducing developer confusion from invalid suggestions. Implications: Aligns with Clippy's goal of reliable static analysis; may influence future lint designs handling generics. |
| 18 | + |
| 19 | +The \"Integration and Execution Sequence Diagram\" requires update to highlight the refined lint pass extension and execution. |
| 20 | + |
| 21 | +Updated diagram showing differences (yellow for changes, green for additions): |
| 22 | + |
| 23 | +```mermaid |
| 24 | +flowchart TD |
| 25 | + A[Driver loads clippy_lints] --> B[Extend LintStore with lint passes] |
| 26 | + B --> C[use_self LateLintPass - changed] |
| 27 | + C --> D[Traverse types in impl items] |
| 28 | + D --> E{Is type in const generic args? - new check} |
| 29 | + E -->|No| F[Proceed with Self replacement check] |
| 30 | + E -->|Yes| G[Skip suggestion - new behavior] |
| 31 | + F --> H[Span lint and suggest if applicable] |
| 32 | + style C fill:#ffff00 |
| 33 | + style E fill:#ffff00 |
| 34 | + style G fill:#90ee90 |
| 35 | + classDef change fill:#ffff00,stroke:#333,stroke-width:2px |
| 36 | + classDef addition fill:#90ee90,stroke:#333,stroke-width:2px |
| 37 | + class C change |
| 38 | + class E change |
| 39 | + class G addition |
| 40 | +``` |
| 41 | + |
| 42 | +## Workflow 4 Analysis (testing) |
| 43 | +### Summary of design changes |
| 44 | +Specific aspects affected: UI test inputs and expected outputs for the `use_self` lint are updated to incorporate a test case for const generics false positive fix. |
| 45 | + |
| 46 | +How the PR implements these changes: |
| 47 | +- `tests/ui/use_self.rs`: Adds or modifies code snippet using const generic type in impl to trigger (previously) FP. |
| 48 | +- `tests/ui/use_self.stderr`: Updates to reflect no lint diagnostic emitted post-fix. |
| 49 | +- `tests/ui/use_self.fixed`: Adjusts any expected fixed code if suggestions were involved. |
| 50 | + |
| 51 | +Potential benefits: Verifies the lint fix correctness, expands test coverage for generic features, ensures no regressions via output matching. Implications: Strengthens overall test suite robustness. |
| 52 | + |
| 53 | +The \"UI Tests Sequence Diagram\" requires update to note expanded test cases and updated validations. |
| 54 | + |
| 55 | +Updated diagram showing differences: |
| 56 | + |
| 57 | +```mermaid |
| 58 | +flowchart TD |
| 59 | + CT[Compile-Test runs] --> CD[Invoke clippy-driver on use_self.rs test] |
| 60 | + CD --> R[Run lints, including improved use_self] |
| 61 | + R --> V[Validate stderr against expected] |
| 62 | + subgraph PR Changes |
| 63 | + testFile[(tests/ui/use_self.rs <br/> + const generic case)]:::add |
| 64 | + stderr[(use_self.stderr updated <br/> no FP lint)]:::change |
| 65 | + fixed[(use_self.fixed updated)]:::change |
| 66 | + end |
| 67 | + CT -.-> testFile |
| 68 | + V -.-> stderr |
| 69 | + V -.-> fixed |
| 70 | + classDef add fill:#90ee90,stroke:#333,stroke-width:2px |
| 71 | + classDef change fill:#ffff00,stroke:#333,stroke-width:2px |
| 72 | + class testFile add |
| 73 | + class stderr change |
| 74 | + class fixed change |
| 75 | +``` |
| 76 | + |
| 77 | +## Validation |
| 78 | +All proposed Mermaid diagrams were validated using `mmdc` (mermaid-cli) to ensure syntactic correctness and renderability to SVG. |
| 79 | + |
| 80 | +No updates to original design documents in `.exp/` are required, as the PR does not alter the high-level workflow designs, sequences, or components—only internal implementation details of a specific lint and its tests. |
0 commit comments