]> git.lizzy.rs Git - rust.git/blob - tests/ui/issues/issue-41498.rs
Rollup merge of #107112 - eltociear:patch-19, r=albertlarsan68
[rust.git] / tests / ui / issues / issue-41498.rs
1 // run-pass
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
14 fn main() {
15     let mut n = None;
16     call_and_ref(&mut n, || [S])[0].mutate();
17 }