/src/test/incremental/hashes/extern_mods.rs

https://gitlab.com/rust-lang/rust · Rust · 224 lines · 167 code · 30 blank · 27 comment · 0 complexity · 6bdf699e87efec46640820991d9f6256 MD5 · raw file

  1. // This test case tests the incremental compilation hash (ICH) implementation
  2. // for `extern` modules.
  3. // The general pattern followed here is: Change one thing between rev1 and rev2
  4. // and make sure that the hash has changed, then change nothing between rev2 and
  5. // rev3 and make sure that the hash has not changed.
  6. // build-pass (FIXME(62277): could be check-pass?)
  7. // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
  8. // compile-flags: -Z query-dep-graph -O
  9. // [cfail1]compile-flags: -Zincremental-ignore-spans
  10. // [cfail2]compile-flags: -Zincremental-ignore-spans
  11. // [cfail3]compile-flags: -Zincremental-ignore-spans
  12. // [cfail4]compile-flags: -Zincremental-relative-spans
  13. // [cfail5]compile-flags: -Zincremental-relative-spans
  14. // [cfail6]compile-flags: -Zincremental-relative-spans
  15. #![allow(warnings)]
  16. #![feature(rustc_attrs)]
  17. #![feature(unboxed_closures)]
  18. #![crate_type = "rlib"]
  19. // Change function name --------------------------------------------------------
  20. #[cfg(any(cfail1,cfail4))]
  21. extern "C" {
  22. pub fn change_function_name1(c: i64) -> i32;
  23. }
  24. #[cfg(not(any(cfail1,cfail4)))]
  25. #[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
  26. #[rustc_clean(cfg = "cfail3")]
  27. #[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
  28. #[rustc_clean(cfg = "cfail6")]
  29. extern "C" {
  30. pub fn change_function_name2(c: i64) -> i32;
  31. }
  32. // Change parameter name -------------------------------------------------------
  33. #[cfg(any(cfail1,cfail4))]
  34. extern "C" {
  35. pub fn change_parameter_name(c: i64) -> i32;
  36. }
  37. #[cfg(not(any(cfail1,cfail4)))]
  38. #[rustc_clean(cfg = "cfail2")]
  39. #[rustc_clean(cfg = "cfail3")]
  40. #[rustc_clean(cfg = "cfail5")]
  41. #[rustc_clean(cfg = "cfail6")]
  42. extern "C" {
  43. pub fn change_parameter_name(d: i64) -> i32;
  44. }
  45. // Change parameter type -------------------------------------------------------
  46. #[cfg(any(cfail1,cfail4))]
  47. extern "C" {
  48. pub fn change_parameter_type(c: i64) -> i32;
  49. }
  50. #[cfg(not(any(cfail1,cfail4)))]
  51. #[rustc_clean(cfg = "cfail2")]
  52. #[rustc_clean(cfg = "cfail3")]
  53. #[rustc_clean(cfg = "cfail5")]
  54. #[rustc_clean(cfg = "cfail6")]
  55. extern "C" {
  56. pub fn change_parameter_type(c: i32) -> i32;
  57. }
  58. // Change return type ----------------------------------------------------------
  59. #[cfg(any(cfail1,cfail4))]
  60. extern "C" {
  61. pub fn change_return_type(c: i32) -> i32;
  62. }
  63. #[cfg(not(any(cfail1,cfail4)))]
  64. #[rustc_clean(cfg = "cfail2")]
  65. #[rustc_clean(cfg = "cfail3")]
  66. #[rustc_clean(cfg = "cfail5")]
  67. #[rustc_clean(cfg = "cfail6")]
  68. extern "C" {
  69. pub fn change_return_type(c: i32) -> i8 ;
  70. }
  71. // Add parameter ---------------------------------------------------------------
  72. #[cfg(any(cfail1,cfail4))]
  73. extern "C" {
  74. pub fn add_parameter(c: i32 ) -> i32;
  75. }
  76. #[cfg(not(any(cfail1,cfail4)))]
  77. #[rustc_clean(cfg = "cfail2")]
  78. #[rustc_clean(cfg = "cfail3")]
  79. #[rustc_clean(cfg = "cfail5")]
  80. #[rustc_clean(cfg = "cfail6")]
  81. extern "C" {
  82. pub fn add_parameter(c: i32, d: i32) -> i32;
  83. }
  84. // Add return type -------------------------------------------------------------
  85. #[cfg(any(cfail1,cfail4))]
  86. extern "C" {
  87. pub fn add_return_type(c: i32) ;
  88. }
  89. #[cfg(not(any(cfail1,cfail4)))]
  90. #[rustc_clean(cfg = "cfail2")]
  91. #[rustc_clean(cfg = "cfail3")]
  92. #[rustc_clean(cfg = "cfail5")]
  93. #[rustc_clean(cfg = "cfail6")]
  94. extern "C" {
  95. pub fn add_return_type(c: i32) -> i32;
  96. }
  97. // Make function variadic ------------------------------------------------------
  98. #[cfg(any(cfail1,cfail4))]
  99. extern "C" {
  100. pub fn make_function_variadic(c: i32 );
  101. }
  102. #[cfg(not(any(cfail1,cfail4)))]
  103. #[rustc_clean(cfg = "cfail2")]
  104. #[rustc_clean(cfg = "cfail3")]
  105. #[rustc_clean(cfg = "cfail5")]
  106. #[rustc_clean(cfg = "cfail6")]
  107. extern "C" {
  108. pub fn make_function_variadic(c: i32, ...);
  109. }
  110. // Change calling convention ---------------------------------------------------
  111. #[cfg(any(cfail1,cfail4))]
  112. extern "C" {
  113. pub fn change_calling_convention(c: i32);
  114. }
  115. #[cfg(not(any(cfail1,cfail4)))]
  116. #[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
  117. #[rustc_clean(cfg = "cfail3")]
  118. #[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
  119. #[rustc_clean(cfg = "cfail6")]
  120. extern "rust-call" {
  121. pub fn change_calling_convention(c: i32);
  122. }
  123. // Make function public --------------------------------------------------------
  124. #[cfg(any(cfail1,cfail4))]
  125. extern "C" {
  126. fn make_function_public(c: i32);
  127. }
  128. #[cfg(not(any(cfail1,cfail4)))]
  129. #[rustc_clean(cfg = "cfail2")]
  130. #[rustc_clean(cfg = "cfail3")]
  131. #[rustc_clean(cfg = "cfail5")]
  132. #[rustc_clean(cfg = "cfail6")]
  133. extern "C" {
  134. pub fn make_function_public(c: i32);
  135. }
  136. // Add function ----------------------------------------------------------------
  137. #[cfg(any(cfail1,cfail4))]
  138. extern "C" {
  139. pub fn add_function1(c: i32);
  140. }
  141. #[cfg(not(any(cfail1,cfail4)))]
  142. #[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
  143. #[rustc_clean(cfg = "cfail3")]
  144. #[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
  145. #[rustc_clean(cfg = "cfail6")]
  146. extern "C" {
  147. pub fn add_function1(c: i32);
  148. pub fn add_function2();
  149. }
  150. // Change link-name ------------------------------------------------------------
  151. #[cfg(any(cfail1,cfail4))]
  152. #[link(name = "foo")]
  153. extern "C" {
  154. pub fn change_link_name(c: i32);
  155. }
  156. #[cfg(not(any(cfail1,cfail4)))]
  157. #[rustc_clean(cfg = "cfail2")]
  158. #[rustc_clean(cfg = "cfail3")]
  159. #[rustc_clean(cfg = "cfail5")]
  160. #[rustc_clean(cfg = "cfail6")]
  161. #[link(name = "bar")]
  162. extern "C" {
  163. pub fn change_link_name(c: i32);
  164. }
  165. type c_i32 = i32;
  166. type c_i64 = i64;
  167. // Indirectly change parameter type --------------------------------------------
  168. mod indirectly_change_parameter_type {
  169. #[cfg(any(cfail1,cfail4))]
  170. use super::c_i32 as c_int;
  171. #[cfg(not(any(cfail1,cfail4)))]
  172. use super::c_i64 as c_int;
  173. #[rustc_clean(cfg = "cfail2")]
  174. #[rustc_clean(cfg = "cfail3")]
  175. #[rustc_clean(cfg = "cfail5")]
  176. #[rustc_clean(cfg = "cfail6")]
  177. extern "C" {
  178. pub fn indirectly_change_parameter_type(c: c_int);
  179. }
  180. }
  181. // Indirectly change return type --------------------------------------------
  182. mod indirectly_change_return_type {
  183. #[cfg(any(cfail1,cfail4))]
  184. use super::c_i32 as c_int;
  185. #[cfg(not(any(cfail1,cfail4)))]
  186. use super::c_i64 as c_int;
  187. #[rustc_clean(cfg = "cfail2")]
  188. #[rustc_clean(cfg = "cfail3")]
  189. #[rustc_clean(cfg = "cfail5")]
  190. #[rustc_clean(cfg = "cfail6")]
  191. extern "C" {
  192. pub fn indirectly_change_return_type() -> c_int;
  193. }
  194. }