rust/tests/ui/regions/issue-6157.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
529 B
Rust
Raw Normal View History

// run-pass
// pretty-expanded FIXME #23616
pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; }
2014-01-29 22:39:09 +00:00
impl<F> OpInt for F where F: FnMut(isize, isize) -> isize {
fn call(&mut self, a:isize, b:isize) -> isize {
2014-01-29 22:39:09 +00:00
(*self)(a, b)
}
}
2019-05-28 18:47:21 +00:00
fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) }
2014-01-29 22:39:09 +00:00
fn muli(x:isize, y:isize) -> isize { x * y }
2014-01-29 22:39:09 +00:00
pub fn main() {
let mut f = |x, y| muli(x, y);
2014-01-29 22:39:09 +00:00
{
let g = &mut f;
2019-05-28 18:47:21 +00:00
let h = g as &mut dyn OpInt;
2014-01-29 22:39:09 +00:00
squarei(3, h);
}
}