Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

borrow_as_ptr does not detect implicit casts due to coercions #14406

Open
RalfJung opened this issue Mar 14, 2025 · 1 comment · May be fixed by #14408
Open

borrow_as_ptr does not detect implicit casts due to coercions #14406

RalfJung opened this issue Mar 14, 2025 · 1 comment · May be fixed by #14408
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@RalfJung
Copy link
Member

RalfJung commented Mar 14, 2025

Summary

borrow_as_ptr should detect &expr in places where that is coerced to a raw pointer, and suggest &raw const expr instead (and similar for the mutable case)

Lint Name

borrow_as_ptr

Reproducer

I tried this code:

#![deny(clippy::borrow_as_ptr)]

fn main() {
    let val = 1;
    let p: *const i32 = &val;
}

I expected to see this happen:
the lint should fire

Instead, this happened:
it does not fire

Version

Clippy 0.1.85 (2025-02-17 4d91de4e48) on the playground
@RalfJung RalfJung added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Mar 14, 2025
@samueltardieu
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants