loop_expressions.rs 4.9 KB
Newer Older
1 2 3 4 5 6 7
// 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.

8
// build-pass (FIXME(62277): could be check-pass?)
9
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10
// compile-flags: -Z query-dep-graph -O
11 12 13 14 15 16
// [cfail1]compile-flags: -Zincremental-ignore-spans
// [cfail2]compile-flags: -Zincremental-ignore-spans
// [cfail3]compile-flags: -Zincremental-ignore-spans
// [cfail4]compile-flags: -Zincremental-relative-spans
// [cfail5]compile-flags: -Zincremental-relative-spans
// [cfail6]compile-flags: -Zincremental-relative-spans
17 18 19 20 21 22

#![allow(warnings)]
#![feature(rustc_attrs)]
#![crate_type="rlib"]


23
// Change loop body
24
#[cfg(any(cfail1,cfail4))]
25
pub fn change_loop_body() {
26 27 28 29 30 31 32
    let mut _x = 0;
    loop {
        _x = 1;
        break;
    }
}

33
#[cfg(not(any(cfail1,cfail4)))]
J
Jakob Degen 已提交
34
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
35
#[rustc_clean(cfg="cfail3")]
J
Jakob Degen 已提交
36
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
37
#[rustc_clean(cfg="cfail6")]
38
pub fn change_loop_body() {
39 40 41 42 43 44 45 46 47
    let mut _x = 0;
    loop {
        _x = 2;
        break;
    }
}



48
// Add break
49
#[cfg(any(cfail1,cfail4))]
50
pub fn add_break() {
51 52 53
    let mut _x = 0;
    loop {
        _x = 1;
54
        //----
55 56 57
    }
}

58
#[cfg(not(any(cfail1,cfail4)))]
59
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
60
#[rustc_clean(cfg="cfail3")]
61 62
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
#[rustc_clean(cfg="cfail6")]
63
pub fn add_break() {
64 65 66 67 68 69 70 71 72
    let mut _x = 0;
    loop {
        _x = 1;
        break;
    }
}



73
// Add loop label
74
#[cfg(any(cfail1,cfail4))]
75
pub fn add_loop_label() {
76
    let mut _x = 0;
77
    /*---*/ loop {
78 79 80 81 82
        _x = 1;
        break;
    }
}

83
#[cfg(not(any(cfail1,cfail4)))]
84
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
85
#[rustc_clean(cfg="cfail3")]
86 87
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
#[rustc_clean(cfg="cfail6")]
88
pub fn add_loop_label() {
89 90 91 92 93 94 95 96 97
    let mut _x = 0;
    'label: loop {
        _x = 1;
        break;
    }
}



98
// Add loop label to break
99
#[cfg(any(cfail1,cfail4))]
100
pub fn add_loop_label_to_break() {
101 102 103
    let mut _x = 0;
    'label: loop {
        _x = 1;
104
        break       ;
105 106 107
    }
}

108
#[cfg(not(any(cfail1,cfail4)))]
109
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
110
#[rustc_clean(cfg="cfail3")]
111 112
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
#[rustc_clean(cfg="cfail6")]
113
pub fn add_loop_label_to_break() {
114 115 116 117 118 119 120 121 122
    let mut _x = 0;
    'label: loop {
        _x = 1;
        break 'label;
    }
}



123
// Change break label
124
#[cfg(any(cfail1,cfail4))]
125
pub fn change_break_label() {
126 127 128 129 130 131 132 133 134
    let mut _x = 0;
    'outer: loop {
        'inner: loop {
            _x = 1;
            break 'inner;
        }
    }
}

135
#[cfg(not(any(cfail1,cfail4)))]
136
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
137
#[rustc_clean(cfg="cfail3")]
138 139
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
#[rustc_clean(cfg="cfail6")]
140
pub fn change_break_label() {
141 142 143 144 145 146 147 148 149 150 151
    let mut _x = 0;
    'outer: loop {
        'inner: loop {
            _x = 1;
            break 'outer;
        }
    }
}



152
// Add loop label to continue
153
#[cfg(any(cfail1,cfail4))]
154
pub fn add_loop_label_to_continue() {
155 156 157
    let mut _x = 0;
    'label: loop {
        _x = 1;
158
        continue       ;
159 160 161
    }
}

162
#[cfg(not(any(cfail1,cfail4)))]
163
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
164
#[rustc_clean(cfg="cfail3")]
165 166
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
167
pub fn add_loop_label_to_continue() {
168 169 170 171 172 173 174 175 176
    let mut _x = 0;
    'label: loop {
        _x = 1;
        continue 'label;
    }
}



177
// Change continue label
178
#[cfg(any(cfail1,cfail4))]
179
pub fn change_continue_label() {
180 181 182 183 184 185 186 187 188
    let mut _x = 0;
    'outer: loop {
        'inner: loop {
            _x = 1;
            continue 'inner;
        }
    }
}

189
#[cfg(not(any(cfail1,cfail4)))]
190
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
191
#[rustc_clean(cfg="cfail3")]
192 193
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
194
pub fn change_continue_label() {
195 196 197 198 199 200 201 202 203 204 205
    let mut _x = 0;
    'outer: loop {
        'inner: loop {
            _x = 1;
            continue 'outer;
        }
    }
}



206
// Change continue to break
207
#[cfg(any(cfail1,cfail4))]
208
pub fn change_continue_to_break() {
209 210 211 212 213 214 215
    let mut _x = 0;
    loop {
        _x = 1;
        continue;
    }
}

216 217
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck, optimized_mir")]
218
#[rustc_clean(cfg="cfail3")]
219 220
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
221
pub fn change_continue_to_break() {
222 223 224
    let mut _x = 0;
    loop {
        _x = 1;
225
        break   ;
226 227
    }
}