mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
72abf370bb
Long ago, UI tests were divided into "compile" and "run" tests. Later, the compile tests were further subdivided into "check" and "build" tests, to speed up tests that don't need a full build. The same split was never applied to incremental test revisions, so the only way to perform a check build in incremental tests is (confusingly) to use a `cfail` revision and then specify `//@ check-fail` or `//@ check-pass`. This PR makes room for dedicated check-fail and check-pass revisions by renaming the existing `cfail` and `cpass` revisions to `bfail` and `bpass`, since they currently perform a full build.
153 lines
3.2 KiB
Rust
153 lines
3.2 KiB
Rust
// This test case tests the incremental compilation hash (ICH) implementation
|
|
// for exprs that can panic at runtime (e.g., because of bounds checking). For
|
|
// these expressions an error message containing their source location is
|
|
// generated, so their hash must always depend on their location in the source
|
|
// code, not just when debuginfo is enabled.
|
|
|
|
// The general pattern followed here is: Change one thing between rev1 and rev2
|
|
// and make sure that the hash has changed, then change nothing between rev2 and
|
|
// rev3 and make sure that the hash has not changed.
|
|
|
|
//@ build-pass (FIXME(62277): could be check-pass?)
|
|
//@ revisions: bfail1 bfail2 bfail3
|
|
//@ compile-flags: -Z query-dep-graph -C debug-assertions -O
|
|
//@ ignore-backends: gcc
|
|
|
|
#![allow(warnings)]
|
|
#![feature(rustc_attrs)]
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
// Indexing expression
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn indexing(slice: &[u8]) -> u8 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
slice[100]
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
slice[100]
|
|
}
|
|
}
|
|
|
|
|
|
// Arithmetic overflow plus
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn arithmetic_overflow_plus(val: i32) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
val + 1
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
val + 1
|
|
}
|
|
}
|
|
|
|
|
|
// Arithmetic overflow minus
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn arithmetic_overflow_minus(val: i32) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
val - 1
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
val - 1
|
|
}
|
|
}
|
|
|
|
|
|
// Arithmetic overflow mult
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn arithmetic_overflow_mult(val: i32) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
val * 2
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
val * 2
|
|
}
|
|
}
|
|
|
|
|
|
// Arithmetic overflow negation
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn arithmetic_overflow_negation(val: i32) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
-val
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
-val
|
|
}
|
|
}
|
|
|
|
|
|
// Division by zero
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn division_by_zero(val: i32) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
2 / val
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
2 / val
|
|
}
|
|
}
|
|
|
|
// Division by zero
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn mod_by_zero(val: i32) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
2 % val
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
2 % val
|
|
}
|
|
}
|
|
|
|
|
|
// shift left
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn shift_left(val: i32, shift: usize) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
val << shift
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
val << shift
|
|
}
|
|
}
|
|
|
|
|
|
// shift right
|
|
#[rustc_clean(cfg="bfail2", except="opt_hir_owner_nodes,optimized_mir")]
|
|
#[rustc_clean(cfg="bfail3")]
|
|
pub fn shift_right(val: i32, shift: usize) -> i32 {
|
|
#[cfg(bfail1)]
|
|
{
|
|
val >> shift
|
|
}
|
|
#[cfg(not(bfail1))]
|
|
{
|
|
val >> shift
|
|
}
|
|
}
|