]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/regions-lifetime-bounds-on-fns.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / regions-lifetime-bounds-on-fns.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
11fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) {
12 // Note: this is legal because of the `'b:'a` declaration.
13 *x = *y;
14}
15
16fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
17 // Illegal now because there is no `'b:'a` declaration.
54a0048b 18 *x = *y; //~ ERROR E0312
1a4d82fc
JJ
19}
20
21fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
22 // Here we try to call `foo` but do not know that `'a` and `'b` are
23 // related as required.
54a0048b 24 a(x, y); //~ ERROR E0495
1a4d82fc
JJ
25}
26
27fn d() {
28 // 'a and 'b are early bound in the function `a` because they appear
29 // inconstraints:
30 let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types
31}
32
33fn e() {
34 // 'a and 'b are late bound in the function `b` because there are
35 // no constraints:
36 let _: fn(&mut &isize, &mut &isize) = b;
37}
38
39fn main() { }