]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs
New upstream version 1.15.0+dfsg1
[rustc.git] / src / test / compile-fail / unboxed-closures-fnmut-as-fn.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// Checks that the Fn trait hierarchy rules do not permit
12// Fn to be used where FnMut is implemented.
13
476ff2be 14#![feature(fn_traits, unboxed_closures)]
1a4d82fc
JJ
15#![feature(overloaded_calls)]
16
17use std::ops::{Fn,FnMut,FnOnce};
18
19struct S;
20
85aaf69f 21impl FnMut<(isize,)> for S {
1a4d82fc
JJ
22 extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize {
23 x * x
24 }
25}
26
c34b1796
AL
27impl FnOnce<(isize,)> for S {
28 type Output = isize;
29
30 extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) }
31}
32
1a4d82fc
JJ
33fn call_it<F:Fn(isize)->isize>(f: &F, x: isize) -> isize {
34 f.call((x,))
35}
36
37fn main() {
85aaf69f 38 let x = call_it(&S, 22);
54a0048b 39 //~^ ERROR E0277
1a4d82fc 40}