]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-46589.rs
Auto merge of #105121 - oli-obk:simpler-cheaper-dump_mir, r=nnethercote
[rust.git] / src / test / ui / nll / issue-46589.rs
1 // This tests passes in Polonius mode, so is skipped in the automated compare-mode.
2 // We will manually check it passes in Polonius tests, as we can't have a test here
3 // which conditionally passes depending on a test revision/compile-flags.
4
5 // ignore-compare-mode-polonius
6
7 struct Foo;
8
9 impl Foo {
10     fn get_self(&mut self) -> Option<&mut Self> {
11         Some(self)
12     }
13
14     fn new_self(&mut self) -> &mut Self {
15         self
16     }
17
18     fn trigger_bug(&mut self) {
19         let other = &mut (&mut *self);
20
21         *other = match (*other).get_self() {
22             Some(s) => s,
23             None => (*other).new_self()
24             //~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499]
25         };
26
27         let c = other;
28     }
29 }
30
31 fn main() {}