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

https://gitlab.com/pranith/rust · Rust · 57 lines · 36 code · 12 blank · 9 comment · 2 complexity · 3f83c5d57aa4b153562793210534667b 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. #![feature(unsafe_destructor)]
  13. use std::marker;
  14. struct arc_destruct<T: Sync> {
  15. _data: isize,
  16. _marker: marker::PhantomData<T>
  17. }
  18. #[unsafe_destructor]
  19. impl<T: Sync> Drop for arc_destruct<T> {
  20. fn drop(&mut self) {}
  21. }
  22. fn arc_destruct<T: Sync>(data: isize) -> arc_destruct<T> {
  23. arc_destruct {
  24. _data: data,
  25. _marker: marker::PhantomData
  26. }
  27. }
  28. fn arc<T: Sync>(_data: T) -> arc_destruct<T> {
  29. arc_destruct(0)
  30. }
  31. fn init() -> arc_destruct<context_res> {
  32. arc(context_res())
  33. }
  34. struct context_res {
  35. ctx : isize,
  36. }
  37. impl Drop for context_res {
  38. fn drop(&mut self) {}
  39. }
  40. fn context_res() -> context_res {
  41. context_res {
  42. ctx: 0
  43. }
  44. }
  45. pub type context = arc_destruct<context_res>;