Guillaume Gomez
616ee876c1
Rollup merge of #59427 - czipperz:non_null_doc_links, r=Mark-Simulacrum
...
Link to PhantomData in NonNull documentation
2019-03-26 22:26:45 +01:00
Mazdak Farrokhzad
0b46f0e649
bump bootstrap; adjust stage0 uses in core::ptr.
2019-03-26 09:57:25 +01:00
Chris Gregory
fd42918a41
Link to PhantomData in NonNull documentation
2019-03-25 18:04:42 -04:00
Mazdak Farrokhzad
3623c1ac4e
Rollup merge of #59130 - RalfJung:non-null, r=rkruppe
...
Note that NonNull does not launder shared references for mutation
See https://users.rust-lang.org/t/relative-pointer-an-abstraction-to-build-movable-self-referential-types/26186/6
2019-03-13 03:33:54 +01:00
Ralf Jung
8ec8639bf3
expand
2019-03-12 13:44:09 +01:00
Ralf Jung
7fcdb93cf5
Note that NonNull does not launder shared references for mutation
2019-03-12 13:41:12 +01:00
Scott McMurray
df4ea90b39
Use lifetime contravariance to elide more lifetimes in core+alloc+std
2019-03-09 19:10:28 -08:00
Mazdak Farrokhzad
f1e317b713
Rollup merge of #58750 - TimDiekmann:master, r=oli-obk
...
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
2019-03-09 17:18:21 +01:00
Tim
797d8ea478
Make Unique::as_ptr, NonNull::dangling and NonNull::cast const
...
Make `Unique::as_ptr` const without feature attribute as it's unstable
Make `NonNull::dangling` and `NonNull::cast` const with `feature = "const_ptr_nonnull"`
2019-02-28 07:32:13 +01:00
Ralf Jung
d10366fe27
avoid unnecessary use of MaybeUninit::get_ref, and expand comment on the others
2019-02-22 23:05:58 +01:00
Alexander Regueiro
99ed06eb88
libs: doc comments
2019-02-10 23:57:25 +00:00
Alexander Regueiro
b87363e763
tests: doc comments
2019-02-10 23:42:32 +00:00
Ralf Jung
9a460aac37
some type-level docs for MaybeUninit; rename into_inner -> into_initialized
2019-02-03 22:10:39 +01:00
Pietro Albini
d158ef64e8
Revert "Auto merge of #57670 - rust-lang:beta-next, r=Mark-Simulacrum"
...
This reverts commit 722b4d6959 , reversing
changes made to 956dba47d3 .
2019-01-17 10:48:10 +01:00
Pietro Albini
b54a00accd
allow unused warnings related to rustc_layout_scalar_valid_range_start
2019-01-16 18:20:08 +01:00
Dylan MacKenzie
68b8b438c3
Add link destination for read-ownership
2019-01-07 21:03:41 -08:00
kennytm
9223512fbe
Removed aligned ZST requirement from docs of read_/write_unaligned.
...
This is just a copy-paste error.
2018-12-28 22:00:33 +08:00
Simon Sapin
7a09115280
Remove the private generic NonZero<T> wrapper type.
...
Instead, use `#[rustc_layout_scalar_valid_range_start(1)]` directly
on relevant libcore types.
2018-12-26 20:54:10 +01:00
Mark Rousskov
2a663555dd
Remove licenses
2018-12-25 21:08:33 -07:00
Mazdak Farrokhzad
3552499010
Rollup merge of #56706 - oli-obk:const_unsafe_fn, r=Centril
...
Make `const unsafe fn` bodies `unsafe`
r? @Centril
Updated for tracking issue discussion https://github.com/rust-lang/rust/issues/55607#issuecomment-445882296
2018-12-16 14:08:22 +01:00
Pietro Albini
7c83737b44
Rollup merge of #56751 - mbrubeck:hash, r=dtolnay
...
Allow ptr::hash to accept fat pointers
Fat pointers implement Hash since #45483 . This is a follow-up to #56250 .
2018-12-15 10:17:35 +01:00
bors
9fe5cb5342
Auto merge of #56161 - RalfJung:vecdeque-stacked-borrows, r=SimonSapin
...
VecDeque: fix for stacked borrows
`VecDeque` violates a version of stacked borrows where creating a shared reference is not enough to make a location *mutably accessible* from raw pointers (and I think that is the version we want). There are two problems:
* Creating a `NonNull<T>` from `&mut T` goes through `&T` (inferred for a `_`), then `*const T`, then `NonNull<T>`. That means in this stricter version of Stacked Borrows, we cannot actually write to such a `NonNull` because it was created from a shared reference! This PR fixes that by going from `&mut T` to `*mut T` to `*const T`.
* `VecDeque::drain` creates the `Drain` struct by *first* creating a `NonNull` from `self` (which is an `&mut VecDeque`), and *then* calling `self.buffer_as_mut_slice()`. The latter reborrows `self`, asserting that `self` is currently the unique pointer to access this `VecDeque`, and hence invalidating the `NonNull` that was created earlier. This PR fixes that by instead using `self.buffer_as_slice()`, which only performs read accesses and creates only shared references, meaning the raw pointer (`NonNull`) remains valid.
It is possible that other methods on `VecDeque` do something similar, miri's test coverage of `VecDeque` is sparse to say the least.
Cc @nikomatsakis @Gankro
2018-12-13 07:12:19 +00:00
Matt Brubeck
8a6ca24bcb
Allow ptr::hash to accept fat pointers
2018-12-12 09:41:03 -08:00
Oliver Scherer
8d0b64f16d
Make const unsafe fn bodies unsafe
2018-12-11 10:27:00 +01:00
Mazdak Farrokhzad
7f076fa521
Rollup merge of #56602 - dwijnand:fix-ptr-hash-docs, r=Centril
...
Fix the just-introduced ptr::hash docs
Follow-up to #56250 .
2018-12-08 08:43:48 +01:00
Alexander Regueiro
ee89c088b0
Various minor/cosmetic improvements to code
2018-12-07 23:53:34 +00:00
Dale Wijnand
ba3db7b03a
grammar
2018-12-07 17:34:53 +01:00
Dale Wijnand
1ac066ef04
Fix the just-introduced ptr::hash docs
2018-12-07 17:33:32 +01:00
Ralf Jung
21b5950cf9
Unique/NonNull::from: make sure we convert to raw pointers ASAP
...
By going through a shared reference, we share the destination as read-only, meaning we can read but not write with the raw pointers
2018-12-07 09:20:54 +01:00
kennytm
6d3501ebe3
Rollup merge of #56250 - dwijnand:ptr-hash, r=alexcrichton
...
Introduce ptr::hash for references
The RHS is what I used, which wasn't as convenient as `ptr::eq`, so I wondered: should `ptr::hash` exist?
My first Rust PR, so I'm going to need some guidance. :)
2018-12-07 12:42:30 +08:00
Oliver Scherer
3ce211dbd0
Increase code-reuse and -readability
2018-12-04 10:17:37 +01:00
Oliver Scherer
02b22323f1
Make sure the initialization of constrained int range newtypes is unsafe
2018-12-04 10:17:36 +01:00
Dale Wijnand
ad765695d1
Fix ptr::hash, just hash the raw pointer
2018-12-04 08:06:26 +00:00
Dale Wijnand
6fab3f9c69
Make ptr::hash take a raw painter like ptr::eq
2018-12-04 07:48:22 +00:00
bors
d3ed34824c
Auto merge of #56165 - RalfJung:drop-glue-type, r=eddyb,nikomatsakis
...
drop glue takes in mutable references, it should reflect that in its type
When drop glue begins, it should retag, like all functions taking references do. But to do that, it needs to take the reference at a proper type: `&mut T`, not `*mut T`.
Failing to retag can mean that the memory the reference points to remains frozen, and `EscapeToRaw` on a frozen location is a NOP, meaning later mutations cause a Stacked Borrows violation.
Cc @nikomatsakis @Gankro because Stacked Borrows
Cc @eddyb for the changes to miri argument passing (the intention is to allow passing `*mut [u8]` when `&mut [u8]` is expected and vice versa)
2018-12-01 07:06:17 +00:00
Dale Wijnand
097b5db5f6
Move feature enable in ptr::hash doc example
2018-11-27 21:18:20 +00:00
Dale Wijnand
9755410f73
Try to fix ptr::hash's doc example
2018-11-27 20:09:21 +00:00
Dale Wijnand
4a7ffe2646
Fix issue number
2018-11-27 16:46:59 +00:00
Dale Wijnand
afb4fbd951
Add an assert_eq in ptr::hash's doc example
2018-11-27 16:46:24 +00:00
Dale Wijnand
81251491dd
Pick a better variable name for ptr::hash
2018-11-27 16:33:01 +00:00
Dale Wijnand
7b429b0440
Fix stability attribute for ptr::hash
2018-11-27 16:32:41 +00:00
Dale Wijnand
5558c07c6e
Fix ptr::hex doc example
2018-11-26 21:31:12 +00:00
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
Ralf Jung
5e27ee76b6
use MaybeUninit in core::ptr::swap_nonoverlapping_bytes
...
Code by @japaric, I just split it into individual commits
2018-11-23 22:50:20 +01:00
Ralf Jung
3fb03d0650
use MaybeUninit in core::ptr::swap
...
Code by @japaric, I just split it into individual commits
2018-11-23 22:50:20 +01:00
Ralf Jung
0bb2e2d6d4
use MaybeUninit in core::ptr::{read,read_unaligned}
...
Code by @japaric, I just split it into individual commits
2018-11-23 22:50:20 +01:00
Ralf Jung
af9b057156
drop glue takes in mutable references, it should reflect that in its type
2018-11-22 16:08:58 +01: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