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

https://gitlab.com/rust-lang/rust · Rust · 137 lines · 87 code · 29 blank · 21 comment · 0 complexity · fed85008ddfd20d728cf67ddcd9b5f17 MD5 · raw file

  1. // This test case tests the incremental compilation hash (ICH) implementation
  2. // for indexing expression.
  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. // Change simple index
  19. #[cfg(any(cfail1,cfail4))]
  20. fn change_simple_index(slice: &[u32]) -> u32 {
  21. slice[3]
  22. }
  23. #[cfg(not(any(cfail1,cfail4)))]
  24. #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
  25. #[rustc_clean(cfg="cfail3")]
  26. #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
  27. #[rustc_clean(cfg="cfail6")]
  28. fn change_simple_index(slice: &[u32]) -> u32 {
  29. slice[4]
  30. }
  31. // Change lower bound
  32. #[cfg(any(cfail1,cfail4))]
  33. fn change_lower_bound(slice: &[u32]) -> &[u32] {
  34. &slice[3..5]
  35. }
  36. #[cfg(not(any(cfail1,cfail4)))]
  37. #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
  38. #[rustc_clean(cfg="cfail3")]
  39. #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
  40. #[rustc_clean(cfg="cfail6")]
  41. fn change_lower_bound(slice: &[u32]) -> &[u32] {
  42. &slice[2..5]
  43. }
  44. // Change upper bound
  45. #[cfg(any(cfail1,cfail4))]
  46. fn change_upper_bound(slice: &[u32]) -> &[u32] {
  47. &slice[3..5]
  48. }
  49. #[cfg(not(any(cfail1,cfail4)))]
  50. #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
  51. #[rustc_clean(cfg="cfail3")]
  52. #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
  53. #[rustc_clean(cfg="cfail6")]
  54. fn change_upper_bound(slice: &[u32]) -> &[u32] {
  55. &slice[3..7]
  56. }
  57. // Add lower bound
  58. #[cfg(any(cfail1,cfail4))]
  59. fn add_lower_bound(slice: &[u32]) -> &[u32] {
  60. &slice[ ..4]
  61. }
  62. #[cfg(not(any(cfail1,cfail4)))]
  63. #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
  64. #[rustc_clean(cfg="cfail3")]
  65. #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
  66. #[rustc_clean(cfg="cfail6")]
  67. fn add_lower_bound(slice: &[u32]) -> &[u32] {
  68. &slice[3..4]
  69. }
  70. // Add upper bound
  71. #[cfg(any(cfail1,cfail4))]
  72. fn add_upper_bound(slice: &[u32]) -> &[u32] {
  73. &slice[3.. ]
  74. }
  75. #[cfg(not(any(cfail1,cfail4)))]
  76. #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
  77. #[rustc_clean(cfg="cfail3")]
  78. #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
  79. #[rustc_clean(cfg="cfail6")]
  80. fn add_upper_bound(slice: &[u32]) -> &[u32] {
  81. &slice[3..7]
  82. }
  83. // Change mutability
  84. #[cfg(any(cfail1,cfail4))]
  85. fn change_mutability(slice: &mut [u32]) -> u32 {
  86. (&mut slice[3..5])[0]
  87. }
  88. #[cfg(not(any(cfail1,cfail4)))]
  89. #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
  90. #[rustc_clean(cfg="cfail3")]
  91. #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
  92. #[rustc_clean(cfg="cfail6")]
  93. fn change_mutability(slice: &mut [u32]) -> u32 {
  94. (& slice[3..5])[0]
  95. }
  96. // Exclusive to inclusive range
  97. #[cfg(any(cfail1,cfail4))]
  98. fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
  99. &slice[3.. 7]
  100. }
  101. #[cfg(not(any(cfail1,cfail4)))]
  102. #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail2")]
  103. #[rustc_clean(cfg="cfail3")]
  104. #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck", cfg="cfail5")]
  105. #[rustc_clean(cfg="cfail6")]
  106. fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
  107. &slice[3..=7]
  108. }