diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-41498.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-41498.rs b/src/test/ui/issues/issue-41498.rs new file mode 100644 index 000000000..ad918ecdd --- /dev/null +++ b/src/test/ui/issues/issue-41498.rs @@ -0,0 +1,17 @@ +// run-pass +// regression test for issue #41498. + +struct S; +impl S { + fn mutate(&mut self) {} +} + +fn call_and_ref<T, F: FnOnce() -> T>(x: &mut Option<T>, f: F) -> &mut T { + *x = Some(f()); + x.as_mut().unwrap() +} + +fn main() { + let mut n = None; + call_and_ref(&mut n, || [S])[0].mutate(); +} |