/src/test/run-pass/auxiliary/issue-2526.rs

https://gitlab.com/alx741/rust · Rust · 54 lines · 34 code · 11 blank · 9 comment · 2 complexity · f10132dee3b96c54d4bb4f352604c030 MD5 · raw file

  1. // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. #![crate_name="issue_2526"]
  11. #![crate_type = "lib"]
  12. use std::marker;
  13. pub struct arc_destruct<T: Sync> {
  14. _data: isize,
  15. _marker: marker::PhantomData<T>
  16. }
  17. impl<T: Sync> Drop for arc_destruct<T> {
  18. fn drop(&mut self) {}
  19. }
  20. fn arc_destruct<T: Sync>(data: isize) -> arc_destruct<T> {
  21. arc_destruct {
  22. _data: data,
  23. _marker: marker::PhantomData
  24. }
  25. }
  26. fn arc<T: Sync>(_data: T) -> arc_destruct<T> {
  27. arc_destruct(0)
  28. }
  29. fn init() -> arc_destruct<context_res> {
  30. arc(context_res())
  31. }
  32. pub struct context_res {
  33. ctx : isize,
  34. }
  35. impl Drop for context_res {
  36. fn drop(&mut self) {}
  37. }
  38. fn context_res() -> context_res {
  39. context_res {
  40. ctx: 0
  41. }
  42. }
  43. pub type context = arc_destruct<context_res>;