diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-04-15 11:57:29 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-05-13 14:19:51 +1200 |
| commit | 843db01bd925279da0a56efde532c9e3ecf73610 (patch) | |
| tree | eed89761dcb0ddeb578ca24357ef680787eabb43 /src/libcore/ops.rs | |
| parent | c2b30b86df6b34ba19e87e63402e43d9e81a64fb (diff) | |
| download | rust-843db01bd925279da0a56efde532c9e3ecf73610.tar.gz rust-843db01bd925279da0a56efde532c9e3ecf73610.zip | |
eddyb's changes for DST coercions
+ lots of rebasing
Diffstat (limited to 'src/libcore/ops.rs')
| -rw-r--r-- | src/libcore/ops.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 55c4264b10c..1a2473fda41 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -70,6 +70,9 @@ use marker::Sized; use fmt; +#[cfg(not(stage0))] // SNAP c64d671 +use marker::Unsize; + /// The `Drop` trait is used to run some code when a value goes out of scope. This /// is sometimes called a 'destructor'. /// @@ -1207,3 +1210,34 @@ mod impls { } } } + +/// Trait that indicates that this is a pointer or a wrapper for one, +/// where unsizing can be performed on the pointee. +#[unstable(feature = "core")] +#[cfg(not(stage0))] // SNAP c64d671 +#[lang="coerce_unsized"] +pub trait CoerceUnsized<T> { + // Empty. +} + +#[cfg(not(stage0))] // SNAP c64d671 +impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {} +#[cfg(not(stage0))] // SNAP c64d671 +impl<'a, 'b: 'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b mut T {} +#[cfg(not(stage0))] // SNAP c64d671 +impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for &'a mut T {} +#[cfg(not(stage0))] // SNAP c64d671 +impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a mut T {} + +#[cfg(not(stage0))] // SNAP c64d671 +impl<'a, 'b: 'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +#[cfg(not(stage0))] // SNAP c64d671 +impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a T {} + +#[cfg(not(stage0))] // SNAP c64d671 +impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} +#[cfg(not(stage0))] // SNAP c64d671 +impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {} + +#[cfg(not(stage0))] // SNAP c64d671 +impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {} |
