]> git.lizzy.rs Git - rust.git/blob - src/test/ui/drop/issue-103107.rs
Auto merge of #103600 - compiler-errors:early-binder-nits, r=spastorino
[rust.git] / src / test / ui / drop / issue-103107.rs
1 // check-pass
2 // compile-flags: -Z validate-mir
3
4 struct Foo<'a>(&'a mut u32);
5
6 impl<'a> Drop for Foo<'a> {
7     fn drop(&mut self) {
8         *self.0 = 0;
9     }
10 }
11
12 fn and() {
13     let mut foo = 0;
14     // This used to compile also before the fix
15     if true && *Foo(&mut foo).0 == 0 && ({ foo = 0; true}) {}
16
17     // This used to fail before the fix
18     if *Foo(&mut foo).0 == 0 && ({ foo = 0; true}) {}
19
20     println!("{foo}");
21 }
22
23 fn or() {
24     let mut foo = 0;
25     // This used to compile also before the fix
26     if false || *Foo(&mut foo).0 == 1 || ({ foo = 0; true}) {}
27
28     // This used to fail before the fix
29     if *Foo(&mut foo).0 == 1 || ({ foo = 0; true}) {}
30
31     println!("{foo}");
32 }
33
34 fn main() {
35     and();
36     or();
37 }