/src/test/incremental/hashes/function_interfaces.rs

https://gitlab.com/jianglu/rust · Rust · 361 lines · 206 code · 112 blank · 43 comment · 0 complexity · 2e8e8f5a9b2cc1d3c936effe31adfa63 MD5 · raw file

  1. // Copyright 2016 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. // This test case tests the incremental compilation hash (ICH) implementation
  11. // for function interfaces.
  12. // The general pattern followed here is: Change one thing between rev1 and rev2
  13. // and make sure that the hash has changed, then change nothing between rev2 and
  14. // rev3 and make sure that the hash has not changed.
  15. // compile-pass
  16. // revisions: cfail1 cfail2 cfail3
  17. // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
  18. #![allow(warnings)]
  19. #![feature(intrinsics)]
  20. #![feature(linkage)]
  21. #![feature(rustc_attrs)]
  22. #![crate_type = "rlib"]
  23. // Add Parameter ---------------------------------------------------------------
  24. #[cfg(cfail1)]
  25. pub fn add_parameter() {}
  26. #[cfg(not(cfail1))]
  27. #[rustc_clean(cfg = "cfail2",
  28. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  29. #[rustc_clean(cfg = "cfail3")]
  30. pub fn add_parameter(p: i32) {}
  31. // Add Return Type -------------------------------------------------------------
  32. #[cfg(cfail1)]
  33. pub fn add_return_type() {}
  34. #[cfg(not(cfail1))]
  35. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
  36. #[rustc_clean(cfg = "cfail3")]
  37. pub fn add_return_type() -> () {}
  38. // Change Parameter Type -------------------------------------------------------
  39. #[cfg(cfail1)]
  40. pub fn type_of_parameter(p: i32) {}
  41. #[cfg(not(cfail1))]
  42. #[rustc_clean(cfg = "cfail2",
  43. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  44. #[rustc_clean(cfg = "cfail3")]
  45. pub fn type_of_parameter(p: i64) {}
  46. // Change Parameter Type Reference ---------------------------------------------
  47. #[cfg(cfail1)]
  48. pub fn type_of_parameter_ref(p: &i32) {}
  49. #[cfg(not(cfail1))]
  50. #[rustc_clean(cfg = "cfail2",
  51. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  52. #[rustc_clean(cfg = "cfail3")]
  53. pub fn type_of_parameter_ref(p: &mut i32) {}
  54. // Change Parameter Order ------------------------------------------------------
  55. #[cfg(cfail1)]
  56. pub fn order_of_parameters(p1: i32, p2: i64) {}
  57. #[cfg(not(cfail1))]
  58. #[rustc_clean(cfg = "cfail2",
  59. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  60. #[rustc_clean(cfg = "cfail3")]
  61. pub fn order_of_parameters(p2: i64, p1: i32) {}
  62. // Unsafe ----------------------------------------------------------------------
  63. #[cfg(cfail1)]
  64. pub fn make_unsafe() {}
  65. #[cfg(not(cfail1))]
  66. #[rustc_clean(cfg = "cfail2",
  67. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  68. #[rustc_clean(cfg = "cfail3")]
  69. pub unsafe fn make_unsafe() {}
  70. // Extern ----------------------------------------------------------------------
  71. #[cfg(cfail1)]
  72. pub fn make_extern() {}
  73. #[cfg(not(cfail1))]
  74. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, TypeckTables, FnSignature")]
  75. #[rustc_clean(cfg = "cfail3")]
  76. pub extern "C" fn make_extern() {}
  77. // Extern C Extern Rust-Intrinsic ----------------------------------------------
  78. #[cfg(cfail1)]
  79. pub extern "C" fn make_intrinsic() {}
  80. #[cfg(not(cfail1))]
  81. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, TypeckTables, FnSignature")]
  82. #[rustc_clean(cfg = "cfail3")]
  83. pub extern "rust-intrinsic" fn make_intrinsic() {}
  84. // Type Parameter --------------------------------------------------------------
  85. #[cfg(cfail1)]
  86. pub fn type_parameter() {}
  87. #[cfg(not(cfail1))]
  88. #[rustc_clean(cfg = "cfail2",
  89. except = "Hir, HirBody, GenericsOfItem, TypeOfItem, PredicatesOfItem")]
  90. #[rustc_clean(cfg = "cfail3")]
  91. pub fn type_parameter<T>() {}
  92. // Lifetime Parameter ----------------------------------------------------------
  93. #[cfg(cfail1)]
  94. pub fn lifetime_parameter() {}
  95. #[cfg(not(cfail1))]
  96. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, GenericsOfItem")]
  97. #[rustc_clean(cfg = "cfail3")]
  98. pub fn lifetime_parameter<'a>() {}
  99. // Trait Bound -----------------------------------------------------------------
  100. #[cfg(cfail1)]
  101. pub fn trait_bound<T>() {}
  102. #[cfg(not(cfail1))]
  103. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
  104. #[rustc_clean(cfg = "cfail3")]
  105. pub fn trait_bound<T: Eq>() {}
  106. // Builtin Bound ---------------------------------------------------------------
  107. #[cfg(cfail1)]
  108. pub fn builtin_bound<T>() {}
  109. #[cfg(not(cfail1))]
  110. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
  111. #[rustc_clean(cfg = "cfail3")]
  112. pub fn builtin_bound<T: Send>() {}
  113. // Lifetime Bound --------------------------------------------------------------
  114. #[cfg(cfail1)]
  115. pub fn lifetime_bound<'a, T>() {}
  116. #[cfg(not(cfail1))]
  117. #[rustc_clean(cfg = "cfail2",
  118. except = "Hir, HirBody, GenericsOfItem, TypeOfItem, PredicatesOfItem")]
  119. #[rustc_clean(cfg = "cfail3")]
  120. pub fn lifetime_bound<'a, T: 'a>() {}
  121. // Second Trait Bound ----------------------------------------------------------
  122. #[cfg(cfail1)]
  123. pub fn second_trait_bound<T: Eq>() {}
  124. #[cfg(not(cfail1))]
  125. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
  126. #[rustc_clean(cfg = "cfail3")]
  127. pub fn second_trait_bound<T: Eq + Clone>() {}
  128. // Second Builtin Bound --------------------------------------------------------
  129. #[cfg(cfail1)]
  130. pub fn second_builtin_bound<T: Send>() {}
  131. #[cfg(not(cfail1))]
  132. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
  133. #[rustc_clean(cfg = "cfail3")]
  134. pub fn second_builtin_bound<T: Send + Sized>() {}
  135. // Second Lifetime Bound -------------------------------------------------------
  136. #[cfg(cfail1)]
  137. pub fn second_lifetime_bound<'a, 'b, T: 'a>() {}
  138. #[cfg(not(cfail1))]
  139. #[rustc_clean(cfg = "cfail2",
  140. except = "Hir, HirBody, GenericsOfItem, TypeOfItem, PredicatesOfItem")]
  141. #[rustc_clean(cfg = "cfail3")]
  142. pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {}
  143. // Inline ----------------------------------------------------------------------
  144. #[cfg(cfail1)]
  145. pub fn inline() {}
  146. #[cfg(not(cfail1))]
  147. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
  148. #[rustc_clean(cfg = "cfail3")]
  149. #[inline]
  150. pub fn inline() {}
  151. // Inline Never ----------------------------------------------------------------
  152. #[cfg(cfail1)]
  153. #[inline(always)]
  154. pub fn inline_never() {}
  155. #[cfg(not(cfail1))]
  156. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
  157. #[rustc_clean(cfg = "cfail3")]
  158. #[inline(never)]
  159. pub fn inline_never() {}
  160. // No Mangle -------------------------------------------------------------------
  161. #[cfg(cfail1)]
  162. pub fn no_mangle() {}
  163. #[cfg(not(cfail1))]
  164. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
  165. #[rustc_clean(cfg = "cfail3")]
  166. #[no_mangle]
  167. pub fn no_mangle() {}
  168. // Linkage ---------------------------------------------------------------------
  169. #[cfg(cfail1)]
  170. pub fn linkage() {}
  171. #[cfg(not(cfail1))]
  172. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
  173. #[rustc_clean(cfg = "cfail3")]
  174. #[linkage = "weak_odr"]
  175. pub fn linkage() {}
  176. // Return Impl Trait -----------------------------------------------------------
  177. #[cfg(cfail1)]
  178. pub fn return_impl_trait() -> i32 {
  179. 0
  180. }
  181. #[cfg(not(cfail1))]
  182. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, TypeckTables, FnSignature")]
  183. #[rustc_clean(cfg = "cfail3")]
  184. pub fn return_impl_trait() -> impl Clone {
  185. 0
  186. }
  187. // Change Return Impl Trait ----------------------------------------------------
  188. #[cfg(cfail1)]
  189. pub fn change_return_impl_trait() -> impl Clone {
  190. 0u32
  191. }
  192. #[cfg(not(cfail1))]
  193. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
  194. #[rustc_clean(cfg = "cfail3")]
  195. pub fn change_return_impl_trait() -> impl Copy {
  196. 0u32
  197. }
  198. // Change Return Type Indirectly -----------------------------------------------
  199. pub struct ReferencedType1;
  200. pub struct ReferencedType2;
  201. pub mod change_return_type_indirectly {
  202. #[cfg(cfail1)]
  203. use super::ReferencedType1 as ReturnType;
  204. #[cfg(not(cfail1))]
  205. use super::ReferencedType2 as ReturnType;
  206. #[rustc_clean(cfg = "cfail2",
  207. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  208. #[rustc_clean(cfg = "cfail3")]
  209. pub fn indirect_return_type() -> ReturnType {
  210. ReturnType {}
  211. }
  212. }
  213. // Change Parameter Type Indirectly --------------------------------------------
  214. pub mod change_parameter_type_indirectly {
  215. #[cfg(cfail1)]
  216. use super::ReferencedType1 as ParameterType;
  217. #[cfg(not(cfail1))]
  218. use super::ReferencedType2 as ParameterType;
  219. #[rustc_clean(cfg = "cfail2",
  220. except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
  221. #[rustc_clean(cfg = "cfail3")]
  222. pub fn indirect_parameter_type(p: ParameterType) {}
  223. }
  224. // Change Trait Bound Indirectly -----------------------------------------------
  225. pub trait ReferencedTrait1 {}
  226. pub trait ReferencedTrait2 {}
  227. pub mod change_trait_bound_indirectly {
  228. #[cfg(cfail1)]
  229. use super::ReferencedTrait1 as Trait;
  230. #[cfg(not(cfail1))]
  231. use super::ReferencedTrait2 as Trait;
  232. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
  233. #[rustc_clean(cfg = "cfail3")]
  234. pub fn indirect_trait_bound<T: Trait>(p: T) {}
  235. }
  236. // Change Trait Bound Indirectly In Where Clause -------------------------------
  237. pub mod change_trait_bound_indirectly_in_where_clause {
  238. #[cfg(cfail1)]
  239. use super::ReferencedTrait1 as Trait;
  240. #[cfg(not(cfail1))]
  241. use super::ReferencedTrait2 as Trait;
  242. #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
  243. #[rustc_clean(cfg = "cfail3")]
  244. pub fn indirect_trait_bound_where<T>(p: T)
  245. where
  246. T: Trait,
  247. {
  248. }
  249. }