|
| 1 | +# PR #16120: Workflow Design Impact Analysis |
| 2 | + |
| 3 | +## Affected Workflows |
| 4 | +- **Workflow 1 (cargo-clippy)**: The PR modifies the implementation of the `missing_asserts_for_indexing` lint in `clippy_lints/src/missing_asserts_for_indexing.rs`, which is executed as part of the lint passes during `cargo clippy` runs. This affects the diagnostic output generated by the workflow. Evidence: Changed file listed in relevant_files for this workflow; overhaul of diagnostics changes the format of emitted messages. [PR #16120](https://github.com/rust-lang/rust-clippy/pull/16120) |
| 5 | +- **Workflow 2 (clippy-driver)**: Similar to workflow 1, the refactored lint pass is registered and run when using the clippy-driver directly, impacting the diagnostics output. |
| 6 | +- **Workflow 4 (testing)**: Updates expected output files (`tests/ui/missing_asserts_for_indexing.stderr` and `tests/ui/missing_asserts_for_indexing_unfixable.stderr`) to match the new diagnostic format from the refactored lint. Evidence: Changed test files in `tests/ui/`. |
| 7 | +- **Workflow 5 (lint-development)**: The PR is an example of modifying an existing lint, refactoring its diagnostic reporting logic using advanced rustc_lint APIs. Evidence: Changes in `clippy_lints/src/` and corresponding UI tests. |
| 8 | + |
| 9 | +## Workflow 1 Analysis |
| 10 | +### Summary of design changes |
| 11 | +The PR refactors the diagnostic reporting in the `missing_asserts_for_indexing` LateLintPass: |
| 12 | +- Changes `span_lint_and_then` to use a `Vec<Span>` for multi-span coverage of all index expressions, allowing a single lint emission highlighting all relevant locations. |
| 13 | +- Replaces `span_suggestion` with `span_suggestion_verbose` for suggestions, computing `Applicability` dynamically using `snippet_with_applicability` to handle cases where snippet replacement may not be safe. |
| 14 | +- Uses `note_once` to emit the general advice only once, instead of repeating it and per-span notes. |
| 15 | +- Minor cleanups like passing `map` by value and removing redundant methods. |
| 16 | + |
| 17 | +These changes improve the quality of diagnostics output by the workflow: cleaner output with less redundancy, more accurate fix suggestions, and better spanning of issues. The high-level design (loading lints, registering passes, executing during compilation, outputting diagnostics) remains unchanged; this is an internal enhancement to one lint's implementation. |
| 18 | + |
| 19 | +**Affected diagram**: Integration sequence diagram in `.exp/design-workflow-1-cargo-clippy.md`. The step "Compiler->>User: output diagnostics from lints" now produces improved diagnostics for this specific lint, but no structural change. |
| 20 | + |
| 21 | +No updates to the Mermaid diagram are required, as the sequence and components are unaffected. However, for illustration, a diff version could highlight the output step: |
| 22 | + |
| 23 | +```mermaid |
| 24 | +sequenceDiagram |
| 25 | + participant User |
| 26 | + participant "cargo clippy" as CargoClippy |
| 27 | + participant "clippy-driver" as Driver |
| 28 | + participant "clippy_lints" as LintsCrate |
| 29 | + participant "LintStore" as Store |
| 30 | + participant Compiler as Rustc |
| 31 | + User->>CargoClippy: run cargo clippy on project |
| 32 | + CargoClippy->>Driver: invoke driver as rustc wrapper |
| 33 | + Driver->>LintsCrate: load and call register_lint_passes on store |
| 34 | + LintsCrate->>Store: extend early and late lint passes with lint impls |
| 35 | + Driver->>Store: create LintListBuilder, insert declared_lints LINTS, register lints and groups |
| 36 | + Driver->>Compiler: run compilation with registered lints |
| 37 | + Store->>Compiler: execute lint passes during compilation phases |
| 38 | + Note over Store,Compiler: Refactored lint uses multi-span linting and verbose suggestions |
| 39 | + Compiler->>User: output improved diagnostics from lints |
| 40 | +``` |
| 41 | + |
| 42 | +(Note: This is illustrative; original diagram unchanged.) |
| 43 | + |
| 44 | +### Potential benefits or implications |
| 45 | +- Benefits: Less verbose output, potentially more applicable fixes, better user experience. |
| 46 | +- Implications: Tests and users see updated diagnostic format; no impact on other lints or workflow correctness. |
| 47 | + |
| 48 | +## Workflow 2 Analysis |
| 49 | +### Summary of design changes |
| 50 | +Analogous to workflow 1, the refactor affects diagnostic output when invoking clippy-driver directly. The changes to lint pass reporting enhance the quality of emitted diagnostics without altering the driver initialization, lint registration, or compilation pipeline sequence. |
| 51 | + |
| 52 | +**Affected diagram**: Diagrams in `.exp/design-workflow-2-clippy-driver.md` (driver invocation and pipeline). No structural changes; improvement internal to lint execution. |
| 53 | + |
| 54 | +No Mermaid updates needed. |
| 55 | + |
| 56 | +### Potential benefits or implications |
| 57 | +Same as workflow 1; direct driver users benefit from better diagnostics for this lint. |
| 58 | + |
| 59 | +## Workflow 4 Analysis |
| 60 | +### Summary of design changes |
| 61 | +The PR updates the expected `.stderr` files for UI tests of the lint to reflect the new diagnostic format (multi-span underlines, consolidated notes, verbose suggestions). This ensures the testing workflow continues to correctly validate the lint's behavior post-refactor. The test execution sequence (spawn driver, compile test.rs, compare stderr) remains unchanged; only test data is adjusted. |
| 62 | + |
| 63 | +**Affected diagram**: UI Tests sequence diagram in `.exp/design-workflow-4-testing.md`, specifically the "Compare stderr with expected .stderr" step now matches updated expectations for improved diagnostics. |
| 64 | + |
| 65 | +No updates to Mermaid required. |
| 66 | + |
| 67 | +### Potential benefits or implications |
| 68 | +- Benefits: Tests accurately capture the new, improved diagnostic output. |
| 69 | +- Implications: When blessing tests, the new format is the standard for this lint. |
| 70 | + |
| 71 | +## Workflow 5 Analysis |
| 72 | +### Summary of design changes |
| 73 | +As a modification to an existing lint implementation, the PR demonstrates evolving lint code to use more advanced diagnostic APIs: |
| 74 | +- Multi-span lint emission for comprehensive issue coverage. |
| 75 | +- Dynamic applicability computation for suggestions. |
| 76 | +- Efficient note emission with `note_once`. |
| 77 | +This aligns with "Lint Implementation Details" in the design doc, enhancing diagnostic capabilities without changing scaffolding, update_lints generation, or integration sequences. |
| 78 | + |
| 79 | +**Affected diagram**: Integration and Execution sequence diagram in `.exp/design-workflow-5-lint-development.md`. The "execute lint passes" and "output diagnostics" steps benefit from better implementation practices, but no sequence change. |
| 80 | + |
| 81 | +No Mermaid updates needed. |
| 82 | + |
| 83 | +### Potential benefits or implications |
| 84 | +- Benefits: Serves as example for future lint development; improves this lint's effectiveness. |
| 85 | +- Implications: Encourages adoption of these APIs in other lints for consistency. |
0 commit comments