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

https://gitlab.com/rust-lang/rust · Rust · 414 lines · 295 code · 80 blank · 39 comment · 0 complexity · 2b199b0fe28514dc133b9f3097c838f5 MD5 · raw file

  1. // This test case tests the incremental compilation hash (ICH) implementation
  2. // for function interfaces.
  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(linkage)]
  17. #![feature(rustc_attrs)]
  18. #![crate_type = "rlib"]
  19. // Add Parameter ---------------------------------------------------------------
  20. #[cfg(any(cfail1,cfail4))]
  21. pub fn add_parameter() {}
  22. #[cfg(not(any(cfail1,cfail4)))]
  23. #[rustc_clean(
  24. cfg = "cfail2",
  25. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  26. )]
  27. #[rustc_clean(cfg = "cfail3")]
  28. #[rustc_clean(
  29. cfg = "cfail5",
  30. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  31. )]
  32. #[rustc_clean(cfg = "cfail6")]
  33. pub fn add_parameter(p: i32) {}
  34. // Add Return Type -------------------------------------------------------------
  35. #[cfg(any(cfail1,cfail4))]
  36. pub fn add_return_type() {}
  37. #[cfg(not(any(cfail1,cfail4)))]
  38. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes")]
  39. #[rustc_clean(cfg = "cfail3")]
  40. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, optimized_mir")]
  41. #[rustc_clean(cfg = "cfail6")]
  42. pub fn add_return_type() -> () {}
  43. // Change Parameter Type -------------------------------------------------------
  44. #[cfg(any(cfail1,cfail4))]
  45. pub fn type_of_parameter(p: i32) {}
  46. #[cfg(not(any(cfail1,cfail4)))]
  47. #[rustc_clean(
  48. cfg = "cfail2",
  49. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  50. )]
  51. #[rustc_clean(cfg = "cfail3")]
  52. #[rustc_clean(
  53. cfg = "cfail5",
  54. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  55. )]
  56. #[rustc_clean(cfg = "cfail6")]
  57. pub fn type_of_parameter(p: i64) {}
  58. // Change Parameter Type Reference ---------------------------------------------
  59. #[cfg(any(cfail1,cfail4))]
  60. pub fn type_of_parameter_ref(p: &i32) {}
  61. #[cfg(not(any(cfail1,cfail4)))]
  62. #[rustc_clean(
  63. cfg = "cfail2",
  64. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  65. )]
  66. #[rustc_clean(cfg = "cfail3")]
  67. #[rustc_clean(
  68. cfg = "cfail5",
  69. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  70. )]
  71. #[rustc_clean(cfg = "cfail6")]
  72. pub fn type_of_parameter_ref(p: &mut i32) {}
  73. // Change Parameter Order ------------------------------------------------------
  74. #[cfg(any(cfail1,cfail4))]
  75. pub fn order_of_parameters(p1: i32, p2: i64) {}
  76. #[cfg(not(any(cfail1,cfail4)))]
  77. #[rustc_clean(
  78. cfg = "cfail2",
  79. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  80. )]
  81. #[rustc_clean(cfg = "cfail3")]
  82. #[rustc_clean(
  83. cfg = "cfail5",
  84. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  85. )]
  86. #[rustc_clean(cfg = "cfail6")]
  87. pub fn order_of_parameters(p2: i64, p1: i32) {}
  88. // Unsafe ----------------------------------------------------------------------
  89. #[cfg(any(cfail1,cfail4))]
  90. pub fn make_unsafe() {}
  91. #[cfg(not(any(cfail1,cfail4)))]
  92. #[rustc_clean(
  93. cfg = "cfail2",
  94. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  95. )]
  96. #[rustc_clean(cfg = "cfail3")]
  97. #[rustc_clean(
  98. cfg = "cfail5",
  99. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  100. )]
  101. #[rustc_clean(cfg = "cfail6")]
  102. pub unsafe fn make_unsafe() {}
  103. // Extern ----------------------------------------------------------------------
  104. #[cfg(any(cfail1,cfail4))]
  105. pub fn make_extern() {}
  106. #[cfg(not(any(cfail1,cfail4)))]
  107. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
  108. #[rustc_clean(cfg = "cfail3")]
  109. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
  110. #[rustc_clean(cfg = "cfail6")]
  111. pub extern "C" fn make_extern() {}
  112. // Type Parameter --------------------------------------------------------------
  113. #[cfg(any(cfail1,cfail4))]
  114. pub fn type_parameter () {}
  115. #[cfg(not(any(cfail1,cfail4)))]
  116. #[rustc_clean(
  117. cfg = "cfail2",
  118. except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
  119. )]
  120. #[rustc_clean(cfg = "cfail3")]
  121. #[rustc_clean(
  122. cfg = "cfail5",
  123. except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
  124. )]
  125. #[rustc_clean(cfg = "cfail6")]
  126. pub fn type_parameter<T>() {}
  127. // Lifetime Parameter ----------------------------------------------------------
  128. #[cfg(any(cfail1,cfail4))]
  129. pub fn lifetime_parameter () {}
  130. #[cfg(not(any(cfail1,cfail4)))]
  131. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")]
  132. #[rustc_clean(cfg = "cfail3")]
  133. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")]
  134. #[rustc_clean(cfg = "cfail6")]
  135. pub fn lifetime_parameter<'a>() {}
  136. // Trait Bound -----------------------------------------------------------------
  137. #[cfg(any(cfail1,cfail4))]
  138. pub fn trait_bound<T >() {}
  139. #[cfg(not(any(cfail1,cfail4)))]
  140. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
  141. #[rustc_clean(cfg = "cfail3")]
  142. pub fn trait_bound<T: Eq>() {}
  143. // Builtin Bound ---------------------------------------------------------------
  144. #[cfg(any(cfail1,cfail4))]
  145. pub fn builtin_bound<T >() {}
  146. #[cfg(not(any(cfail1,cfail4)))]
  147. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
  148. #[rustc_clean(cfg = "cfail3")]
  149. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
  150. #[rustc_clean(cfg = "cfail6")]
  151. pub fn builtin_bound<T: Send>() {}
  152. // Lifetime Bound --------------------------------------------------------------
  153. #[cfg(any(cfail1,cfail4))]
  154. pub fn lifetime_bound<'a, T>() {}
  155. #[cfg(not(any(cfail1,cfail4)))]
  156. #[rustc_clean(
  157. cfg = "cfail2",
  158. except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
  159. )]
  160. #[rustc_clean(cfg = "cfail3")]
  161. #[rustc_clean(
  162. cfg = "cfail5",
  163. except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig,optimized_mir"
  164. )]
  165. #[rustc_clean(cfg = "cfail6")]
  166. pub fn lifetime_bound<'a, T: 'a>() {}
  167. // Second Trait Bound ----------------------------------------------------------
  168. #[cfg(any(cfail1,cfail4))]
  169. pub fn second_trait_bound<T: Eq >() {}
  170. #[cfg(not(any(cfail1,cfail4)))]
  171. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
  172. #[rustc_clean(cfg = "cfail3")]
  173. pub fn second_trait_bound<T: Eq + Clone>() {}
  174. // Second Builtin Bound --------------------------------------------------------
  175. #[cfg(any(cfail1,cfail4))]
  176. pub fn second_builtin_bound<T: Send >() {}
  177. #[cfg(not(any(cfail1,cfail4)))]
  178. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
  179. #[rustc_clean(cfg = "cfail3")]
  180. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
  181. #[rustc_clean(cfg = "cfail6")]
  182. pub fn second_builtin_bound<T: Send + Sized>() {}
  183. // Second Lifetime Bound -------------------------------------------------------
  184. #[cfg(any(cfail1,cfail4))]
  185. pub fn second_lifetime_bound<'a, 'b, T: 'a >() {}
  186. #[cfg(not(any(cfail1,cfail4)))]
  187. #[rustc_clean(
  188. cfg = "cfail2",
  189. except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
  190. )]
  191. #[rustc_clean(cfg = "cfail3")]
  192. #[rustc_clean(
  193. cfg = "cfail5",
  194. except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
  195. )]
  196. #[rustc_clean(cfg = "cfail6")]
  197. pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {}
  198. // Inline ----------------------------------------------------------------------
  199. #[cfg(any(cfail1,cfail4))]
  200. pub fn inline() {}
  201. #[cfg(not(any(cfail1,cfail4)))]
  202. #[rustc_clean(cfg = "cfail2")]
  203. #[rustc_clean(cfg = "cfail3")]
  204. #[rustc_clean(cfg = "cfail5")]
  205. #[rustc_clean(cfg = "cfail6")]
  206. #[inline]
  207. pub fn inline() {}
  208. // Inline Never ----------------------------------------------------------------
  209. #[cfg(any(cfail1,cfail4))]
  210. #[inline(always)]
  211. pub fn inline_never() {}
  212. #[cfg(not(any(cfail1,cfail4)))]
  213. #[rustc_clean(cfg = "cfail2")]
  214. #[rustc_clean(cfg = "cfail3")]
  215. #[rustc_clean(cfg = "cfail5")]
  216. #[rustc_clean(cfg = "cfail6")]
  217. #[inline(never)]
  218. pub fn inline_never() {}
  219. // No Mangle -------------------------------------------------------------------
  220. #[cfg(any(cfail1,cfail4))]
  221. pub fn no_mangle() {}
  222. #[cfg(not(any(cfail1,cfail4)))]
  223. #[rustc_clean(cfg = "cfail2")]
  224. #[rustc_clean(cfg = "cfail3")]
  225. #[rustc_clean(cfg = "cfail5")]
  226. #[rustc_clean(cfg = "cfail6")]
  227. #[no_mangle]
  228. pub fn no_mangle() {}
  229. // Linkage ---------------------------------------------------------------------
  230. #[cfg(any(cfail1,cfail4))]
  231. pub fn linkage() {}
  232. #[cfg(not(any(cfail1,cfail4)))]
  233. #[rustc_clean(cfg = "cfail2")]
  234. #[rustc_clean(cfg = "cfail3")]
  235. #[rustc_clean(cfg = "cfail5")]
  236. #[rustc_clean(cfg = "cfail6")]
  237. #[linkage = "weak_odr"]
  238. pub fn linkage() {}
  239. // Return Impl Trait -----------------------------------------------------------
  240. #[cfg(any(cfail1,cfail4))]
  241. pub fn return_impl_trait() -> i32 {
  242. 0
  243. }
  244. #[cfg(not(any(cfail1,cfail4)))]
  245. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
  246. #[rustc_clean(cfg = "cfail3")]
  247. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
  248. #[rustc_clean(cfg = "cfail6")]
  249. pub fn return_impl_trait() -> impl Clone {
  250. 0
  251. }
  252. // Change Return Impl Trait ----------------------------------------------------
  253. #[cfg(any(cfail1,cfail4))]
  254. pub fn change_return_impl_trait() -> impl Clone {
  255. 0u32
  256. }
  257. #[cfg(not(any(cfail1,cfail4)))]
  258. #[rustc_clean(cfg = "cfail2")]
  259. #[rustc_clean(cfg = "cfail3")]
  260. #[rustc_clean(cfg = "cfail5")]
  261. #[rustc_clean(cfg = "cfail6")]
  262. pub fn change_return_impl_trait() -> impl Copy {
  263. 0u32
  264. }
  265. // Change Return Type Indirectly -----------------------------------------------
  266. pub struct ReferencedType1;
  267. pub struct ReferencedType2;
  268. pub mod change_return_type_indirectly {
  269. #[cfg(any(cfail1,cfail4))]
  270. use super::ReferencedType1 as ReturnType;
  271. #[cfg(not(any(cfail1,cfail4)))]
  272. use super::ReferencedType2 as ReturnType;
  273. #[rustc_clean(
  274. cfg = "cfail2",
  275. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  276. )]
  277. #[rustc_clean(cfg = "cfail3")]
  278. #[rustc_clean(
  279. cfg = "cfail5",
  280. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  281. )]
  282. #[rustc_clean(cfg = "cfail6")]
  283. pub fn indirect_return_type() -> ReturnType {
  284. ReturnType {}
  285. }
  286. }
  287. // Change Parameter Type Indirectly --------------------------------------------
  288. pub mod change_parameter_type_indirectly {
  289. #[cfg(any(cfail1,cfail4))]
  290. use super::ReferencedType1 as ParameterType;
  291. #[cfg(not(any(cfail1,cfail4)))]
  292. use super::ReferencedType2 as ParameterType;
  293. #[rustc_clean(
  294. cfg = "cfail2",
  295. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  296. )]
  297. #[rustc_clean(cfg = "cfail3")]
  298. #[rustc_clean(
  299. cfg = "cfail5",
  300. except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
  301. )]
  302. #[rustc_clean(cfg = "cfail6")]
  303. pub fn indirect_parameter_type(p: ParameterType) {}
  304. }
  305. // Change Trait Bound Indirectly -----------------------------------------------
  306. pub trait ReferencedTrait1 {}
  307. pub trait ReferencedTrait2 {}
  308. pub mod change_trait_bound_indirectly {
  309. #[cfg(any(cfail1,cfail4))]
  310. use super::ReferencedTrait1 as Trait;
  311. #[cfg(not(any(cfail1,cfail4)))]
  312. use super::ReferencedTrait2 as Trait;
  313. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
  314. #[rustc_clean(cfg = "cfail3")]
  315. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
  316. #[rustc_clean(cfg = "cfail6")]
  317. pub fn indirect_trait_bound<T: Trait>(p: T) {}
  318. }
  319. // Change Trait Bound Indirectly In Where Clause -------------------------------
  320. pub mod change_trait_bound_indirectly_in_where_clause {
  321. #[cfg(any(cfail1,cfail4))]
  322. use super::ReferencedTrait1 as Trait;
  323. #[cfg(not(any(cfail1,cfail4)))]
  324. use super::ReferencedTrait2 as Trait;
  325. #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
  326. #[rustc_clean(cfg = "cfail3")]
  327. #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
  328. #[rustc_clean(cfg = "cfail6")]
  329. pub fn indirect_trait_bound_where<T>(p: T)
  330. where
  331. T: Trait,
  332. {
  333. }
  334. }