]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/object-lifetime-default-from-ref-struct.rs
24da9603679065f404866242f82aa9210200de87
[rust.git] / src / test / run-pass / object-lifetime-default-from-ref-struct.rs
1 // Copyright 2015 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 the lifetime of the enclosing `&` is used for the object
12 // lifetime bound.
13
14 #![allow(dead_code)]
15
16 trait Test {
17     fn foo(&self) { }
18 }
19
20 struct Ref<'a,T:'a+?Sized> {
21     r: &'a T
22 }
23
24 struct SomeStruct<'a> {
25     t: Ref<'a,Test>,
26     u: Ref<'a,Test+'a>,
27 }
28
29 fn a<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) {
30     ss.t = t;
31 }
32
33 fn b<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) {
34     ss.u = t;
35 }
36
37 fn c<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) {
38     ss.t = t;
39 }
40
41 fn d<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) {
42     ss.u = t;
43 }
44
45
46 fn main() {
47 }