Dale Wijnand
86d20f9342
FIXME is the new TODO
2018-11-26 19:23:20 +00:00
Dale Wijnand
47b5e23e6b
Introduce ptr::hash for references
2018-11-26 18:36:03 +00:00
Steve Klabnik
d7b3f5c6ae
update various stdlib docs
2018-11-21 06:50:17 -05:00
bors
65204a97d4
Auto merge of #55278 - Centril:constification-1, r=alexcrichton
...
Minor standard library constification
This PR makes some bits of the standard library into `const fn`s.
I've tried to be as aggressive as I possibly could in the constification.
The list is rather small due to how restrictive `const fn` is at the moment.
r? @oli-obk cc @rust-lang/libs
Stable public APIs affected:
+ [x] `Cell::as_ptr`
+ [x] `UnsafeCell::get`
+ [x] `char::is_ascii`
+ [x] `iter::empty`
+ [x] `ManuallyDrop::{new, into_inner}`
+ [x] `RangeInclusive::{start, end}`
+ [x] `NonNull::as_ptr`
+ [x] `{[T], str}::as_ptr`
+ [x] `Duration::{as_secs, subsec_millis, subsec_micros, subsec_nanos}`
+ [x] `CStr::as_ptr`
+ [x] `Ipv4Addr::is_unspecified`
+ [x] `Ipv6Addr::new`
+ [x] `Ipv6Addr::octets`
Unstable public APIs affected:
+ [x] `Duration::{as_millis, as_micros, as_nanos, as_float_secs}`
+ [x] `Wrapping::{count_ones, count_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, reverse_bits, from_be, from_le, to_be, to_le, leading_zeros, is_positive, is_negative, leading_zeros}`
+ [x] `core::convert::identity`
--------------------------
## Removed from list in first pass:
Stable public APIs affected:
+ [ ] `BTree{Map, Set}::{len, is_empty}`
+ [ ] `VecDeque::is_empty`
+ [ ] `String::{is_empty, len}`
+ [ ] `FromUtf8Error::utf8_error`
+ [ ] `Vec<T>::{is_empty, len}`
+ [ ] `Layout::size`
+ [ ] `DecodeUtf16Error::unpaired_surrogate`
+ [ ] `core::fmt::{fill, width, precision, sign_plus, sign_minus, alternate, sign_aware_zero_pad}`
+ [ ] `panic::Location::{file, line, column}`
+ [ ] `{ChunksExact, RChunksExact}::remainder`
+ [ ] `Utf8Error::valid_up_to`
+ [ ] `VacantEntry::key`
+ [ ] `NulError::nul_position`
+ [ ] `IntoStringError::utf8_error`
+ [ ] `IntoInnerError::error`
+ [ ] `io::Chain::get_ref`
+ [ ] `io::Take::{limit, get_ref}`
+ [ ] `SocketAddrV6::{flowinfo, scope_id}`
+ [ ] `PrefixComponent::{kind, as_os_str}`
+ [ ] `Path::{ancestors, display}`
+ [ ] `WaitTimeoutResult::timed_out`
+ [ ] `Receiver::{iter, try_iter}`
+ [ ] `thread::JoinHandle::thread`
+ [ ] `SystemTimeError::duration`
Unstable public APIs affected:
+ [ ] `core::fmt::Arguments::new_v1`
+ [ ] `core::fmt::Arguments::new_v1_formatted`
+ [ ] `Pin::{get_ref, into_ref}`
+ [ ] `Utf8Lossy::chunks`
+ [ ] `LocalWaker::as_waker`
+ [ ] `panic::PanicInfo::{internal_constructor, message, location}`
+ [ ] `panic::Location::{internal_constructor }`
## Removed from list in 2nd pass:
Stable public APIs affected:
+ [ ] `LinkedList::{new, iter, is_empty, len}`
+ [ ] `mem::forget`
+ [ ] `Cursor::{new, get_ref, position}`
+ [ ] `io::{empty, repeat, sink}`
+ [ ] `PoisonError::new`
+ [ ] `thread::Builder::new`
+ [ ] `process::Stdio::{piped, inherit, null}`
Unstable public APIs affected:
+ [ ] `io::Initializer::{zeroing, should_initialize}`
2018-11-12 18:54:11 +00:00
Bruce Mitchener
9b4d68e53b
Fix documentation typos.
2018-11-10 19:31:49 +07:00
Mazdak Farrokhzad
e15c62d61f
revert making internal APIs const fn.
2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
5b89877dda
constify parts of libcore.
2018-11-10 01:07:32 +01:00
Michael Hewson
f12c250e40
Replace CoerceSized trait with DispatchFromDyn
...
Rename `CoerceSized` to `DispatchFromDyn`, and reverse the direction so that, for example, you write
```
impl<T: Unsize<U>, U> DispatchFromDyn<*const U> for *const T {}
```
instead of
```
impl<T: Unsize<U>, U> DispatchFromDyn<*const T> for *const U {}
```
this way the trait is really just a subset of `CoerceUnsized`.
The checks in object_safety.rs are updated for the new trait, and some documentation and method names in there are updated for the new trait name — e.g. `receiver_is_coercible` is now called `receiver_is_dispatchable`. Since the trait now works in the opposite direction, some code had to updated here for that too.
I did not update the error messages for invalid `CoerceSized` (now `DispatchFromDyn`) implementations, except to find/replace `CoerceSized` with `DispatchFromDyn`. Will ask for suggestions in the PR thread.
2018-11-01 18:16:59 -04:00
Michael Hewson
192900e7c2
Add CoerceSized impls throughout libstd
...
This will make receiver types like `Rc<Self>` and `Pin<&mut Self>`
object-safe.
2018-11-01 18:16:22 -04:00
Alex Crichton
d0060d72e5
Bump nightly to 1.32.0
...
* Also update the bootstrap compiler
* Update cargo to 1.32.0
* Clean out stage0 annotations
2018-10-31 11:53:50 -07:00
Nick Fitzgerald
dc77d49775
Make a bunch of trivial methods of NonNull be #[inline]
2018-10-28 00:59:04 +02:00
Matthias Krüger
4972beaf65
fix typos in various places
2018-10-23 15:56:25 +02:00
Jan Niehusmann
6cc84acc60
remove unnecessary emphasis in doc comment
...
During review of the previous commit, @joshtriplett noticed that
the emphasis on 'the same' is unnecessary. For consistency, remove it
on the offset() functions, as well.
2018-10-14 20:26:23 +00:00
Jan Niehusmann
e8ec4987a8
clarify pointer add/sub function safety concerns
...
Ralf Jung made the same changes to the offset functions' documentation
in commit fb089156
. As add/sub just call offset, the same limitation
applies here, as well.
Removed emphasis on review request by @joshtriplett
2018-10-14 20:24:01 +00:00
bors
8dc554a325
Auto merge of #54534 - nagisa:align-offset-simplification, r=alexcrichton
...
Simplify implementation of align_offset slightly
2018-10-12 06:38:11 +00:00
Oliver Schneider
9e46c0b689
Only promote calls to #[rustc_promotable]
const fns
2018-10-03 10:07:05 +02:00
Simonas Kazlauskas
0b3e5eb6cc
Simplify implementation of align_offset slightly
2018-09-30 16:27:13 +03:00
Ralf Jung
e37d6d37e7
Revert "Auto merge of #53508 - japaric:maybe-uninit, r=RalfJung"
...
This reverts commit c6e3d7fa31
, reversing
changes made to 4591a245c7
.
2018-09-29 09:50:50 +02:00
bors
70073ec61d
Auto merge of #53783 - RalfJung:ptr-docs, r=alexcrichton
...
Rewrite docs for pointer methods
This takes over https://github.com/rust-lang/rust/pull/51016 by @ecstatic-morse. They did most of the work, I just did some editing.
However, I realized one problem: This updates the docs for the "free functions" in `core::ptr`, but it does not update the copies of these docs for the inherent methods of the `*const T` and `*mut T` types. These getting out-of-sync is certainly bad, but I also don't feel like copying all this stuff around. Instead, we should remove this redundancy. Any good ideas?
2018-09-24 17:36:44 +00:00
Jorge Aparicio
af101fdc33
address Mark-Simulacrum comments
2018-09-22 21:01:21 +02:00
Jorge Aparicio
851acdd22d
core: fix deprecated warnings
2018-09-22 21:01:21 +02:00
Ralf Jung
adcc0d2168
clarify swap
2018-09-18 21:14:31 +02:00
Ralf Jung
0ec87d0c92
rearrange for clarity
2018-09-17 15:21:20 +02:00
Ralf Jung
2713d36679
tweaks
2018-09-17 15:14:19 +02:00
Nicole Mazzuca
78f5b6866e
fix typos
2018-09-10 22:30:30 -07:00
Ralf Jung
bc809e01ee
remark on concurrency in validity section
2018-09-01 18:00:10 +02:00
Ralf Jung
755de3c684
Valid raw pointers
2018-09-01 17:50:54 +02:00
Ralf Jung
408a6a00c2
fix doctests
2018-08-31 18:47:41 +02:00
Ralf Jung
b463871df5
(un)aligned
2018-08-31 17:02:39 +02:00
Ralf Jung
dc2237c49f
apply feedback
2018-08-31 17:01:53 +02:00
Ralf Jung
4ed469c483
turn ptr type method docs into links to docs of free functions, to avoid duplication and inconsistency
2018-08-31 09:54:37 +02:00
Ralf Jung
18a7bdb568
fix example
2018-08-30 18:05:49 +02:00
Ralf Jung
274122426e
fix example
2018-08-30 17:48:34 +02:00
Ralf Jung
c06f5517dc
improve volatile comments
2018-08-30 17:37:58 +02:00
Ralf Jung
e869b81b93
address remaining remarks and add example for dropping unaligned data
2018-08-30 17:07:24 +02:00
Ralf Jung
1ec66fb4b2
apply comments
2018-08-30 16:26:48 +02:00
Ralf Jung
fc63113f1f
clarify ZST comment
2018-08-30 16:19:05 +02:00
Ralf Jung
098bec82f6
clarify that these are preliminary guarantees
2018-08-29 19:27:20 +02:00
Ralf Jung
b0c5dc2cc1
edit docs a little
2018-08-29 14:34:59 +02:00
Dylan MacKenzie
c8da321581
Resolve null/ZST conflict correctly (whoops)
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
7e165d90a6
Add a list of known facts re: validity
...
Also rewrites the reads/writes section to be less reliant on `*const`,
`*mut`
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
95a9088603
You can't make an omlette without breaking a few links
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
3a55c85c33
Incorporate RalfJung's suggestions
...
This splits "valid" into "valid for reads" and "valid for writes", and
also adds the concept of operation size to validity. Now functions which
operate on sequences state that e.g. pointer args must be "valid for reads of
size x".
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
ea5570cf27
Redefine range validity
...
Uses `x.offset(i)` must be valid for all `i` in `0..count`.
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
e40585f248
Remove definiton of valid pointer
...
The enumerated list of conditions is replaced by an explanation that
rust doesn't have a formal memory model. It does say that pointers
created directly from references are guaranteed to be valid, and links
to both the "Unsafe Code" section of the book and the "Undefined
Behavior" section of the reference.
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
30122e91d9
Fix off-by-one error when specifying a valid range
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
6f7338bb92
Reword module level docs re: alignment
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
7b2ef6bd77
Update docs for swap_nonoverlapping
...
They closely mirror the docs for `copy_nonoverlapping`
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
04a08c60a1
Fix unused variable warning in doctest
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
9f5a3cccb8
Fix failing doctests
2018-08-29 10:10:58 +02:00