diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-03-03 17:50:16 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-03 17:50:16 +0900 |
| commit | 9be7932d35f9d71e3264c67b7e2aca485a2e3dc4 (patch) | |
| tree | 477ba05853556f548d237ed8d9701006a32fa487 | |
| parent | 017a2f4ce6feca27092c04506ac6de52332ac369 (diff) | |
| parent | ba49ed01f0abd2c18313611ad43424ca827c1498 (diff) | |
| download | rust-9be7932d35f9d71e3264c67b7e2aca485a2e3dc4.tar.gz rust-9be7932d35f9d71e3264c67b7e2aca485a2e3dc4.zip | |
Rollup merge of #69634 - GuillaumeGomez:clean-up-e0378, r=Dylan-DPC
clean up E0378 explanation r? @Dylan-DPC
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0378.md | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/librustc_error_codes/error_codes/E0378.md b/src/librustc_error_codes/error_codes/E0378.md index 311483c8900..7f4374738de 100644 --- a/src/librustc_error_codes/error_codes/E0378.md +++ b/src/librustc_error_codes/error_codes/E0378.md @@ -1,10 +1,28 @@ +The `DispatchFromDyn` trait was implemented on something which is not a pointer +or a newtype wrapper around a pointer. + +Erroneous code example: + +```compile-fail,E0378 +#![feature(dispatch_from_dyn)] +use std::ops::DispatchFromDyn; + +struct WrapperExtraField<T> { + ptr: T, + extra_stuff: i32, +} + +impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T> +where + T: DispatchFromDyn<U>, +{} +``` + The `DispatchFromDyn` trait currently can only be implemented for builtin pointer types and structs that are newtype wrappers around them — that is, the struct must have only one field (except for`PhantomData`), and that field must itself implement `DispatchFromDyn`. -Examples: - ``` #![feature(dispatch_from_dyn, unsize)] use std::{ @@ -20,6 +38,8 @@ where {} ``` +Another example: + ``` #![feature(dispatch_from_dyn)] use std::{ @@ -37,21 +57,3 @@ where T: DispatchFromDyn<U>, {} ``` - -Example of illegal `DispatchFromDyn` implementation -(illegal because of extra field) - -```compile-fail,E0378 -#![feature(dispatch_from_dyn)] -use std::ops::DispatchFromDyn; - -struct WrapperExtraField<T> { - ptr: T, - extra_stuff: i32, -} - -impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T> -where - T: DispatchFromDyn<U>, -{} -``` |
