]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.rs
Rollup merge of #106244 - atouchet:readme3, r=workingjubilee
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-fnmut-as-fn.rs
1 // Checks that the Fn trait hierarchy rules do not permit
2 // Fn to be used where FnMut is implemented.
3
4 #![feature(fn_traits, unboxed_closures)]
5
6 use std::ops::{Fn,FnMut,FnOnce};
7
8 struct S;
9
10 impl FnMut<(isize,)> for S {
11     extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize {
12         x * x
13     }
14 }
15
16 impl FnOnce<(isize,)> for S {
17     type Output = isize;
18
19     extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) }
20 }
21
22 fn call_it<F:Fn(isize)->isize>(f: &F, x: isize) -> isize {
23     f.call((x,))
24 }
25
26 fn main() {
27     let x = call_it(&S, 22);
28     //~^ ERROR E0277
29 }