]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
cc61c64b XL |
2 | // regression test for issue #41498. |
3 | ||
4 | struct S; | |
5 | impl S { | |
6 | fn mutate(&mut self) {} | |
7 | } | |
8 | ||
9 | fn call_and_ref<T, F: FnOnce() -> T>(x: &mut Option<T>, f: F) -> &mut T { | |
10 | *x = Some(f()); | |
11 | x.as_mut().unwrap() | |
12 | } | |
13 | ||
7453a54e | 14 | fn main() { |
cc61c64b XL |
15 | let mut n = None; |
16 | call_and_ref(&mut n, || [S])[0].mutate(); | |
223e47cc | 17 | } |