]>
git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/panic_exprs.rs
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.
21 // must-compile-successfully
22 // revisions: cfail1 cfail2 cfail3
23 // compile-flags: -Z query-dep-graph -C debug-assertions
26 #![feature(rustc_attrs)]
30 // Indexing expression ---------------------------------------------------------
32 pub fn indexing(slice
: &[u8]) -> u8 {
37 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
38 #[rustc_clean(cfg="cfail3")]
39 #[rustc_metadata_clean(cfg="cfail2")]
40 #[rustc_metadata_clean(cfg="cfail3")]
41 pub fn indexing(slice
: &[u8]) -> u8 {
46 // Arithmetic overflow plus ----------------------------------------------------
48 pub fn arithmetic_overflow_plus(val
: i32) -> i32 {
53 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
54 #[rustc_clean(cfg="cfail3")]
55 #[rustc_metadata_clean(cfg="cfail2")]
56 #[rustc_metadata_clean(cfg="cfail3")]
57 pub fn arithmetic_overflow_plus(val
: i32) -> i32 {
62 // Arithmetic overflow minus ----------------------------------------------------
64 pub fn arithmetic_overflow_minus(val
: i32) -> i32 {
69 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
70 #[rustc_clean(cfg="cfail3")]
71 #[rustc_metadata_clean(cfg="cfail2")]
72 #[rustc_metadata_clean(cfg="cfail3")]
73 pub fn arithmetic_overflow_minus(val
: i32) -> i32 {
78 // Arithmetic overflow mult ----------------------------------------------------
80 pub fn arithmetic_overflow_mult(val
: i32) -> i32 {
85 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
86 #[rustc_clean(cfg="cfail3")]
87 #[rustc_metadata_clean(cfg="cfail2")]
88 #[rustc_metadata_clean(cfg="cfail3")]
89 pub fn arithmetic_overflow_mult(val
: i32) -> i32 {
94 // Arithmetic overflow negation ------------------------------------------------
96 pub fn arithmetic_overflow_negation(val
: i32) -> i32 {
101 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
102 #[rustc_clean(cfg="cfail3")]
103 #[rustc_metadata_clean(cfg="cfail2")]
104 #[rustc_metadata_clean(cfg="cfail3")]
105 pub fn arithmetic_overflow_negation(val
: i32) -> i32 {
110 // Division by zero ------------------------------------------------------------
112 pub fn division_by_zero(val
: i32) -> i32 {
117 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
118 #[rustc_clean(cfg="cfail3")]
119 #[rustc_metadata_clean(cfg="cfail2")]
120 #[rustc_metadata_clean(cfg="cfail3")]
121 pub fn division_by_zero(val
: i32) -> i32 {
125 // Division by zero ------------------------------------------------------------
127 pub fn mod_by_zero(val
: i32) -> i32 {
132 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
133 #[rustc_clean(cfg="cfail3")]
134 #[rustc_metadata_clean(cfg="cfail2")]
135 #[rustc_metadata_clean(cfg="cfail3")]
136 pub fn mod_by_zero(val
: i32) -> i32 {
141 // shift left ------------------------------------------------------------------
143 pub fn shift_left(val
: i32, shift
: usize) -> i32 {
148 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
149 #[rustc_clean(cfg="cfail3")]
150 #[rustc_metadata_clean(cfg="cfail2")]
151 #[rustc_metadata_clean(cfg="cfail3")]
152 pub fn shift_left(val
: i32, shift
: usize) -> i32 {
157 // shift right ------------------------------------------------------------------
159 pub fn shift_right(val
: i32, shift
: usize) -> i32 {
164 #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
165 #[rustc_clean(cfg="cfail3")]
166 #[rustc_metadata_clean(cfg="cfail2")]
167 #[rustc_metadata_clean(cfg="cfail3")]
168 pub fn shift_right(val
: i32, shift
: usize) -> i32 {
173 // THE FOLLOWING ITEMS SHOULD NOT BE INFLUENCED BY THEIR SOURCE LOCATION
175 // bitwise ---------------------------------------------------------------------
177 pub fn bitwise(val
: i32) -> i32 {
178 !val
& 0x101010101 | 0x45689 ^
0x2372382
182 #[rustc_clean(cfg="cfail2")]
183 #[rustc_clean(cfg="cfail3")]
184 #[rustc_metadata_clean(cfg="cfail2")]
185 #[rustc_metadata_clean(cfg="cfail3")]
186 pub fn bitwise(val
: i32) -> i32 {
187 !val
& 0x101010101 | 0x45689 ^
0x2372382
191 // logical ---------------------------------------------------------------------
193 pub fn logical(val1
: bool
, val2
: bool
, val3
: bool
) -> bool
{
198 #[rustc_clean(cfg="cfail2")]
199 #[rustc_clean(cfg="cfail3")]
200 #[rustc_metadata_clean(cfg="cfail2")]
201 #[rustc_metadata_clean(cfg="cfail3")]
202 pub fn logical(val1
: bool
, val2
: bool
, val3
: bool
) -> bool
{