about summary refs log tree commit diff
path: root/src/libcore/nonzero.rs
diff options
context:
space:
mode:
authorMichael Hewson <michael@michaelhewson.ca>2018-10-03 23:40:21 -0400
committerMichael Hewson <michael@michaelhewson.ca>2018-11-01 18:16:59 -0400
commitf12c250e40650e6103161f986f02a84b7357bdc9 (patch)
treec79c2edee2f4e22e63cd3baef0b0bebd982c103d /src/libcore/nonzero.rs
parentc29641e067d44c754fbc6a40e463a7e4d45ab31e (diff)
downloadrust-f12c250e40650e6103161f986f02a84b7357bdc9.tar.gz
rust-f12c250e40650e6103161f986f02a84b7357bdc9.zip
Replace CoerceSized trait with DispatchFromDyn
Rename `CoerceSized` to `DispatchFromDyn`, and reverse the direction so that, for example, you write

```
impl<T: Unsize<U>, U> DispatchFromDyn<*const U> for *const T {}
```

instead of

```
impl<T: Unsize<U>, U> DispatchFromDyn<*const T> for *const U {}
```

this way the trait is really just a subset of `CoerceUnsized`.

The checks in object_safety.rs are updated for the new trait, and some documentation and method names in there are updated for the new trait name — e.g. `receiver_is_coercible` is now called `receiver_is_dispatchable`. Since the trait now works in the opposite direction, some code had to updated here for that too.

I did not update the error messages for invalid `CoerceSized` (now `DispatchFromDyn`) implementations, except to find/replace `CoerceSized` with `DispatchFromDyn`. Will ask for suggestions in the PR thread.
Diffstat (limited to 'src/libcore/nonzero.rs')
-rw-r--r--src/libcore/nonzero.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs
index 2bc6c36171c..436cd1fc057 100644
--- a/src/libcore/nonzero.rs
+++ b/src/libcore/nonzero.rs
@@ -10,7 +10,7 @@
 
 //! Exposes the NonZero lang item which provides optimization hints.
 
-use ops::{CoerceUnsized, CoerceSized};
+use ops::{CoerceUnsized, DispatchFromDyn};
 
 /// A wrapper type for raw pointers and integers that will never be
 /// NULL or 0 that might allow certain optimizations.
@@ -21,4 +21,4 @@ pub(crate) struct NonZero<T>(pub(crate) T);
 
 impl<T: CoerceUnsized<U>, U> CoerceUnsized<NonZero<U>> for NonZero<T> {}
 
-impl<T: CoerceUnsized<U>, U: CoerceSized<T>> CoerceSized<NonZero<T>> for NonZero<U> {}
+impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<NonZero<U>> for NonZero<T> {}