/src/test/incremental/hashes/indexing_expressions.rs

https://gitlab.com/jianglu/rust · Rust · 142 lines · 87 code · 31 blank · 24 comment · 0 complexity · 1bca43e3809e39d0f5b1828a8bfb7951 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 indexing expression.
  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 simple index ---------------------------------------------------------
  22. #[cfg(cfail1)]
  23. fn change_simple_index(slice: &[u32]) -> u32 {
  24. slice[3]
  25. }
  26. #[cfg(not(cfail1))]
  27. #[rustc_clean(label="Hir", cfg="cfail2")]
  28. #[rustc_clean(label="Hir", cfg="cfail3")]
  29. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  30. #[rustc_clean(label="HirBody", cfg="cfail3")]
  31. fn change_simple_index(slice: &[u32]) -> u32 {
  32. slice[4]
  33. }
  34. // Change lower bound ----------------------------------------------------------
  35. #[cfg(cfail1)]
  36. fn change_lower_bound(slice: &[u32]) -> &[u32] {
  37. &slice[3..5]
  38. }
  39. #[cfg(not(cfail1))]
  40. #[rustc_clean(label="Hir", cfg="cfail2")]
  41. #[rustc_clean(label="Hir", cfg="cfail3")]
  42. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  43. #[rustc_clean(label="HirBody", cfg="cfail3")]
  44. fn change_lower_bound(slice: &[u32]) -> &[u32] {
  45. &slice[2..5]
  46. }
  47. // Change upper bound ----------------------------------------------------------
  48. #[cfg(cfail1)]
  49. fn change_upper_bound(slice: &[u32]) -> &[u32] {
  50. &slice[3..5]
  51. }
  52. #[cfg(not(cfail1))]
  53. #[rustc_clean(label="Hir", cfg="cfail2")]
  54. #[rustc_clean(label="Hir", cfg="cfail3")]
  55. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  56. #[rustc_clean(label="HirBody", cfg="cfail3")]
  57. fn change_upper_bound(slice: &[u32]) -> &[u32] {
  58. &slice[3..7]
  59. }
  60. // Add lower bound -------------------------------------------------------------
  61. #[cfg(cfail1)]
  62. fn add_lower_bound(slice: &[u32]) -> &[u32] {
  63. &slice[..4]
  64. }
  65. #[cfg(not(cfail1))]
  66. #[rustc_clean(label="Hir", cfg="cfail2")]
  67. #[rustc_clean(label="Hir", cfg="cfail3")]
  68. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  69. #[rustc_clean(label="HirBody", cfg="cfail3")]
  70. fn add_lower_bound(slice: &[u32]) -> &[u32] {
  71. &slice[3..4]
  72. }
  73. // Add upper bound -------------------------------------------------------------
  74. #[cfg(cfail1)]
  75. fn add_upper_bound(slice: &[u32]) -> &[u32] {
  76. &slice[3..]
  77. }
  78. #[cfg(not(cfail1))]
  79. #[rustc_clean(label="Hir", cfg="cfail2")]
  80. #[rustc_clean(label="Hir", cfg="cfail3")]
  81. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  82. #[rustc_clean(label="HirBody", cfg="cfail3")]
  83. fn add_upper_bound(slice: &[u32]) -> &[u32] {
  84. &slice[3..7]
  85. }
  86. // Change mutability -----------------------------------------------------------
  87. #[cfg(cfail1)]
  88. fn change_mutability(slice: &mut [u32]) -> u32 {
  89. (&mut slice[3..5])[0]
  90. }
  91. #[cfg(not(cfail1))]
  92. #[rustc_clean(label="Hir", cfg="cfail2")]
  93. #[rustc_clean(label="Hir", cfg="cfail3")]
  94. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  95. #[rustc_clean(label="HirBody", cfg="cfail3")]
  96. fn change_mutability(slice: &mut [u32]) -> u32 {
  97. (&slice[3..5])[0]
  98. }
  99. // Exclusive to inclusive range ------------------------------------------------
  100. #[cfg(cfail1)]
  101. fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
  102. &slice[3..7]
  103. }
  104. #[cfg(not(cfail1))]
  105. #[rustc_clean(label="Hir", cfg="cfail2")]
  106. #[rustc_clean(label="Hir", cfg="cfail3")]
  107. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  108. #[rustc_clean(label="HirBody", cfg="cfail3")]
  109. fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
  110. &slice[3..=7]
  111. }