blob: 5f447595662edd74aa749b1f5c44c73eebb139b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// check-pass
// compile-flags: -Z validate-mir
struct Foo<'a>(&'a mut u32);
impl<'a> Drop for Foo<'a> {
fn drop(&mut self) {
*self.0 = 0;
}
}
fn and() {
let mut foo = 0;
// This used to compile also before the fix
if true && *Foo(&mut foo).0 == 0 && ({ foo = 0; true}) {}
// This used to fail before the fix
if *Foo(&mut foo).0 == 0 && ({ foo = 0; true}) {}
println!("{foo}");
}
fn or() {
let mut foo = 0;
// This used to compile also before the fix
if false || *Foo(&mut foo).0 == 1 || ({ foo = 0; true}) {}
// This used to fail before the fix
if *Foo(&mut foo).0 == 1 || ({ foo = 0; true}) {}
println!("{foo}");
}
fn main() {
and();
or();
}
|