Files
rust/tests/incremental/hashes/loop_expressions.rs
T
Zalathar 0ea8958c02 Migrate bfail/build-pass tests to bpass (2/2)
This is the subset of incremental tests that have a FIXME to consider migrating
to check-pass instead.

That migration is beyond the scope of this PR, but might be attempted later.
2026-04-22 12:28:25 +10:00

226 lines
4.8 KiB
Rust

// This test case tests the incremental compilation hash (ICH) implementation
// for `loop` loops.
// 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.
//@ revisions: bpass1 bpass2 bpass3 bpass4 bpass5 bpass6
//@ compile-flags: -Z query-dep-graph -O
//@ [bpass1]compile-flags: -Zincremental-ignore-spans
//@ [bpass2]compile-flags: -Zincremental-ignore-spans
//@ [bpass3]compile-flags: -Zincremental-ignore-spans
//@ ignore-backends: gcc
// FIXME(#62277): could be check-pass?
#![allow(warnings)]
#![feature(rustc_attrs)]
#![crate_type="rlib"]
// Change loop body
#[cfg(any(bpass1,bpass4))]
pub fn change_loop_body() {
let mut _x = 0;
loop {
_x = 1;
break;
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="bpass6")]
pub fn change_loop_body() {
let mut _x = 0;
loop {
_x = 2;
break;
}
}
// Add break
#[cfg(any(bpass1,bpass4))]
pub fn add_break() {
let mut _x = 0;
loop {
_x = 1;
//----
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes, optimized_mir, typeck_root")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes, optimized_mir, typeck_root")]
#[rustc_clean(cfg="bpass6")]
pub fn add_break() {
let mut _x = 0;
loop {
_x = 1;
break;
}
}
// Add loop label
#[cfg(any(bpass1,bpass4))]
pub fn add_loop_label() {
let mut _x = 0;
/*---*/ loop {
_x = 1;
break;
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes")]
#[rustc_clean(cfg="bpass6")]
pub fn add_loop_label() {
let mut _x = 0;
'label: loop {
_x = 1;
break;
}
}
// Add loop label to break
#[cfg(any(bpass1,bpass4))]
pub fn add_loop_label_to_break() {
let mut _x = 0;
'label: loop {
_x = 1;
break ;
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes")]
#[rustc_clean(cfg="bpass6")]
pub fn add_loop_label_to_break() {
let mut _x = 0;
'label: loop {
_x = 1;
break 'label;
}
}
// Change break label
#[cfg(any(bpass1,bpass4))]
pub fn change_break_label() {
let mut _x = 0;
'outer: loop {
'inner: loop {
_x = 1;
break 'inner;
}
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes, optimized_mir, typeck_root")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes, optimized_mir, typeck_root")]
#[rustc_clean(cfg="bpass6")]
pub fn change_break_label() {
let mut _x = 0;
'outer: loop {
'inner: loop {
_x = 1;
break 'outer;
}
}
}
// Add loop label to continue
#[cfg(any(bpass1,bpass4))]
pub fn add_loop_label_to_continue() {
let mut _x = 0;
'label: loop {
_x = 1;
continue ;
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="bpass6")]
pub fn add_loop_label_to_continue() {
let mut _x = 0;
'label: loop {
_x = 1;
continue 'label;
}
}
// Change continue label
#[cfg(any(bpass1,bpass4))]
pub fn change_continue_label() {
let mut _x = 0;
'outer: loop {
'inner: loop {
_x = 1;
continue 'inner;
}
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="bpass6")]
pub fn change_continue_label() {
let mut _x = 0;
'outer: loop {
'inner: loop {
_x = 1;
continue 'outer;
}
}
}
// Change continue to break
#[cfg(any(bpass1,bpass4))]
pub fn change_continue_to_break() {
let mut _x = 0;
loop {
_x = 1;
continue;
}
}
#[cfg(not(any(bpass1,bpass4)))]
#[rustc_clean(cfg="bpass2", except="opt_hir_owner_nodes, typeck_root, optimized_mir")]
#[rustc_clean(cfg="bpass3")]
#[rustc_clean(cfg="bpass5", except="opt_hir_owner_nodes, typeck_root, optimized_mir")]
#[rustc_clean(cfg="bpass6")]
pub fn change_continue_to_break() {
let mut _x = 0;
loop {
_x = 1;
break ;
}
}