/src/test/incremental/hashes/let_expressions.rs

https://gitlab.com/jianglu/rust · Rust · 216 lines · 135 code · 52 blank · 29 comment · 0 complexity · 60cf275effd430e10c49d015fd553240 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 let expressions.
  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(rustc_attrs)]
  20. #![crate_type="rlib"]
  21. // Change Name -----------------------------------------------------------------
  22. #[cfg(cfail1)]
  23. pub fn change_name() {
  24. let _x = 2u64;
  25. }
  26. #[cfg(not(cfail1))]
  27. #[rustc_clean(cfg="cfail2",
  28. except="HirBody,MirValidated,MirOptimized")]
  29. #[rustc_clean(cfg="cfail3")]
  30. pub fn change_name() {
  31. let _y = 2u64;
  32. }
  33. // Add Type --------------------------------------------------------------------
  34. #[cfg(cfail1)]
  35. pub fn add_type() {
  36. let _x = 2u32;
  37. }
  38. #[cfg(not(cfail1))]
  39. #[rustc_clean(cfg="cfail2",
  40. except="HirBody,TypeckTables,MirValidated")]
  41. #[rustc_clean(cfg="cfail3")]
  42. pub fn add_type() {
  43. let _x: u32 = 2u32;
  44. }
  45. // Change Type -----------------------------------------------------------------
  46. #[cfg(cfail1)]
  47. pub fn change_type() {
  48. let _x: u64 = 2;
  49. }
  50. #[cfg(not(cfail1))]
  51. #[rustc_clean(cfg="cfail2",
  52. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  53. #[rustc_clean(cfg="cfail3")]
  54. pub fn change_type() {
  55. let _x: u8 = 2;
  56. }
  57. // Change Mutability of Reference Type -----------------------------------------
  58. #[cfg(cfail1)]
  59. pub fn change_mutability_of_reference_type() {
  60. let _x: &u64;
  61. }
  62. #[cfg(not(cfail1))]
  63. #[rustc_clean(cfg="cfail2",
  64. except="HirBody,TypeckTables,MirValidated")]
  65. #[rustc_clean(cfg="cfail3")]
  66. pub fn change_mutability_of_reference_type() {
  67. let _x: &mut u64;
  68. }
  69. // Change Mutability of Slot ---------------------------------------------------
  70. #[cfg(cfail1)]
  71. pub fn change_mutability_of_slot() {
  72. let mut _x: u64 = 0;
  73. }
  74. #[cfg(not(cfail1))]
  75. #[rustc_clean(cfg="cfail2",
  76. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  77. #[rustc_clean(cfg="cfail3")]
  78. pub fn change_mutability_of_slot() {
  79. let _x: u64 = 0;
  80. }
  81. // Change Simple Binding to Pattern --------------------------------------------
  82. #[cfg(cfail1)]
  83. pub fn change_simple_binding_to_pattern() {
  84. let _x = (0u8, 'x');
  85. }
  86. #[cfg(not(cfail1))]
  87. #[rustc_clean(cfg="cfail2",
  88. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  89. #[rustc_clean(cfg="cfail3")]
  90. pub fn change_simple_binding_to_pattern() {
  91. let (_a, _b) = (0u8, 'x');
  92. }
  93. // Change Name in Pattern ------------------------------------------------------
  94. #[cfg(cfail1)]
  95. pub fn change_name_in_pattern() {
  96. let (_a, _b) = (1u8, 'y');
  97. }
  98. #[cfg(not(cfail1))]
  99. #[rustc_clean(cfg="cfail2",
  100. except="HirBody,MirValidated,MirOptimized")]
  101. #[rustc_clean(cfg="cfail3")]
  102. pub fn change_name_in_pattern() {
  103. let (_a, _c) = (1u8, 'y');
  104. }
  105. // Add `ref` in Pattern --------------------------------------------------------
  106. #[cfg(cfail1)]
  107. pub fn add_ref_in_pattern() {
  108. let (_a, _b) = (1u8, 'y');
  109. }
  110. #[cfg(not(cfail1))]
  111. #[rustc_clean(cfg="cfail2",
  112. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  113. #[rustc_clean(cfg="cfail3")]
  114. pub fn add_ref_in_pattern() {
  115. let (ref _a, _b) = (1u8, 'y');
  116. }
  117. // Add `&` in Pattern ----------------------------------------------------------
  118. #[cfg(cfail1)]
  119. pub fn add_amp_in_pattern() {
  120. let (_a, _b) = (&1u8, 'y');
  121. }
  122. #[cfg(not(cfail1))]
  123. #[rustc_clean(cfg="cfail2",
  124. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  125. #[rustc_clean(cfg="cfail3")]
  126. pub fn add_amp_in_pattern() {
  127. let (&_a, _b) = (&1u8, 'y');
  128. }
  129. // Change Mutability of Binding in Pattern -------------------------------------
  130. #[cfg(cfail1)]
  131. pub fn change_mutability_of_binding_in_pattern() {
  132. let (_a, _b) = (99u8, 'q');
  133. }
  134. #[cfg(not(cfail1))]
  135. #[rustc_clean(cfg="cfail2",
  136. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  137. #[rustc_clean(cfg="cfail3")]
  138. pub fn change_mutability_of_binding_in_pattern() {
  139. let (mut _a, _b) = (99u8, 'q');
  140. }
  141. // Add Initializer -------------------------------------------------------------
  142. #[cfg(cfail1)]
  143. pub fn add_initializer() {
  144. let _x: i16;
  145. }
  146. #[cfg(not(cfail1))]
  147. #[rustc_clean(cfg="cfail2",
  148. except="HirBody,TypeckTables,MirValidated,MirOptimized")]
  149. #[rustc_clean(cfg="cfail3")]
  150. pub fn add_initializer() {
  151. let _x: i16 = 3i16;
  152. }
  153. // Change Initializer ----------------------------------------------------------
  154. #[cfg(cfail1)]
  155. pub fn change_initializer() {
  156. let _x = 4u16;
  157. }
  158. #[cfg(not(cfail1))]
  159. #[rustc_clean(cfg="cfail2",
  160. except="HirBody,MirValidated,MirOptimized")]
  161. #[rustc_clean(cfg="cfail3")]
  162. pub fn change_initializer() {
  163. let _x = 5u16;
  164. }