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

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

23 lines
498 B
Rust
Raw Normal View History

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