Closed
Description
After I updating to rust master, the following stopped working:
struct MyStruct;
trait Repro {
fn repro(self, s: MyStruct) -> ~str;
}
// Work arounds:
// a) impl<'a> Repro for |MyStruct|:'a
// b) bind the closure to a local variable first, such that the type can be specified
impl Repro for |MyStruct|:'static -> ~str {
fn repro(self, s: MyStruct) -> ~str {
self(s)
}
}
fn do_stuff<R: Repro>(r: R) -> ~str {
r.repro(MyStruct)
}
pub fn main() {
println!("{}", do_stuff(|s: MyStruct| format!("{:?}", s)));
}
$rustc repro.rs
repro.rs:18:18: 18:26 error: failed to find an implementation of trait Repro for |MyStruct| -> ~str
repro.rs:18 println!("{}", do_stuff(|s: MyStruct| format!("{:?}", s)));
^~~~~~~~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
repro.rs:18:3: 18:62 note: expansion site