Skip to content

extend clippy_utils::path_to_local() to handle Cast expressions #14378

Closed as not planned
@benacq

Description

@benacq

Description

clippy_utils::path_to_local() currently accepts a Path expression and returns the canonical HirId of the local, example below:

let x: u32 = 40;

The Path expression for the variable x inside the Let statement will resolve correctly, however the variable b in the example below returns None when passed to the function, because the Path expression is wrapped inside a Cast expression.

let a: i32 = 10;

let b = a as u32;

Version

rustc 1.87.0-nightly (00f245915 2025-02-26)
binary: rustc
commit-hash: 00f245915b0c7839d42c26f9628220c4f1b93bf6
commit-date: 2025-02-26
host: aarch64-apple-darwin
release: 1.87.0-nightly
LLVM version: 20.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions