summary refs log tree commit diff
path: root/src/libcore/ptr.rs
AgeCommit message (Collapse)AuthorLines
2017-11-07Auto merge of #44932 - cuviper:unsized-ptr-is_null, r=alexcrichtonbors-6/+12
Remove `T: Sized` on pointer `as_ref()` and `as_mut()` `NonZero::is_zero()` was already casting all pointers to thin `*mut u8` to check for null. The same test on unsized fat pointers can also be used with `as_ref()` and `as_mut()` to get fat references. (This PR formerly changed `is_null()` too, but checking just the data pointer is not obviously correct for trait objects, especially if `*const self` sorts of methods are ever allowed.)
2017-10-29Fix references to zero_memory and copy_memory in ptr docsFlorian Hartwig-9/+9
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-4/+4
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-10-20Fix most rendering warnings from switching to CommonMarksteveklabnik-6/+6
2017-10-10Restore `T: Sized` on `ptr::is_null`Josh Stone-21/+13
The exact semantics of `is_null` on unsized pointers are still debatable, especially for trait objects. It may be legal to call `*mut self` methods on a trait object someday, as with Go interfaces, so `is_null` might need to validate the vtable pointer too. For `as_ref` and `as_mut`, we're assuming that you cannot have a non-null data pointer with a null vtable, so casting the unsized check is fine.
2017-10-05Auto merge of #44943 - nivkner:fixme_fixup, r=dtolnaybors-2/+0
address some FIXME whose associated issues were marked as closed part of #44366
2017-09-30address some `FIXME`s whose associated issues were marked as closedNiv Kaminer-2/+0
remove FIXME(#13101) since `assert_receiver_is_total_eq` stays. remove FIXME(#19649) now that stability markers render. remove FIXME(#13642) now the benchmarks were moved. remove FIXME(#6220) now that floating points can be formatted. remove FIXME(#18248) and write tests for `Rc<str>` and `Rc<[u8]>` remove reference to irelevent issues in FIXME(#1697, #2178...) update FIXME(#5516) to point to getopts issue 7 update FIXME(#7771) to point to RFC 628 update FIXME(#19839) to point to issue 26925
2017-09-29Document that there are many possible null pointersJosh Stone-0/+10
2017-09-29Remove `T: Sized` on `ptr::is_null()`, `as_ref()`, `as_mut()`Josh Stone-7/+11
`NonZero::is_zero()` was already casting all pointers to thin `*mut u8` to check for null. It seems reasonable to apply that for `is_null()` in general, and then unsized fat pointers can also be used with `as_ref()` and `as_mut()` to get fat references.
2017-09-28Normalize spaces in lang attributes.Havvy-1/+1
2017-09-17Add `<*const T>::align_offset` and use it in `memchr`Oliver Schneider-1/+74
2017-09-16Auto merge of #43964 - Gankro:unsafe-reform, r=sfacklerbors-12/+1174
implement unsafe pointer methods I also cleaned up some existing documentation a bit here or there since I was doing so much auditing of it. Most notably I significantly rewrote the `offset` docs to clarify safety (`*const` and `*mut`'s offset docs had actually diverged).
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-0/+6
2017-09-10implement unsafe pointer methodsAlexis Beingessner-12/+1174
2017-08-31Update bootstrap compilerAlex Crichton-27/+0
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-14Make `Clone` a lang item and generate builtin impls.scalexm-0/+3
Fixes #28229. Fixes #24000.
2017-08-13Addresses comments in PR #43836Alexey Tarasov-10/+8
- removes warnings introduced in changeset 0cd3587 - makes documentation more neat and grammatically correct
2017-08-12Follow up commit for the issue 39827Alexey Tarasov-0/+12
- updates documentation on volatile memory intrinsics, now the case of zero-sized types is mentioned explicitly. Volatile memory operations which doesn't affect memory at all are omitted in LLVM backend, e.g. if number of elements is zero or type used in generic specialisation is zero-sized, then LLVM intrinsic or related code is not generated. This was not explicitly documented before in Rust documentation and potentially could cause issues.
2017-07-22Fix unstable feature name for some impls for Unique<T>Simon Sapin-2/+2
2017-07-22Add conversions from references to NonZero pointers, Unique, and SharedSimon Sapin-0/+28
2017-07-22Implement From<Unique<T>> for Shared<T>Simon Sapin-0/+8
2017-07-22Rename {NonZero,Shared,Unique}::new_checked to newSimon Sapin-4/+4
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-6/+6
2017-07-22Add `new_checked(…) -> Option<Self>` to NonZero, Unique, and Shared.Simon Sapin-2/+12
2017-07-20std: Cut down #[inline] annotations where not necessaryAlex Crichton-2/+2
This PR cuts down on a large number of `#[inline(always)]` and `#[inline]` annotations in libcore for various core functions. The `#[inline(always)]` annotation is almost never needed and is detrimental to debug build times as it forces LLVM to perform inlining when it otherwise wouldn't need to in debug builds. Additionally `#[inline]` is an unnecessary annoation on almost all generic functions because the function will already be monomorphized into other codegen units and otherwise rarely needs the extra "help" from us to tell LLVM to inline something. Overall this PR cut the compile time of a [microbenchmark][1] by 30% from 1s to 0.7s. [1]: https://gist.github.com/alexcrichton/a7d70319a45aa60cf36a6a7bf540dd3a
2017-07-10Disable big-endian simd in swap_nonoverlapping_bytesJosh Stone-1/+4
This is a workaround for #42778, which was git-bisected to #40454's optimizations to `mem::swap`, later moved to `ptr` in #42819. Natively compiled rustc couldn't even compile stage1 libcore on powerpc64 and s390x, but they work fine without this `repr(simd)`. Since powerpc64le works OK, it seems probably related to being big-endian. The underlying problem is not yet known, but this at least makes those architectures functional again in the meantime. cc @arielb1
2017-06-28Auto merge of #42819 - scottmcm:swap-nonoverlapping, r=sfacklerbors-0/+84
Reuse the mem::swap optimizations to speed up slice::rotate This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster. Exposes the swapping logic from PR https://github.com/rust-lang/rust/pull/40454 as `pub unsafe fn ptr::swap_nonoverlapping` under library feature `swap_nonoverlapping` https://github.com/rust-lang/rust/issues/42818. (The new method seemed plausible, and was the simplest way to share the logic. I'm not attached to it, though, so let me know if a different way would be better.)
2017-06-23Removed as many "```ignore" as possible.kennytm-6/+6
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-21Reuse the mem::swap optimizations to speed up slice::rotateScott McMurray-0/+84
Exposes the swapping logic from PR 40454 as `pub unsafe fn ptr::swap_nonoverlapping` under feature swap_nonoverlapping This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster.
2017-05-13Auto merge of #41920 - arielb1:inline-drop, r=eddybbors-1/+0
remove the #[inline] attribute from drop_in_place Apparently LLVM has exponential code growth while inlining landing pads if that attribute is present. Fixes #41696. beta-nominating because regression. r? @eddyb
2017-05-11remove the #[inline] attribute from drop_in_placeAriel Ben-Yehuda-1/+0
Apparently LLVM has exponential code growth while inlining landing pads if that attribute is present. Fixes #41696.
2017-05-10fix typo in Unique::empty docRalf Jung-1/+1
2017-05-04refactor NonZero, Shared, and Unique APIsAlexis Beingessner-44/+127
Major difference is that I removed Deref impls, as apparently LLVM has trouble maintaining metadata with a `&ptr -> &ptr` API. This was cited as a blocker for ever stabilizing this API. It wasn't that ergonomic anyway. * Added `get` to NonZero to replace Deref impl * Added `as_ptr` to Shared/Unique to replace Deref impl * Added Unique's `as_ref` and `as_mut` conveniences to Shared * Added `::empty()` convenience constructor for Unique/Shared * Deprecated `as_mut_ptr` on Shared in favour of `as_ptr` * Improved documentation of types Note that Shared now only refers to *mut, and not *const
2017-04-29Update stage0 bootstrap compilerAlex Crichton-5/+0
We've got a freshly minted beta compiler, let's update to use that on nightly! This has a few other changes associated with it as well * A bump to the rustc version number (to 1.19.0) * Movement of the `cargo` and `rls` submodules to their "proper" location in `src/tools/{cargo,rls}`. Now that Cargo workspaces support the `exclude` option this can work. * Updates of the `cargo` and `rls` submodules to their master branches. * Tweak to the `src/stage0.txt` format to be more amenable for Cargo version numbers. On the beta channel Cargo will bootstrap from a different version than rustc (e.g. the version numbers are different), so we need different configuration for this. * Addition of `dev` as a readable key in the `src/stage0.txt` format. If present then stage0 compilers are downloaded from `dev-static.rust-lang.org` instead of `static.rust-lang.org`. This is added to accomodate our updated release process with Travis and AppVeyor.
2017-04-05Add tracking issue for offset_toAmanieu d'Antras-2/+2
2017-04-03Add ptr::offset_toAmanieu d'Antras-0/+76
2017-03-22Various fixes to wording consistency in the docsStjepan Glavina-2/+2
2017-03-20Rollup merge of #40667 - DaseinPhaos:patch-4, r=GuillaumeGomezCorey Farwell-4/+4
Fix typo in `ptr` doc `sizeof` should be `size_of`
2017-03-20Auto merge of #39628 - arielb1:shimmir, r=eddybbors-0/+29
Translate shims using MIR This removes one large remaining part of old trans.
2017-03-20Fix typo in `ptr` docLuxko-4/+4
`sizeof` should be `size_of`
2017-03-18translate drop glue using MIRAriel Ben-Yehuda-0/+29
Drop of arrays is now translated in trans::block in an ugly way that I should clean up in a later PR, and does not handle panics in the middle of an array drop, but this commit & PR are growing too big.
2017-03-17Minor fixups to fix tidy errorsAlex Crichton-2/+1
2017-03-17Stabilize rc_raw feature, closes #37197Aaron Turon-3/+11
2017-03-17Stabilize ptr_unaligned feature, closes #37955Aaron Turon-6/+2
2017-03-09Reword the non-dropping of `src` for `ptr::write{,_unaligned}`Tobias Bucher-3/+5
2017-03-07Clarify handling of `src` in `ptr::write`Tobias Bucher-0/+4
Fixes #39733.
2017-01-25std: Stabilize APIs for the 1.16.0 releaseAlex Crichton-4/+2
This commit applies the stabilization/deprecations of the 1.16.0 release, as tracked by the rust-lang/rust issue tracker and the final-comment-period tag. The following APIs were stabilized: * `VecDeque::truncate` * `VecDeque::resize` * `String::insert_str` * `Duration::checked_{add,sub,div,mul}` * `str::replacen` * `SocketAddr::is_ipv{4,6}` * `IpAddr::is_ipv{4,6}` * `str::repeat` * `Vec::dedup_by` * `Vec::dedup_by_key` * `Result::unwrap_or_default` * `<*const T>::wrapping_offset` * `<*mut T>::wrapping_offset` * `CommandExt::creation_flags` (on Windows) * `File::set_permissions` * `String::split_off` The following APIs were deprecated * `EnumSet` - replaced with other ecosystem abstractions, long since unstable Closes #27788 Closes #35553 Closes #35774 Closes #36436 Closes #36949 Closes #37079 Closes #37087 Closes #37516 Closes #37827 Closes #37916 Closes #37966 Closes #38080
2017-01-07thanks @eddybSteve Klabnik-1/+1
2017-01-07Improve safety warning on ptr::swapSteve Klabnik-1/+4
2016-12-12Implement RFC #1725Steven Fackler-0/+83
cc #37955