about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
AgeCommit message (Collapse)AuthorLines
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
2018-10-12Auto merge of #54534 - nagisa:align-offset-simplification, r=alexcrichtonbors-25/+12
Simplify implementation of align_offset slightly
2018-10-03Only promote calls to `#[rustc_promotable]` const fnsOliver Schneider-0/+2
2018-09-30Simplify implementation of align_offset slightlySimonas Kazlauskas-25/+12
2018-09-29Revert "Auto merge of #53508 - japaric:maybe-uninit, r=RalfJung"Ralf Jung-14/+18
This reverts commit c6e3d7fa3113aaa64602507f39d4627c427742ff, reversing changes made to 4591a245c7eec9f70d668982b1383cd2a6854af5.
2018-09-24Auto merge of #53783 - RalfJung:ptr-docs, r=alexcrichtonbors-513/+541
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-22address Mark-Simulacrum commentsJorge Aparicio-2/+2
2018-09-22core: fix deprecated warningsJorge Aparicio-18/+14
2018-09-18clarify swapRalf Jung-5/+10
2018-09-17rearrange for clarityRalf Jung-41/+40
2018-09-17tweaksRalf Jung-1/+24
2018-09-10fix typosNicole Mazzuca-1/+1
2018-09-01remark on concurrency in validity sectionRalf Jung-0/+9
2018-09-01Valid raw pointersRalf Jung-1/+1
2018-08-31fix doctestsRalf Jung-1/+3
2018-08-31(un)alignedRalf Jung-2/+2
2018-08-31apply feedbackRalf Jung-7/+8
2018-08-31turn ptr type method docs into links to docs of free functions, to avoid ↵Ralf Jung-433/+44
duplication and inconsistency