Skip to content

[ACP 362] genericize ptr::from_raw_parts #125701

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 30, 2024

Conversation

scottmcm
Copy link
Member

This implements rust-lang/libs-team#362

As such, it can partially undo #124795 , letting slice_from_raw_parts just call from_raw_parts again without re-introducing the unnecessary cast to MIR.

By doing this it also removes a spurious cast from str::from_raw_parts. And I think it does a good job of showing the value of the ACP, since the only thing that needed new turbofishing because of this is inside ptr::null(_mut), but only because ptr::without_provenance(_mut) doesn't support pointers to extern types, which it absolutely could (without even changing the implementation).

@rustbot
Copy link
Collaborator

rustbot commented May 29, 2024

r? @m-ou-se

rustbot has assigned @m-ou-se.
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 rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 29, 2024
@rust-log-analyzer

This comment has been minimized.

@scottmcm
Copy link
Member Author

Oh, the CI failure helpfully shows that anyone still having a cast gets a nice error suggesting

help: consider removing this method call, as the receiver has type *mut u8 and *mut u8: std::ptr::Thin trivially holds

@scottmcm scottmcm force-pushed the generic-from-raw-parts branch from 9285c3c to d2619ea Compare May 29, 2024 06:51
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the generic-from-raw-parts branch from d2619ea to 0d63e6b Compare May 29, 2024 16:34
@WaffleLapkin
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 29, 2024

📌 Commit 0d63e6b has been approved by WaffleLapkin

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 May 29, 2024
@WaffleLapkin WaffleLapkin assigned WaffleLapkin and unassigned m-ou-se May 29, 2024
fmease added a commit to fmease/rust that referenced this pull request May 29, 2024
…=WaffleLapkin

[ACP 362] genericize `ptr::from_raw_parts`

This implements rust-lang/libs-team#362

As such, it can partially undo rust-lang#124795 , letting `slice_from_raw_parts` just call `from_raw_parts` again without re-introducing the unnecessary cast to MIR.

By doing this it also removes a spurious cast from `str::from_raw_parts`.  And I think it does a good job of showing the value of the ACP, since the only thing that needed new turbofishing because of this is inside `ptr::null(_mut)`, but only because `ptr::without_provenance(_mut)` doesn't support pointers to extern types, which it absolutely could (without even changing the implementation).
bors added a commit to rust-lang-ci/rust that referenced this pull request May 30, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#125653 (Migrate `run-make/const-prop-lint` to `rmake.rs`)
 - rust-lang#125662 (Rewrite `fpic`, `simple-dylib` and `issue-37893` `run-make` tests in `rmake.rs` or ui test format)
 - rust-lang#125699 (Streamline `x fmt` and improve its output)
 - rust-lang#125701 ([ACP 362] genericize `ptr::from_raw_parts`)
 - rust-lang#125723 (Migrate `run-make/crate-data-smoke` to `rmake.rs`)
 - rust-lang#125733 (Add lang items for `AsyncFn*`, `Future`, `AsyncFnKindHelper`'s associated types)
 - rust-lang#125734 (ast: Revert a breaking attribute visiting order change)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 849ccc8 into rust-lang:master May 30, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 30, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 30, 2024
Rollup merge of rust-lang#125701 - scottmcm:generic-from-raw-parts, r=WaffleLapkin

[ACP 362] genericize `ptr::from_raw_parts`

This implements rust-lang/libs-team#362

As such, it can partially undo rust-lang#124795 , letting `slice_from_raw_parts` just call `from_raw_parts` again without re-introducing the unnecessary cast to MIR.

By doing this it also removes a spurious cast from `str::from_raw_parts`.  And I think it does a good job of showing the value of the ACP, since the only thing that needed new turbofishing because of this is inside `ptr::null(_mut)`, but only because `ptr::without_provenance(_mut)` doesn't support pointers to extern types, which it absolutely could (without even changing the implementation).
@scottmcm scottmcm deleted the generic-from-raw-parts branch May 30, 2024 17:47
egkoppel added a commit to popcorn-2/popcorn-2 that referenced this pull request May 31, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 12, 2024
…aw-parts, r=ibraheemdev

Generalize `NonNull::from_raw_parts` per ACP362

I did the raw pointers in rust-lang#125701, but apparently forgot `NonNull`.

cc rust-lang/libs-team#362
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2024
Rollup merge of rust-lang#132895 - scottmcm:generalize-nonnull-from-raw-parts, r=ibraheemdev

Generalize `NonNull::from_raw_parts` per ACP362

I did the raw pointers in rust-lang#125701, but apparently forgot `NonNull`.

cc rust-lang/libs-team#362
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants