diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-07-24 14:56:02 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-07-24 14:56:02 -0400 |
| commit | a75c21fc9cf970c0a4372c2e4c5f3b770050f26f (patch) | |
| tree | 8e321788aeeff241533aff0b915cd03a76fec487 | |
| parent | fafb1fa82357e89759fb5698bac3252f852208f0 (diff) | |
| parent | e66817512a414d1665e37e6016a6fc06522fb2e0 (diff) | |
| download | rust-a75c21fc9cf970c0a4372c2e4c5f3b770050f26f.tar.gz rust-a75c21fc9cf970c0a4372c2e4c5f3b770050f26f.zip | |
Rollup merge of #27220 - AlisdairO:diagnostics120, r=Manishearth
As title! I should probably be bunching these up a bit more, but I'm not sure when my time is going to disappear on me. Once my schedule stabilises I'll try to start batching them into larger PRs. Part of #24407. r? @Manishearth
| -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 b151ae677d9..73ee3bbbe5b 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. @@ -2251,7 +2290,6 @@ register_diagnostics! { E0103, E0104, E0118, - E0120, E0122, E0123, E0127, |
