2014-06-01 20:41:46 -05:00
|
|
|
// 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 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-10-28 06:24:25 -05:00
|
|
|
// Checks that the Fn trait hierarchy rules do not permit
|
|
|
|
// Fn to be used where FnMut is implemented.
|
|
|
|
|
2014-11-15 15:04:04 -06:00
|
|
|
#![feature(unboxed_closures)]
|
2014-10-28 06:24:25 -05:00
|
|
|
#![feature(overloaded_calls)]
|
2014-06-01 20:41:46 -05:00
|
|
|
|
2014-10-28 06:24:25 -05:00
|
|
|
use std::ops::{Fn,FnMut,FnOnce};
|
2014-06-01 20:41:46 -05:00
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
2015-01-12 09:27:25 -06:00
|
|
|
impl FnMut<(isize,)> for S {
|
2015-01-08 04:54:35 -06:00
|
|
|
extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize {
|
2014-06-01 20:41:46 -05:00
|
|
|
x * x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-11 09:08:33 -05:00
|
|
|
impl FnOnce<(isize,)> for S {
|
|
|
|
type Output = isize;
|
|
|
|
|
|
|
|
extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) }
|
|
|
|
}
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn call_it<F:Fn(isize)->isize>(f: &F, x: isize) -> isize {
|
2014-10-28 06:24:25 -05:00
|
|
|
f.call((x,))
|
2014-06-01 20:41:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-01-12 09:27:25 -06:00
|
|
|
let x = call_it(&S, 22);
|
|
|
|
//~^ ERROR not implemented
|
2014-06-01 20:41:46 -05:00
|
|
|
}
|