|  | 
| 1 |  | -use crate::marker::{PointeeSized, Unsize}; | 
|  | 1 | +use crate::marker::{Move, PointeeSized, Unsize}; | 
| 2 | 2 | 
 | 
| 3 | 3 | /// Trait that indicates that this is a pointer or a wrapper for one, | 
| 4 | 4 | /// where unsizing can be performed on the pointee. | 
| @@ -39,34 +39,46 @@ pub trait CoerceUnsized<T: PointeeSized> { | 
| 39 | 39 | 
 | 
| 40 | 40 | // &mut T -> &mut U | 
| 41 | 41 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 42 |  | -impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {} | 
|  | 42 | +impl<'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> | 
|  | 43 | +    for &'a mut T | 
|  | 44 | +{ | 
|  | 45 | +} | 
| 43 | 46 | // &mut T -> &U | 
| 44 | 47 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 45 |  | -impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b mut T {} | 
|  | 48 | +impl<'a, 'b: 'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> | 
|  | 49 | +    for &'b mut T | 
|  | 50 | +{ | 
|  | 51 | +} | 
| 46 | 52 | // &mut T -> *mut U | 
| 47 | 53 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 48 |  | -impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for &'a mut T {} | 
|  | 54 | +impl<'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for &'a mut T {} | 
| 49 | 55 | // &mut T -> *const U | 
| 50 | 56 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 51 |  | -impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for &'a mut T {} | 
|  | 57 | +impl<'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> | 
|  | 58 | +    for &'a mut T | 
|  | 59 | +{ | 
|  | 60 | +} | 
| 52 | 61 | 
 | 
| 53 | 62 | // &T -> &U | 
| 54 | 63 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 55 |  | -impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {} | 
|  | 64 | +impl<'a, 'b: 'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> | 
|  | 65 | +    for &'b T | 
|  | 66 | +{ | 
|  | 67 | +} | 
| 56 | 68 | // &T -> *const U | 
| 57 | 69 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 58 |  | -impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for &'a T {} | 
|  | 70 | +impl<'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for &'a T {} | 
| 59 | 71 | 
 | 
| 60 | 72 | // *mut T -> *mut U | 
| 61 | 73 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 62 |  | -impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {} | 
|  | 74 | +impl<T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {} | 
| 63 | 75 | // *mut T -> *const U | 
| 64 | 76 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 65 |  | -impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *mut T {} | 
|  | 77 | +impl<T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *mut T {} | 
| 66 | 78 | 
 | 
| 67 | 79 | // *const T -> *const U | 
| 68 | 80 | #[unstable(feature = "coerce_unsized", issue = "18598")] | 
| 69 |  | -impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {} | 
|  | 81 | +impl<T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {} | 
| 70 | 82 | 
 | 
| 71 | 83 | /// `DispatchFromDyn` is used in the implementation of dyn-compatibility[^1] checks (specifically | 
| 72 | 84 | /// allowing arbitrary self types), to guarantee that a method's receiver type can be dispatched on. | 
| @@ -116,19 +128,31 @@ impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for * | 
| 116 | 128 | /// [^1]: Formerly known as *object safety*. | 
| 117 | 129 | #[unstable(feature = "dispatch_from_dyn", issue = "none")] | 
| 118 | 130 | #[lang = "dispatch_from_dyn"] | 
| 119 |  | -pub trait DispatchFromDyn<T> { | 
|  | 131 | +pub trait DispatchFromDyn<T: ?Move> { | 
| 120 | 132 |     // Empty. | 
| 121 | 133 | } | 
| 122 | 134 | 
 | 
| 123 | 135 | // &T -> &U | 
| 124 | 136 | #[unstable(feature = "dispatch_from_dyn", issue = "none")] | 
| 125 |  | -impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {} | 
|  | 137 | +impl<'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized + ?Move> DispatchFromDyn<&'a U> | 
|  | 138 | +    for &'a T | 
|  | 139 | +{ | 
|  | 140 | +} | 
| 126 | 141 | // &mut T -> &mut U | 
| 127 | 142 | #[unstable(feature = "dispatch_from_dyn", issue = "none")] | 
| 128 |  | -impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {} | 
|  | 143 | +impl<'a, T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized + ?Move> DispatchFromDyn<&'a mut U> | 
|  | 144 | +    for &'a mut T | 
|  | 145 | +{ | 
|  | 146 | +} | 
| 129 | 147 | // *const T -> *const U | 
| 130 | 148 | #[unstable(feature = "dispatch_from_dyn", issue = "none")] | 
| 131 |  | -impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {} | 
|  | 149 | +impl<T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized + ?Move> DispatchFromDyn<*const U> | 
|  | 150 | +    for *const T | 
|  | 151 | +{ | 
|  | 152 | +} | 
| 132 | 153 | // *mut T -> *mut U | 
| 133 | 154 | #[unstable(feature = "dispatch_from_dyn", issue = "none")] | 
| 134 |  | -impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {} | 
|  | 155 | +impl<T: PointeeSized + ?Move + Unsize<U>, U: PointeeSized + ?Move> DispatchFromDyn<*mut U> | 
|  | 156 | +    for *mut T | 
|  | 157 | +{ | 
|  | 158 | +} | 
0 commit comments