1
Fork 0
Commit graph

48 commits

Author SHA1 Message Date
Amos Onn
22b263ae18 Optimize core::ptr::align_offset
- As explained in the comment inside mod_inv, it is valid to work mod
  `usize::max_value()` right until the end.
2020-02-03 01:03:33 +01:00
Amos Onn
3173cd1473 Optimize core::ptr::align_offset
- When calculating the inverse, it's enough to work `mod a/g` instead
  of `mod a`.
2020-02-03 01:03:33 +01:00
Amos Onn
e835d0d761 Optimize core::ptr::align_offset
- Stopping condition inside mod_inv can be >= instead of >
- Remove intrinsics::unchecked_rem, we are working modulu powers-of-2 so
we can simply mask
2020-02-03 01:03:33 +01:00
bors
82018665a5 Auto merge of #68234 - CAD97:slice-from-raw-parts, r=KodrAus
Stabilize ptr::slice_from_raw_parts[_mut]

Closes #36925, the tracking issue.
Initial impl: #60667

r? @rust-lang/libs

In addition to stabilizing, I've adjusted the example of `ptr::slice_from_raw_parts` to use `slice_from_raw_parts` instead of `slice_from_raw_parts_mut`, which was unnecessary for the example as written.
2020-01-28 05:31:34 +00:00
Ralf Jung
79359315d6 get rid of real_drop_in_place again 2020-01-18 11:15:56 +01:00
CAD97
1c0d4851a6 Fix incorrect slice->ptr conversion in slice_from_raw_parts docs 2020-01-15 17:00:36 -05:00
CAD97
f76177ce43 Stabilize ptr::slice_from_raw_parts[_mut] 2020-01-14 20:15:39 -05:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mazdak Farrokhzad
eaeb1138c6
Rollup merge of #67480 - rossmacarthur:fix-41260-avoid-issue-0-part-2, r=Centril
Require issue = "none" over issue = "0" in unstable attributes

These changes make the use of `issue = "none"` required in unstable attributes throughout the compiler.

Notes:
- #66299 is now in beta so `issue = "none"` is accepted.
- The `tidy` tool now fails on `issue = "0"`.
- Tests that used `issue = "0"` were changed to use `issue = "none"`, except for _one_ that asserts `issue = "0"` can still be used.
- The compiler still allows `issue = "0"` because some submodules require it, this could be disallowed once these are updated.

Resolves #41260

r? @varkor
2019-12-22 02:40:04 +01:00
Mazdak Farrokhzad
f43ced3dbc
Rollup merge of #67462 - DutchGhost:const_slice_from_raw_parts, r=dtolnay
Make ptr::slice_from_raw_parts a const fn available under a feature flag

A first step in the direction of https://github.com/rust-lang/rust/issues/67456 .
This makes `ptr::slice_from_raw_parts` and `ptr::slice_from_raw_parts_mut` available as a const fn under a feature flag.
2019-12-21 15:29:47 +01:00
Ross MacArthur
f7256d28d1
Require issue = "none" over issue = "0" in unstable attributes 2019-12-21 13:16:18 +02:00
Dodo
382d370c4f Make ptr::slice_from_raw_parts a const fn available under a feature flag 2019-12-20 21:42:03 +01:00
Christoph Schmidler
12d65c28a6 Split up ptr/mod.rs in libcore, one with implementation detail for const ptr and the other with mut ptr 2019-12-19 09:01:26 +01:00
Mark Rousskov
82184440ec Propagate cfg bootstrap 2019-12-18 12:16:19 -05:00
Oliver Scherer
5e17e39881 Require stable/unstable annotations for the constness of all stable functions with a const modifier 2019-12-13 11:27:02 +01:00
David Tolnay
c737169fe5
Format libcore with rustfmt (including tests and benches) 2019-12-06 20:20:51 -08:00
David Tolnay
24d7f72c62
Suppress libcore/ptr/mod.rs filelength lint 2019-12-06 20:16:12 -08:00
CreepySkeleton
f11dd32f75 Use intra-doc links 2019-11-27 21:36:09 +03:00
CreepySkeleton
d411dd27bf Elaborate on std::ptr::{as_ref,as_mod} and clarify docs 2019-11-27 21:33:24 +03:00
Mark Rousskov
997feacddd Snap cfgs 2019-11-12 16:36:57 -05:00
Mazdak Farrokhzad
379b19c17f
Rollup merge of #63793 - oli-obk:🧹, r=dtolnay
Have tidy ensure that we document all `unsafe` blocks in libcore

cc @rust-lang/libs

I documented a few and added ignore flags on the other files. We can incrementally document the files, but won't regress any files this way.
2019-11-07 14:27:20 +01:00
Oliver Scherer
02f9167f94 Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
Ralf Jung
11a48a0423
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-05 21:50:55 +01:00
Ralf Jung
1a254e4f43 expand slice from_raw_part docs 2019-11-05 09:55:33 +01:00
Ralf Jung
82dc3aa5fb link from raw slice creation methods to safety requirements 2019-11-05 09:32:47 +01:00
bors
6c1b220fd7 Auto merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikic
Make <*const/mut T>::offset_from `const fn`

This reenables offset_of cc @mjbshaw 	after https://github.com/rust-lang/rust/pull/63075 broke it
2019-11-02 22:26:54 +00:00
Oliver Scherer
88b5e945e0 Make <*const/mut T>::offset_from const fn 2019-10-11 10:40:49 +02:00
Lzu Tao
d0862ec9b0 Inline ptr::null(_mut) even in debug builds 2019-10-02 12:22:37 +00:00
Lzu Tao
6c1b447f2e Remove unneeded fn main blocks from docs 2019-10-01 11:55:46 +00:00
Alexander Regueiro
b0006dff10 A few cosmetic improvements to code & comments in liballoc and libcore 2019-09-06 16:02:25 +01:00
Mazdak Farrokhzad
e9615f2487
Rollup merge of #63297 - RalfJung:ptr_offset, r=dtolnay
Improve pointer offset method docs

Cc @rkruppe @gnzlbg
2019-08-12 10:58:13 +02:00
Ralf Jung
0dc9e2a565 improve wrapping_ docs 2019-08-05 18:55:56 +02:00
Ralf Jung
aa72b1d3e3 note about stack-allocated variables being allocated objects 2019-08-05 18:41:33 +02:00
Ralf Jung
1f018636e3 improve align_offset docs 2019-08-05 18:38:10 +02:00
Bruce Mitchener
86633b6389 Fix typos in doc comments. 2019-08-02 01:36:36 +07:00
Mazdak Farrokhzad
b5bea2565e
Rollup merge of #61965 - phil-opp:patch-4, r=scottmcm
Remove mentions of removed `offset_to` method from `align_offset` docs

The `offset_to` method was deleted in https://github.com/rust-lang/rust/pull/52814.

The replacement for the removed method is `wrapping_offset_from`. However, neither method takes an `usize` as argument, so I don't think that it makes sense to mention them.
2019-07-30 05:37:30 +02:00
Philipp Oppermann
c9c73f5d25 Refer to add method instead of offset
The `align_offset` method returns an `usize`, so using `add` makes more sense than using `offset`, which takes an `isize`.
2019-07-17 17:25:43 +02:00
Simon Sapin
8040c54b08 Stabilize <*mut _>::cast and <*const _>::cast
FCP: https://github.com/rust-lang/rust/issues/60602#issuecomment-511146402
2019-07-16 08:51:53 +02:00
Freyskeyd
bc322af444
doc(ptr): add example for {read,write}_unaligned
Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
2019-07-09 16:55:00 +02:00
Mazdak Farrokhzad
d3569ddf32
Rollup merge of #62323 - Centril:clarify-read-unaligned, r=RalfJung
Clarify unaligned fields in ptr::{read,write}_unaligned

r? @RalfJung
2019-07-05 13:53:07 +02:00
Mazdak Farrokhzad
54527db7b0
ptr::{read,write}_unaligned: use no_run and reword slightly. 2019-07-04 09:54:37 +02:00
Mazdak Farrokhzad
bee964c502 Clarify unaligned fields in ptr::read_unaligned. 2019-07-04 05:32:38 +02:00
Ralf Jung
6225607e67 remove bogus example from drop_in_place 2019-07-03 20:14:59 +02:00
Julien Cretin
b8106b59d2 Fix meta-variable binding errors in macros
The errors are either:
- The meta-variable used in the right-hand side is not bound (or defined) in the
  left-hand side.
- The meta-variable used in the right-hand side does not repeat with the same
  kleene operator as its binder in the left-hand side. Either it does not repeat
  enough, or it uses a different operator somewhere.

This change should have no semantic impact.
2019-06-23 01:30:41 +02:00
Philipp Oppermann
fed12fad70
Remove mentions of removed offset_to method 2019-06-19 18:46:12 +02:00
Oliver Scherer
8b21b075f7 Add functions to build raw slices 2019-06-19 09:21:44 +02:00
Ralf Jung
00bae8774c note some safety concerns of raw-ptr-to-ref casts 2019-06-14 10:47:32 +02:00
Ralf Jung
c2e7eb6ff0 split core::ptr module into multiple files 2019-05-25 09:03:45 +02:00
Renamed from src/libcore/ptr.rs (Browse further)