]> git.lizzy.rs Git - rust.git/blob - src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs
Move some E0XXX to `ui`
[rust.git] / src / test / ui / error-codes / E0621-does-not-trigger-for-closures.rs
1 // Copyright 2016 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 // Test that we give the generic E0495 when one of the free regions is
12 // bound in a closure (rather than suggesting a change to the signature
13 // of the closure, which is not specified in `foo` but rather in `invoke`).
14
15 // FIXME - This might be better as a UI test, but the finer details
16 // of the error seem to vary on different machines.
17 fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32
18 where F: FnOnce(&'a i32, &i32) -> &'a i32
19 {
20     let y = 22;
21     f(x, &y)
22 }
23
24 fn foo<'a>(x: &'a i32) {
25     invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
26 }
27
28 fn main() {}