rust/library/alloc/src
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
..
alloc Replace Memoryblock with NonNull<[u8]> 2020-08-04 18:03:34 +02:00
collections Rollup merge of #75377 - canova:map_debug_impl, r=dtolnay 2020-10-03 00:31:04 +02:00
prelude
raw_vec Rename AllocErr to AllocError 2020-09-28 14:51:03 -04:00
rc Add tests for weak into/from raw 2020-09-12 10:38:33 -05:00
sync Add tests for weak into/from raw 2020-09-12 10:38:33 -05:00
alloc.rs Rename AllocErr to AllocError 2020-09-28 14:51:03 -04:00
borrow.rs Update library functions with stability attributes 2020-09-22 10:05:58 -07:00
boxed.rs Use intra-doc links for MaybeUninit in boxed.rs 2020-09-01 23:54:17 -04:00
fmt.rs Apply suggestions from code review 2020-08-21 19:31:00 +02:00
lib.rs Update library functions with stability attributes 2020-09-22 10:05:58 -07:00
macros.rs Use intra-doc-links in alloc 2020-08-21 00:25:25 +02:00
raw_vec.rs Rollup merge of #76993 - blitzerr:alloc-ref, r=Amanieu 2020-09-23 14:54:06 +02:00
rc.rs Auto merge of #74160 - CAD97:weak-as-unsized-ptr, r=RalfJung 2020-10-03 14:18:26 +00:00
slice.rs Rollup merge of #75026 - JulianKnodt:array_windows, r=Amanieu 2020-09-16 12:24:03 -07:00
str.rs
string.rs Rollup merge of #76525 - fusion-engineering-forks:string-drain, r=dtolnay 2020-09-19 11:47:47 +02:00
sync.rs Auto merge of #74160 - CAD97:weak-as-unsized-ptr, r=RalfJung 2020-10-03 14:18:26 +00:00
task.rs Allow unstable From impl for [Raw]Waker. 2020-09-11 13:36:45 +02:00
tests.rs
vec.rs Fix typo in vec doc "tries to reserves" 2020-10-01 10:08:51 +08:00