|
| 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 | +fn a<'a, 'b, 'c>(x: &mut &'a int, y: &mut &'b int, z: &mut &'c int) where 'b: 'a + 'c { |
| 12 | + // Note: this is legal because of the `'b:'a` declaration. |
| 13 | + *x = *y; |
| 14 | + *z = *y; |
| 15 | +} |
| 16 | + |
| 17 | +fn b<'a, 'b, 'c>(x: &mut &'a int, y: &mut &'b int, z: &mut &'c int) { |
| 18 | + // Illegal now because there is no `'b:'a` declaration. |
| 19 | + *x = *y; //~ ERROR mismatched types |
| 20 | + *z = *y; //~ ERROR mismatched types |
| 21 | +} |
| 22 | + |
| 23 | +fn c<'a,'b, 'c>(x: &mut &'a int, y: &mut &'b int, z: &mut &'c int) { |
| 24 | + // Here we try to call `foo` but do not know that `'a` and `'b` are |
| 25 | + // related as required. |
| 26 | + a(x, y, z); //~ ERROR cannot infer |
| 27 | +} |
| 28 | + |
| 29 | +fn d() { |
| 30 | + // 'a and 'b are early bound in the function `a` because they appear |
| 31 | + // inconstraints: |
| 32 | + let _: fn(&mut &int, &mut &int, &mut &int) = a; //~ ERROR mismatched types |
| 33 | +} |
| 34 | + |
| 35 | +fn e() { |
| 36 | + // 'a and 'b are late bound in the function `b` because there are |
| 37 | + // no constraints: |
| 38 | + let _: fn(&mut &int, &mut &int, &mut &int) = b; |
| 39 | +} |
| 40 | + |
| 41 | +fn main() { } |
0 commit comments