Skip to content
Open
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
25 changes: 25 additions & 0 deletions pr-analysis-16147.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# PR #16147: Workflow Design Impact Analysis

## Affected Workflows
None of the workflows defined in `.exp/workflows.json` are affected by this PR in terms of their design, components, sequences, or flows.

**Justification**:
- The PR modifies the implementation of the existing `let_and_return` lint in `clippy_lints/src/returns/let_and_return.rs` by adding a type check to avoid suggesting invalid casts for raw pointers.
- It also updates UI test files in `tests/ui/` to include a new test case and adjust expected outputs (`.stderr` and `.fixed` files) for different Rust editions.
- While these files are relevant to workflows like "lint-development" (workflow 5) and "testing" (workflow 4)—as they involve lint logic and UI tests—the changes are internal to a specific lint's behavior and test expectations. They do not introduce new steps, modify core components (e.g., scaffolding tools, driver registration, test orchestration), alter interactions, or require updates to the documented high-level designs or Mermaid diagrams in `.exp/design-workflow-*.md` files.
- Other workflows (e.g., "cargo-clippy", "clippy-driver") may experience behavioral improvements in lint accuracy, but their execution pipelines and designs remain unchanged.
- Evidence: Code diff shows a targeted conditional addition in lint pass logic; test diffs add a regression test and update outputs without altering test framework usage. No mentions of `let_and_return` or related changes in design documents.

[PR #16147](https://github.com/rust-lang/rust-clippy/pull/16147)

## General Summary of PR Changes
This PR fixes a bug in the `let_and_return` lint where it would incorrectly suggest an `as _` cast for expressions resulting in raw pointers, which is invalid in Rust.

### Key Changes:
- **Lint Logic Fix**: In `check_block` function of `let_and_return.rs`, the suggestion for coercing via `as _` now excludes cases where the adjusted expression type is a raw pointer (`*const T` or `*mut T`). This prevents invalid code suggestions.
- **Test Enhancements**:
- Added a new test case `issue16135()` demonstrating a raw pointer from `Box::into_raw()` to verify the fix.
- Updated expected lint messages and fixed outputs in `.stderr` and `.fixed` files for both Rust 2021 and 2024 editions to match the corrected behavior.
- **Implications**: Improves lint reliability and user experience by avoiding erroneous suggestions, potentially reducing false positives in auto-fixes via `--fix`. No performance or compatibility impacts noted. Aligns with Clippy's goal of providing accurate diagnostics and fixes.

No updates to design documents or Mermaid diagrams are required, as the high-level workflows remain intact. All existing diagrams in `.exp/` validate correctly without modification.