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

Add support for ptr::writes for the invalid_reference_casting lint #115100

Merged
merged 1 commit into from Aug 23, 2023

Conversation

Urgau
Copy link
Contributor

@Urgau Urgau commented Aug 22, 2023

This PR adds support for ptr::write and others for the invalid_reference_casting lint.

Detecting instances where instead of using the deref (*) operator to assign someone uses ptr::write, ptr::write_unaligned or ptr::write_volatile.

let data_len = 5u64;

std::ptr::write(
    std::mem::transmute::<*const u64, *mut u64>(&data_len),
    new_data_len,
);

r? @est31

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 22, 2023
@est31
Copy link
Member

est31 commented Aug 23, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 23, 2023

📌 Commit 7ee77b5 has been approved by est31

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 23, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 23, 2023
…es, r=est31

Add support for `ptr::write`s for the `invalid_reference_casting` lint

This PR adds support for `ptr::write` and others for the `invalid_reference_casting` lint.

Detecting instances where instead of using the deref (`*`) operator to assign someone uses `ptr::write`, `ptr::write_unaligned` or `ptr::write_volatile`.

```rust
let data_len = 5u64;

std::ptr::write(
    std::mem::transmute::<*const u64, *mut u64>(&data_len),
    new_data_len,
);
```

r? `@est31`
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 23, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#114930 (Automatically add OS labels to std PRs)
 - rust-lang#115053 (docs: Add example, reference link for `type` keyword.)
 - rust-lang#115092 (Add generics_of to smir)
 - rust-lang#115096 (Add regression test for not `memcpy`ing padding bytes)
 - rust-lang#115100 (Add support for `ptr::write`s for the `invalid_reference_casting` lint)
 - rust-lang#115114 (Contents of reachable statics is reachable)
 - rust-lang#115122 (Fix clippy lint for identical `if`/`else` contraining `?` expressions)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7257e9c into rust-lang:master Aug 23, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Aug 23, 2023
@Urgau Urgau deleted the invalid_ref_casting-ptr-writes branch August 23, 2023 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants