Commit Graph

26 Commits

Author SHA1 Message Date
Nicolas Nattis 929f80ece9 Add a spin loop hint for Arc::downgrade 2020-10-23 16:10:56 -03:00
bors 738d4a7a36 Auto merge of #74160 - CAD97:weak-as-unsized-ptr, r=RalfJung
Allow Weak::as_ptr and friends for unsized T

Relaxes `impl<T> Weak<T>` to `impl<T: ?Sized> Weak<T>` for the methods `rc::Weak::as_ptr`, `into_raw`, and `from_raw`.

Follow-up to #73845, which did most of the impl work to make these functions work for `T: ?Sized`.

We still have to adjust the implementation of `Weak::from_raw` here, however, because I missed a use of `ptr.is_null()` previously. This check was necessary when `into`/`from_raw` were first implemented, as `into_raw` returned `ptr::null()` for dangling weak. However, we now just (wrapping) offset dangling weaks' pointers the same as nondangling weak, so the null check is no longer necessary (or even hit). (I can submit just 17a928f as a separate PR if desired.)

As a nice side effect, moves the `fn is_dangling` definition closer to `Weak::new`, which creates the dangling weak.

This technically stabilizes that "something like `align_of_val_raw`" is possible to do. However, I believe the part of the functionality required by these methods here -- specifically, getting the alignment of a pointee from a pointer where it may be dangling iff the pointee is `Sized` -- is uncontroversial enough to stabilize these methods without a way to implement them on stable Rust.

r? `@RalfJung,` who reviewed #73845.

ATTN: This changes (relaxes) the (input) generic bounds on stable fn!
2020-10-03 14:18:26 +00:00
Ralf Jung e27ef130c1 grammar nit 2020-10-03 12:15:26 +02:00
Jacob Hughes 5829560a68 Rename AllocErr to AllocError 2020-09-28 14:51:03 -04:00
CAD97 9d9903c5a5 Allow Weak::as_ptr and friends for unsized T 2020-09-12 10:38:33 -05:00
CAD97 5e7406c956 Adjust sync::Weak::from_raw to support unsized T 2020-09-12 10:38:32 -05:00
Joshua Nelson 44bacc3ffa Revert change to MaybeUninit until rustdoc bugs are fixed
https://github.com/rust-lang/rust/issues/76106
2020-09-02 17:38:21 -04:00
Joshua Nelson 59a1a05bff Convert many files to intra-doc links
- Use intra-doc links for `std::io` in `std::fs`
- Use intra-doc links for File::read in unix/ext/fs.rs
- Remove explicit intra-doc links for `true` in `net/addr.rs`
- Use intra-doc links in alloc/src/sync.rs
- Use intra-doc links in src/ascii.rs
- Switch to intra-doc links in alloc/rc.rs
- Use intra-doc links in core/pin.rs
- Use intra-doc links in std/prelude
- Use shorter links in `std/fs.rs`

  `io` is already in scope.
2020-09-02 17:37:40 -04:00
Camelid 7be129e53a Add missing hyphen
reference counted pointer -> reference-counted pointer
2020-08-28 09:29:06 -07:00
bors 9d74562432 Auto merge of #75505 - Dylan-DPC:feature/arc_new, r=KodrAus
Add Arc::new_cyclic

Rework of #72443

References #75861

cc @Diggsey @RalfJung

r? @KodrAus
2020-08-24 08:26:59 +00:00
Dylan DPC c26a8d5772 add issue number 2020-08-24 02:34:52 +02:00
bors 663d2f5cd3 Auto merge of #75171 - amosonn:new_zeroed_slice, r=Amanieu
New zeroed slice

Add to #63291 the methods

```rust
impl<T> Box<[T]> { pub fn new_zeroed_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_zeroed_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_zeroed_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }
```

as suggested in https://github.com/rust-lang/rust/issues/63291#issuecomment-605511675 .

Also optimize `{Rc, Arc}::new_zeroed` to use `alloc_zeroed`, otherwise they are no more efficient than using `new_uninit` and zeroing the memory manually (which was the original implementation).
2020-08-22 18:46:42 +00:00
LeSeulArtichaut 97072c6b90 Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-21 19:31:00 +02:00
LeSeulArtichaut 1ababd8794 Use intra-doc-links in alloc 2020-08-21 00:25:25 +02:00
DPC 9ad17b9ca7 tidy up 2020-08-15 03:16:20 +02:00
DPC 76b99d5f1d Add Arc::new_cyclic 2020-08-13 03:07:54 +02:00
Amos Onn ab204c5b20 Add {Box,Rc,Arc}::new_zeroed_slice 2020-08-05 08:32:10 +02:00
Amos Onn 361f668c49 Use alloc_zeroed in {Rc,Arc}::new_zeroed 2020-08-05 08:32:05 +02:00
Tim Diekmann ab9362ad9a Replace Memoryblock with NonNull<[u8]> 2020-08-04 18:03:34 +02:00
Tim Diekmann 24ddf76ed7 Merge branch 'master' into remove-in-place-alloc 2020-08-03 02:18:20 +02:00
liuzhenyu 3b4151c9f3 fix typos 2020-08-02 23:20:00 +08:00
Manish Goregaokar 46379687ac Rollup merge of #74782 - vorner:weak-into-raw-cnt-doc, r=dtolnay
Don't use "weak count" around Weak::from_raw_ptr

As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.
2020-07-30 13:04:29 -07:00
Simon Sapin 1fb67363bf Remove deprecated unstable {Box,Rc,Arc}::into_raw_non_null functions
FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29 11:00:31 +02:00
Tim Diekmann 076ef66ba2 Remove in-place allocation and revert to separate methods for zeroed allocations
Fix docs
2020-07-28 12:41:18 +02:00
Michal 'vorner' Vaner ad6d63ef01 Don't use "weak count" around Weak::from_raw_ptr
As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.
2020-07-28 08:30:32 +02:00
mark 2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00