Migrate libraries from ptr::slice_from_raw_parts to .cast_slice#156109
Migrate libraries from ptr::slice_from_raw_parts to .cast_slice#156109Paladynee wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
cc @Amanieu, @folkertdev, @sayantn |
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
some notable places like core::slice::from_raw_parts have not been updated, because i felt like changing that would harm readability than improving it. |
This comment has been minimized.
This comment has been minimized.
|
hmm wait let me revert that doc change, apparently it is exactly the same in |
This comment has been minimized.
This comment has been minimized.
5533d7b to
fced58f
Compare
|
Could |
Aside from this, |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
i believe they are equivalent other than the debug UB assertion, yes |
|
I'm not touching anything in;
with that, i think this pr is ready @rustbot ready |
fced58f to
e030a3f
Compare
The |
e030a3f to
14315f9
Compare
done |
|
@bors r+ rollup |
…nts, r=jhpratt Migrate libraries from ptr::slice_from_raw_parts to .cast_slice Tracking issue for `#![feature(ptr_cast_slice)]`: rust-lang#149103 This commit updates most callsites of ptr::slice_from_raw_parts within ./library to the more concise but unstable postfix `.cast_slice()` method on raw pointers, using the `ptr_cast_slice` feature. Some tests in alloctests have also been updated. No functional change, debatably improved readability.
Rollup of 14 pull requests Successful merges: - #146273 (lint ImproperCTypes: refactor linting architecture (part 2)) - #149509 (Lint unused pub items in binary crates) - #156173 (Fewer global node_id_to_def_id lookups) - #156177 (windows/time: avoid being too close to 0) - #155961 (Deny warnings in the test for crates that are available on stable) - #155981 (Use special DefIds for aliases) - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice) - #156130 (Fold/visit tweaks) - #156131 (Metadata macro/query cleanups) - #156202 (llvm: Use correct type for splat mask) - #156227 (Add Trusty OS to the generic error implementation.) - #156237 (compiletest: prevent directives from having multiple revisions) - #156241 (Move tests coercion) - #156258 (Document wasi-sdk minimum versions for WASI targets)
|
This pull request was unapproved. This PR was contained in a rollup (#156263), which was unapproved. |
| assert_eq!(size % elem_size, 0); | ||
| let len = size / elem_size; | ||
| ptr::slice_from_raw_parts_mut(ptr as _, len) | ||
| (ptr as _).cast_slice(len) |
There was a problem hiding this comment.
error[E0282]: type annotations needed
--> /rustc/620725bffcba2613fa6243f559657c2bedb5615f/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs:154:9
|
154 | (ptr as _).cast_slice(len)
| ^^^^^^^^^^ cannot infer type
https://github.com/rust-lang/rust/actions/runs/25475505562/job/74748095499#step:28:10939
Tracking issue for
#![feature(ptr_cast_slice)]: #149103This commit updates most callsites of ptr::slice_from_raw_parts within ./library to the more concise but unstable postfix
.cast_slice()method on raw pointers, using theptr_cast_slicefeature. Some tests in alloctests have also been updated.No functional change, debatably improved readability.