Closed
Description
This test suggests that &fn
is noncopyable. I do not believe this should be the case.
type ErrPrinter = &fn(&str, &str);
fn example_err(prog: &str, arg: &str) {
io::println(fmt!("%s: %s", prog, arg))
}
fn exit(+print: ErrPrinter, prog: &str, arg: &str) {
print(prog, arg);
}
struct X {
mut err: ErrPrinter
}
impl X {
fn boom() {
exit(self.err, "prog", "arg");
}
}
fn main(){
let val = &X{
err: example_err,
};
val.boom();
}
The test yields:
Running /Users/nmatsakis/versioned/rust-gold/build/x86_64-apple-darwin/stage2/bin/rustc:
/Users/nmatsakis/tmp/foo.rs:17:13: 17:21 error: copying a noncopyable value
/Users/nmatsakis/tmp/foo.rs:17 exit(self.err, "prog", "arg");
^~~~~~~~
/Users/nmatsakis/tmp/foo.rs:17:13: 17:21 note: function arguments must be copyable
/Users/nmatsakis/tmp/foo.rs:17 exit(self.err, "prog", "arg");