about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
AgeCommit message (Collapse)AuthorLines
2019-02-10libs: doc commentsAlexander Regueiro-3/+3
2019-02-10tests: doc commentsAlexander Regueiro-8/+8
2019-02-03some type-level docs for MaybeUninit; rename into_inner -> into_initializedRalf Jung-2/+2
2019-01-17Revert "Auto merge of #57670 - rust-lang:beta-next, r=Mark-Simulacrum"Pietro Albini-16/+0
This reverts commit 722b4d695964906807b12379577bce5ee3d23e08, reversing changes made to 956dba47d33fc8b2bdabcd50e5bfed264b570382.
2019-01-16allow unused warnings related to rustc_layout_scalar_valid_range_startPietro Albini-0/+16
2019-01-07Add link destination for `read-ownership`Dylan MacKenzie-0/+1
2018-12-28Removed aligned ZST requirement from docs of read_/write_unaligned.kennytm-2/+2
This is just a copy-paste error.
2018-12-26Remove the private generic NonZero<T> wrapper type.Simon Sapin-14/+15
Instead, use `#[rustc_layout_scalar_valid_range_start(1)]` directly on relevant libcore types.
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-16Rollup merge of #56706 - oli-obk:const_unsafe_fn, r=CentrilMazdak Farrokhzad-1/+1
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-15Rollup merge of #56751 - mbrubeck:hash, r=dtolnayPietro Albini-1/+1
Allow ptr::hash to accept fat pointers Fat pointers implement Hash since #45483. This is a follow-up to #56250.
2018-12-13Auto merge of #56161 - RalfJung:vecdeque-stacked-borrows, r=SimonSapinbors-4/+4
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-12Allow ptr::hash to accept fat pointersMatt Brubeck-1/+1
2018-12-11Make `const unsafe fn` bodies `unsafe`Oliver Scherer-1/+1
2018-12-08Rollup merge of #56602 - dwijnand:fix-ptr-hash-docs, r=CentrilMazdak Farrokhzad-2/+5
Fix the just-introduced ptr::hash docs Follow-up to #56250.
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-19/+19
2018-12-07grammarDale Wijnand-1/+1
2018-12-07Fix the just-introduced ptr::hash docsDale Wijnand-2/+5
2018-12-07Unique/NonNull::from: make sure we convert to raw pointers ASAPRalf Jung-4/+4
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-07Rollup merge of #56250 - dwijnand:ptr-hash, r=alexcrichtonkennytm-0/+30
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-04Increase code-reuse and -readabilityOliver Scherer-1/+1
2018-12-04Make sure the initialization of constrained int range newtypes is unsafeOliver Scherer-7/+7
2018-12-04Fix ptr::hash, just hash the raw pointerDale Wijnand-1/+1
2018-12-04Make ptr::hash take a raw painter like ptr::eqDale Wijnand-1/+1
2018-12-01Auto merge of #56165 - RalfJung:drop-glue-type, r=eddyb,nikomatsakisbors-2/+12
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-11-27Move feature enable in ptr::hash doc exampleDale Wijnand-1/+1
2018-11-27Try to fix ptr::hash's doc exampleDale Wijnand-2/+3
2018-11-27Fix issue numberDale Wijnand-1/+1
2018-11-27Add an assert_eq in ptr::hash's doc exampleDale Wijnand-1/+7
2018-11-27Pick a better variable name for ptr::hashDale Wijnand-2/+2
2018-11-27Fix stability attribute for ptr::hashDale Wijnand-1/+1
2018-11-26Fix ptr::hex doc exampleDale Wijnand-1/+1
2018-11-26FIXME is the new TODODale Wijnand-1/+1
2018-11-26Introduce ptr::hash for referencesDale Wijnand-0/+23
2018-11-23use MaybeUninit in core::ptr::swap_nonoverlapping_bytesRalf Jung-4/+4
Code by @japaric, I just split it into individual commits
2018-11-23use MaybeUninit in core::ptr::swapRalf Jung-8/+5
Code by @japaric, I just split it into individual commits
2018-11-23use MaybeUninit in core::ptr::{read,read_unaligned}Ralf Jung-7/+7
Code by @japaric, I just split it into individual commits
2018-11-22drop glue takes in mutable references, it should reflect that in its typeRalf Jung-2/+12
2018-11-21update various stdlib docsSteve Klabnik-1/+1
2018-11-12Auto merge of #55278 - Centril:constification-1, r=alexcrichtonbors-1/+1
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-10Fix documentation typos.Bruce Mitchener-4/+4
2018-11-10revert making internal APIs const fn.Mazdak Farrokhzad-1/+1
2018-11-10constify parts of libcore.Mazdak Farrokhzad-2/+2
2018-11-01Replace CoerceSized trait with DispatchFromDynMichael Hewson-4/+4
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-01Add CoerceSized impls throughout libstdMichael Hewson-1/+7
This will make receiver types like `Rc<Self>` and `Pin<&mut Self>` object-safe.
2018-10-31Bump nightly to 1.32.0Alex Crichton-2/+2
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-28Make a bunch of trivial methods of NonNull be `#[inline]`Nick Fitzgerald-0/+14
2018-10-23fix typos in various placesMatthias Krüger-1/+1
2018-10-14remove unnecessary emphasis in doc commentJan Niehusmann-2/+2
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-14clarify pointer add/sub function safety concernsJan Niehusmann-4/+4
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