From dbd8f2605a23d3999608c83ad9839a463970812f Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Wed, 29 Jan 2014 23:39:09 +0100 Subject: [PATCH] Add test for issue 6157 --- src/test/run-pass/issue-6157.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/run-pass/issue-6157.rs diff --git a/src/test/run-pass/issue-6157.rs b/src/test/run-pass/issue-6157.rs new file mode 100644 index 0000000000000..50e5f97034a1a --- /dev/null +++ b/src/test/run-pass/issue-6157.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait OpInt<'a> { fn call<'a>(&'a self, int, int) -> int; } + +impl<'a> OpInt<'a> for 'a |int, int| -> int { + fn call(&self, a:int, b:int) -> int { + (*self)(a, b) + } +} + +fn squarei<'a>(x: int, op: &'a OpInt) -> int { op.call(x, x) } + +fn muli(x:int, y:int) -> int { x * y } + +pub fn main() { + let f = |x,y| muli(x,y); + { + let g = &f; + let h = g as &OpInt; + squarei(3, h); + } +}