/src/test/incremental/hashes/call_expressions.rs

https://gitlab.com/rust-lang/rust · Rust · 200 lines · 135 code · 40 blank · 25 comment · 0 complexity · 34542b59e042410eafbdebe45f2286bf MD5 · raw file

  1. // This test case tests the incremental compilation hash (ICH) implementation
  2. // for function and method call expressions.
  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. #![crate_type="rlib"]
  18. fn callee1(_x: u32, _y: i64) {}
  19. fn callee2(_x: u32, _y: i64) {}
  20. // Change Callee (Function)
  21. #[cfg(any(cfail1,cfail4))]
  22. pub fn change_callee_function() {
  23. callee1(1, 2)
  24. }
  25. #[cfg(not(any(cfail1,cfail4)))]
  26. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
  27. #[rustc_clean(cfg="cfail3")]
  28. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
  29. #[rustc_clean(cfg="cfail6")]
  30. pub fn change_callee_function() {
  31. callee2(1, 2)
  32. }
  33. // Change Argument (Function)
  34. #[cfg(any(cfail1,cfail4))]
  35. pub fn change_argument_function() {
  36. callee1(1, 2)
  37. }
  38. #[cfg(not(any(cfail1,cfail4)))]
  39. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
  40. #[rustc_clean(cfg="cfail3")]
  41. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
  42. #[rustc_clean(cfg="cfail6")]
  43. pub fn change_argument_function() {
  44. callee1(1, 3)
  45. }
  46. // Change Callee Indirectly (Function)
  47. mod change_callee_indirectly_function {
  48. #[cfg(any(cfail1,cfail4))]
  49. use super::callee1 as callee;
  50. #[cfg(not(any(cfail1,cfail4)))]
  51. use super::callee2 as callee;
  52. #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
  53. #[rustc_clean(cfg="cfail3")]
  54. #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
  55. #[rustc_clean(cfg="cfail6")]
  56. pub fn change_callee_indirectly_function() {
  57. callee(1, 2)
  58. }
  59. }
  60. struct Struct;
  61. impl Struct {
  62. fn method1(&self, _x: char, _y: bool) {}
  63. fn method2(&self, _x: char, _y: bool) {}
  64. }
  65. // Change Callee (Method)
  66. #[cfg(any(cfail1,cfail4))]
  67. pub fn change_callee_method() {
  68. let s = Struct;
  69. s.method1('x', true);
  70. }
  71. #[cfg(not(any(cfail1,cfail4)))]
  72. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
  73. #[rustc_clean(cfg="cfail3")]
  74. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
  75. #[rustc_clean(cfg="cfail6")]
  76. pub fn change_callee_method() {
  77. let s = Struct;
  78. s.method2('x', true);
  79. }
  80. // Change Argument (Method)
  81. #[cfg(any(cfail1,cfail4))]
  82. pub fn change_argument_method() {
  83. let s = Struct;
  84. s.method1('x', true);
  85. }
  86. #[cfg(not(any(cfail1,cfail4)))]
  87. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
  88. #[rustc_clean(cfg="cfail3")]
  89. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
  90. #[rustc_clean(cfg="cfail6")]
  91. pub fn change_argument_method() {
  92. let s = Struct;
  93. s.method1('y', true);
  94. }
  95. // Change Callee (Method, UFCS)
  96. #[cfg(any(cfail1,cfail4))]
  97. pub fn change_ufcs_callee_method() {
  98. let s = Struct;
  99. Struct::method1(&s, 'x', true);
  100. }
  101. #[cfg(not(any(cfail1,cfail4)))]
  102. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
  103. #[rustc_clean(cfg="cfail3")]
  104. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
  105. #[rustc_clean(cfg="cfail6")]
  106. pub fn change_ufcs_callee_method() {
  107. let s = Struct;
  108. Struct::method2(&s, 'x', true);
  109. }
  110. // Change Argument (Method, UFCS)
  111. #[cfg(any(cfail1,cfail4))]
  112. pub fn change_argument_method_ufcs() {
  113. let s = Struct;
  114. Struct::method1(&s, 'x', true);
  115. }
  116. #[cfg(not(any(cfail1,cfail4)))]
  117. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
  118. #[rustc_clean(cfg="cfail3")]
  119. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
  120. #[rustc_clean(cfg="cfail6")]
  121. pub fn change_argument_method_ufcs() {
  122. let s = Struct;
  123. Struct::method1(&s, 'x',false);
  124. }
  125. // Change To UFCS
  126. #[cfg(any(cfail1,cfail4))]
  127. pub fn change_to_ufcs() {
  128. let s = Struct;
  129. s.method1('x', true); // ------
  130. }
  131. #[cfg(not(any(cfail1,cfail4)))]
  132. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
  133. #[rustc_clean(cfg="cfail3")]
  134. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
  135. #[rustc_clean(cfg="cfail6")]
  136. // One might think this would be expanded in the hir_owner_nodes/Mir, but it actually
  137. // results in slightly different hir_owner/Mir.
  138. pub fn change_to_ufcs() {
  139. let s = Struct;
  140. Struct::method1(&s, 'x', true);
  141. }
  142. struct Struct2;
  143. impl Struct2 {
  144. fn method1(&self, _x: char, _y: bool) {}
  145. }
  146. // Change UFCS Callee Indirectly
  147. pub mod change_ufcs_callee_indirectly {
  148. #[cfg(any(cfail1,cfail4))]
  149. use super::Struct as Struct;
  150. #[cfg(not(any(cfail1,cfail4)))]
  151. use super::Struct2 as Struct;
  152. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
  153. #[rustc_clean(cfg="cfail3")]
  154. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
  155. #[rustc_clean(cfg="cfail6")]
  156. pub fn change_ufcs_callee_indirectly() {
  157. let s = Struct;
  158. Struct::method1(&s, 'q', false)
  159. }
  160. }