Skip to content

Conversation

@Abd002
Copy link
Contributor

@Abd002 Abd002 commented Dec 10, 2025

Fix ref_as_ptr false positives for temporary values and let/static/const initializers.

Fixes #16220

changelog: [ref_as_ptr]: Only lint on non-temporary expressions)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 10, 2025

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Dec 10, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Dec 10, 2025
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) has-merge-commits PR has merge commits, merge with caution. labels Dec 10, 2025
@samueltardieu
Copy link
Member

Thanks for your contribution.

Could you either link to an issue describing the problem (or open one, and marked it closed by this pull-request), or make sure you describe it (and include tests that failed before) in the commit description?

@github-actions
Copy link

github-actions bot commented Dec 12, 2025

No changes for aefb01b

@Abd002
Copy link
Contributor Author

Abd002 commented Dec 12, 2025

Done

@Jarcho
Copy link
Contributor

Jarcho commented Dec 12, 2025

You have the wrong conditions here. This can't lint if the cast is in a context that supports lifetime extension and the casted expression is a borrow of a temporary. All other cases are ok to lint.

@Jarcho
Copy link
Contributor

Jarcho commented Dec 13, 2025

You're missing tests for additional things that should lint now. e.g.

let _ = &x as *const _;
let _ = &*x as *const _;
let _ = &x.0 as *const _;

@Abd002
Copy link
Contributor Author

Abd002 commented Dec 13, 2025

You're missing tests for additional things that should lint now. e.g.

let _ = &x as *const _;
let _ = &*x as *const _;
let _ = &x.0 as *const _;

Tests are included

Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jarcho Jarcho added this pull request to the merge queue Dec 13, 2025
Merged via the queue into rust-lang:master with commit f206ef8 Dec 13, 2025
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify and refine “temporary” handling in ref_as_ptr lint

4 participants