]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/regions-infer-not-param.rs
rollup merge of #20518: nagisa/weighted-bool
[rust.git] / src / test / compile-fail / regions-infer-not-param.rs
1 // Copyright 2012 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 struct direct<'a> {
12     f: &'a int
13 }
14
15 struct indirect1 {
16     // Here the lifetime parameter of direct is bound by the fn()
17     g: Box<FnOnce(direct) + 'static>
18 }
19
20 struct indirect2<'a> {
21     // But here it is set to 'a
22     g: Box<FnOnce(direct<'a>) + 'static>
23 }
24
25 fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types
26
27 fn take_indirect1(p: indirect1) -> indirect1 { p }
28
29 fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types
30
31 fn main() {}