summary refs log tree commit diff
path: root/src/libcore/ptr.rs
AgeCommit message (Collapse)AuthorLines
2018-11-22update various stdlib docsSteve Klabnik-1/+1
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
2018-08-30fix exampleRalf Jung-2/+1
2018-08-30fix exampleRalf Jung-2/+3
2018-08-30improve volatile commentsRalf Jung-4/+4
2018-08-30address remaining remarks and add example for dropping unaligned dataRalf Jung-4/+32
2018-08-30apply commentsRalf Jung-12/+13
2018-08-30clarify ZST commentRalf Jung-10/+10
2018-08-29clarify that these are preliminary guaranteesRalf Jung-5/+4
2018-08-29edit docs a littleRalf Jung-24/+37
2018-08-29Resolve null/ZST conflict correctly (whoops)Dylan MacKenzie-4/+3
2018-08-29Add a list of known facts re: validityDylan MacKenzie-9/+26
Also rewrites the reads/writes section to be less reliant on `*const`, `*mut`
2018-08-29You can't make an omlette without breaking a few linksDylan MacKenzie-1/+1
2018-08-29Incorporate RalfJung's suggestionsDylan MacKenzie-28/+38
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-29Redefine range validityDylan MacKenzie-8/+6
Uses `x.offset(i)` must be valid for all `i` in `0..count`.
2018-08-29Remove definiton of valid pointerDylan MacKenzie-7/+14
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-29Fix off-by-one error when specifying a valid rangeDylan MacKenzie-2/+2
2018-08-29Reword module level docs re: alignmentDylan MacKenzie-4/+4
2018-08-29Update docs for `swap_nonoverlapping`Dylan MacKenzie-3/+19
They closely mirror the docs for `copy_nonoverlapping`
2018-08-29Fix unused variable warning in doctestDylan MacKenzie-0/+1
2018-08-29Fix failing doctestsDylan MacKenzie-3/+3
2018-08-29Mention alignment in top-level docsDylan MacKenzie-5/+11
This also removes the overlong link that failed tidy xD.
2018-08-29Rewrite docs for `std::ptr`Dylan MacKenzie-68/+351
- Add links to the GNU libc docs for `memmove`, `memcpy`, and `memset`, as well as internally linking to other functions in `std::ptr` - List invariants which, when violated, cause UB for all functions - Add example to `ptr::drop_in_place` and compares it to `ptr::read`. - Add examples which more closely mirror real world uses for the functions in `std::ptr`. Also, move the reimplementation of `mem::swap` to the examples of `ptr::read` and use a more interesting example for `copy_nonoverlapping`. - Change module level description - Define what constitutes a "valid" pointer. - Centralize discussion of ownership of bitwise copies in `ptr::read` and provide an example.
2018-08-22Rollup merge of #53574 - vorner:ptr_as_ref_unchecked, r=Mark-SimulacrumGuillaume Gomez-0/+30
Suggest direct raw-pointer dereference People often come looking for some kind of `as_ref_unchecked` method on raw pointers that would give them `&T` and not `Option<&T>` when they are sure the pointer is not NULL. There's no such method, but taking a reference of the dereferenced pointer accomplishes the same thing. Therefore, suggest using that, at the `as_ref` site ‒ it's a place people are likely going to look into.
2018-08-21Suggest direct raw-pointer dereferenceMichal 'vorner' Vaner-0/+30
People often come looking for some kind of `as_ref_unchecked` method on raw pointers that would give them `&T` and not `Option<&T>` when they are sure the pointer is not NULL. There's no such method, but taking a reference of the dereferenced pointer accomplishes the same thing. Therefore, suggest using that, at the `as_ref` site ‒ it's a place people are likely going to look into.
2018-08-21Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJungkennytm-8/+8
Replace usages of ptr::offset with ptr::{add,sub}. Rust provides these helper methods – so let's use them!
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-8/+8
2018-08-19Fix typos found by codespell.Matthias Krüger-1/+1
2018-08-12Rollup merge of #53059 - ljedrz:unneeded_returns, r=kennytmGuillaume Gomez-2/+2
Remove explicit returns where unnecessary
2018-08-04Remove explicit returns where unnecessaryljedrz-2/+2
2018-08-03volatile operations docs: clarify that this does not help wrt. concurrencyRalf Jung-0/+30