diff options
| author | Alisdair Owens <awo101@zepler.net> | 2015-07-22 17:24:03 +0100 |
|---|---|---|
| committer | Alisdair Owens <awo101@zepler.net> | 2015-07-23 17:35:24 +0100 |
| commit | e66817512a414d1665e37e6016a6fc06522fb2e0 (patch) | |
| tree | 04388c697ce14a6e6b8c59b754b7d058faa603ef | |
| parent | 2e5b165e1801c2ddb5d3cc49ff96b9f264a4545c (diff) | |
| download | rust-e66817512a414d1665e37e6016a6fc06522fb2e0.tar.gz rust-e66817512a414d1665e37e6016a6fc06522fb2e0.zip | |
Add diagnostics for E0120
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index f865de522b2..ad45304341a 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1316,6 +1316,45 @@ fn main() { ``` "##, +E0120: r##" +An attempt was made to implement Drop on a trait, which is not allowed: only +structs and enums can implement Drop. An example causing this error: + +``` +trait MyTrait {} + +impl Drop for MyTrait { + fn drop(&mut self) {} +} +``` + +A workaround for this problem is to wrap the trait up in a struct, and implement +Drop on that. An example is shown below: + +``` +trait MyTrait {} +struct MyWrapper<T: MyTrait> { foo: T } + +impl <T: MyTrait> Drop for MyWrapper<T> { + fn drop(&mut self) {} +} + +``` + +Alternatively, wrapping trait objects requires something like the following: + +``` +trait MyTrait {} + +//or Box<MyTrait>, if you wanted an owned trait object +struct MyWrapper<'a> { foo: &'a MyTrait } + +impl <'a> Drop for MyWrapper<'a> { + fn drop(&mut self) {} +} +``` +"##, + E0121: r##" In order to be consistent with Rust's lack of global type inference, type placeholders are disallowed by design in item signatures. @@ -2195,7 +2234,6 @@ register_diagnostics! { E0103, E0104, E0118, - E0120, E0122, E0123, E0127, |
