-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix clippy::ref_as_ptr for non-temporary references in let/const #16214
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
Conversation
|
rustbot has assigned @samueltardieu. Use |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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? |
|
No changes for aefb01b |
|
Done |
|
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. |
|
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
Fix
ref_as_ptrfalse positives for temporary values and let/static/const initializers.Fixes #16220
changelog: [
ref_as_ptr]: Only lint on non-temporary expressions)