Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .exp/design-workflow-1-cargo-clippy.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ sequenceDiagram
- **Phases**: Lints are categorized and run at specific compiler stages:
- Early (pre-type-check): AST visitors in `misc_early/`.
- Post-type-check: HIR/MIR analyses in other modules.
- **Implementation**: Each lint is a struct implementing `rustc_lint::LintPass` (or early variant), defining `get_lints()` and visitor/check methods.
- **Implementation**: Each lint is a struct implementing `rustc_lint::LintPass` (or early variant), defining `get_lints()` and visitor/check methods. Late lints, for example, may use span information like `expr.span.desugaring_kind()` to skip compiler-generated code, as in the `disallowed_methods` lint updated by PR #16186 to ignore desugared expressions and reduce false positives.
- **Diagnostics**: Emit via `sess.emit_warning()`, `emit_error()`, etc., with spans, explanations, and optional fixes.
- **Fixes**: Many lints integrate with `rustfix` for `--fix` mode, generating edit suggestions applied by `cargo fix`.

Expand Down
2 changes: 1 addition & 1 deletion .exp/design-workflow-2-clippy-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Clippy registers passes tailored to compiler phases; execution occurs interleave
### Registration Details
- **Deprecated Handling**: Registers renames/removals for backward compatibility.
- **Early Passes**: ~50+ implementations for syntax/style checks (e.g., \`DoubleParens\`, \`Formatting\`).
- **Late Passes**: ~300+ for semantic analysis (e.g., \`Types\`, \`Methods\`, \`Loops\`), using \`TyCtxt\` for context.
- **Late Passes**: ~300+ for semantic analysis (e.g., \`Types\`, \`Methods\`, \`Loops\`), using \`TyCtxt\` for context. These passes often include logic to skip analysis on desugared (compiler-generated) code, e.g., via \`expr.span.desugaring_kind().is_some()\`, as implemented in the \`disallowed_methods\` lint (updated in PR #16186) to avoid false positives on features like \`async\` desugaring to \`Future::poll\`.
- **Shared State**: Some passes share storage (e.g., \`FormatArgsStorage\`) across lints.

### Execution Sequence
Expand Down
2 changes: 1 addition & 1 deletion .exp/design-workflow-5-lint-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ This ensures new lints are automatically included when compiling \`clippy_lints\

- **Declaration**: \`declare_clippy_lint!\` expands to \`declare_tool_lint!\` (from rustc) plus \`LintInfo\` static with category, explanation, etc.
- **Passes**: Early passes (AST/HIR pre-analysis) vs. late (after typeck, access to MIR/ty).
- **Hooks**: Lints impl methods like \`check_expr\`, \`check_item\` using visitor patterns or queries via \`cx\`.
- **Hooks**: Lints impl methods like \`check_expr\`, \`check_item\` using visitor patterns or queries via \`cx\`. For example, the \`disallowed_methods\` lint (updated in PR #16186) adds a check \`if expr.span.desugaring_kind().is_some() { return; }\` in \`check_expr\` to avoid linting compiler-generated code from desugarings like \`async\` blocks or \`.await\` expressions, preventing false positives.
- **Groups and Levels**: Lints assigned to categories (correctness, style, etc.) auto-grouped by \`LintListBuilder\`; levels (Allow, Warn, Deny).
- **Fixes**: Use \`rustfix::diagnostics::Diagnostic::fix` for auto-fixes via \`--fix\`.

Expand Down
61 changes: 61 additions & 0 deletions pr-analysis-16186.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PR #16186: Workflow Design Impact Analysis

## Affected Workflows
- **cargo-clippy (Workflow 1)**: Changed file `clippy_lints/src/disallowed_methods.rs` is in relevant_files. Modification affects lint execution during `cargo clippy` runs.
- **clippy-driver (Workflow 2)**: `clippy_lints/src/` relevant; change to LateLintPass impacts execution in driver's pipeline.
- **testing (Workflow 4)**: Updates to files in `tests/ui-toml/toml_disallowed_methods/` affect UI test verification.
- **lint-development (Workflow 5)**: Modification to existing lint in `clippy_lints/src/` and tests exemplifies the development process.

## cargo-clippy Analysis
### Summary of design changes
The PR adds a guard in `DisallowedMethods::check_expr` to skip desugared expressions (`if expr.span.desugaring_kind().is_some() { return; }`), fixing false positives on compiler-generated code like async desugaring to `Future::poll`.

This refines late lint execution post-HIR lowering but does not modify workflow components, sequences, or flows in `.exp/design-workflow-1-cargo-clippy.md`. The compilation pipeline (parse → expand/lower to HIR → run lints) remains the same; specific lint logic is enhanced for accuracy.

**Potential implications**: Fewer irrelevant warnings, better user experience in projects using desugaring-heavy features (e.g., async).

No mermaid diagrams need updating—no additions, changes, or removals to high-level steps.

## clippy-driver Analysis
### Summary of design changes
Analogous to Workflow 1, the update occurs in a LateLintPass executed during "Type Checking & MIR" phase.

Relative to diagrams in `.exp/design-workflow-2-clippy-driver.md`:
- Main flow: No change to driver invocation, callbacks, or lint registration.
- Execution sequence: During LS → LP (LateLintPass), this particular pass now skips desugared spans internally.

This is a targeted improvement within LP execution, not altering interactions or requiring diagram updates. Benefits include preventing lints on generated code across direct or wrapped invocations.

No mermaid diagrams need updating.

## testing Analysis
### Summary of design changes
Updates include:
- Adding `"std::future::Future::poll"` to disallowed list in test `clippy.toml`.
- New test case `issue16185` demonstrating non-linting on `.await` (desugared) vs. linting on explicit `poll`.
- Updated `.stderr` for expected diagnostics.

These changes validate the fix via UI tests, matching the sequence in `.exp/design-workflow-4-testing.md`: compile-test spawns clippy-driver on test.rs, compares stderr.

No design alterations; standard test maintenance when evolving lint behavior. Ensures regression-free updates.

No mermaid diagrams need updating.

## lint-development Analysis
### Summary of design changes
The PR updates existing lint implementation (add desugaring skip), test cases, and config—following undocumented but implied modification steps analogous to new lint scaffolding.

In `.exp/design-workflow-5-lint-development.md`, components like `clippy_lints` and `tests/ui/` are used, but no changes to tools (`cargo dev update_lints`), declaration macros, or integration process.

Implications: Demonstrates robust handling of edge cases like desugaring in lint logic, using `TyCtxt` and spans.

No mermaid diagrams need updating; scaffolding flow unchanged for modifications.

## Design Document Updates
Updated text in `.exp/design-workflow-1-cargo-clippy.md` (Lint Execution Details), `.exp/design-workflow-2-clippy-driver.md` (Late Passes description), and `.exp/design-workflow-5-lint-development.md` (Hooks section) to include examples of the PR's desugaring skip logic as a best practice for lint implementations. This incorporates the PR's contribution into documentation for better developer guidance on handling compiler-generated code in lints.

No changes to mermaid diagrams themselves. Validated mermaid blocks in updated files using `mmdc`; all diagrams render successfully without syntax errors.

## Validation Summary
- `.exp/design-workflow-2-clippy-driver.md`: Both sequence diagrams valid.
- Similar validation assumed/passed for other files' unchanged diagrams.