Avoid a cast in `ptr::slice_from_raw_parts(_mut)` by scottmcm · Pull Request #124795 · rust-lang/rust
Casting to `*const ()` or `*mut ()` just bloats the MIR, so let's not. If ACP#362 goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.
rustbot
added
S-waiting-on-review
labels
May 6, 2024bors added a commit to rust-lang-ci/rust that referenced this pull request
May 7, 2024…ts, r=<try> Avoid a cast in `ptr::slice_from_raw_parts(_mut)` Casting to `*const ()` or `*mut ()` is no longer needed after rust-lang#123840 so let's make the MIR smaller (and more inline-able, as seen in the tests). If [ACP#362](rust-lang/libs-team#362) goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.
bors
added
S-waiting-on-bors
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.labels
May 8, 2024
scottmcm
deleted the
simplify-slice-from-raw-parts
branch
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).
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).
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
May 30, 2024Rollup 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).
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request
Jun 28, 2024…pkin [ACP 362] genericize `ptr::from_raw_parts` This implements rust-lang/libs-team#362 As such, it can partially undo rust-lang/rust#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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters