Closed
Description
Similar to #11612 but seems this seems to only happen in an overloaded call?
#![feature(overloaded_calls)]
use std::ops::Fn;
trait Response {}
trait Request {}
trait Ingot<R, S> {
fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status;
}
type IoResult<T> = Result<T, ()>;
struct SendFile<'a>;
struct HelloWorld;
struct Alloy;
enum Status {
Continue
}
impl Alloy {
fn find<T>(&self) -> Option<T> {
None
}
}
impl<'a, 'b> Fn<(&'b mut Response,), IoResult<()>> for SendFile<'a> {
/// Serve from specified path.
fn call(&self, (_res,): (&'b mut Response,)) -> IoResult<()> {
// Check that path exists (path has already checked for permissions)
// Serve file
Ok(())
}
}
impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld {
fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status {
let mut send_file = alloy.find::<SendFile>().unwrap();
send_file(res);
Continue
}
}
fn main() {}
a.rs:37:19: 37:22 error: value may contain references; add `'static` bound to `Rs`
a.rs:37 send_file(res);
^~~
error: aborting due to previous error
Adding an explicit cast works fine.
Reported originally by zzmp on IRC: