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.
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.
11 // This test case tests the incremental compilation hash (ICH) implementation
12 // for exprs that can panic at runtime (e.g. because of bounds checking). For
13 // these expressions an error message containing their source location is
14 // generated, so their hash must always depend on their location in the source
15 // code, not just when debuginfo is enabled.
17 // The general pattern followed here is: Change one thing between rev1 and rev2
18 // and make sure that the hash has changed, then change nothing between rev2 and
19 // rev3 and make sure that the hash has not changed.
22 // revisions: cfail1 cfail2 cfail3
23 // compile-flags: -Z query-dep-graph -C debug-assertions
26 #![feature(rustc_attrs)]
30 // Indexing expression ---------------------------------------------------------
31 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
32 #[rustc_clean(cfg="cfail3")]
33 pub fn indexing(slice: &[u8]) -> u8 {
45 // Arithmetic overflow plus ----------------------------------------------------
46 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
47 #[rustc_clean(cfg="cfail3")]
48 pub fn arithmetic_overflow_plus(val: i32) -> i32 {
60 // Arithmetic overflow minus ----------------------------------------------------
61 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
62 #[rustc_clean(cfg="cfail3")]
63 pub fn arithmetic_overflow_minus(val: i32) -> i32 {
75 // Arithmetic overflow mult ----------------------------------------------------
76 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
77 #[rustc_clean(cfg="cfail3")]
78 pub fn arithmetic_overflow_mult(val: i32) -> i32 {
90 // Arithmetic overflow negation ------------------------------------------------
91 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
92 #[rustc_clean(cfg="cfail3")]
93 pub fn arithmetic_overflow_negation(val: i32) -> i32 {
105 // Division by zero ------------------------------------------------------------
106 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
107 #[rustc_clean(cfg="cfail3")]
108 pub fn division_by_zero(val: i32) -> i32 {
119 // Division by zero ------------------------------------------------------------
120 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
121 #[rustc_clean(cfg="cfail3")]
122 pub fn mod_by_zero(val: i32) -> i32 {
134 // shift left ------------------------------------------------------------------
135 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
136 #[rustc_clean(cfg="cfail3")]
137 pub fn shift_left(val: i32, shift: usize) -> i32 {
149 // shift right ------------------------------------------------------------------
150 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
151 #[rustc_clean(cfg="cfail3")]
152 pub fn shift_right(val: i32, shift: usize) -> i32 {