]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/regions-close-over-type-parameter-multiple.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / test / compile-fail / regions-close-over-type-parameter-multiple.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
11#![feature(box_syntax)]
12
13// Various tests where we over type parameters with multiple lifetime
14// bounds.
15
16trait SomeTrait { fn get(&self) -> isize; }
17
18fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'a> {
19 // A outlives 'a AND 'b...
20 box v as Box<SomeTrait+'a> // ...hence this type is safe.
21}
22
23fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'b> {
24 // A outlives 'a AND 'b...
25 box v as Box<SomeTrait+'b> // ...hence this type is safe.
26}
27
28fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'c> {
29 // A outlives 'a AND 'b...but not 'c.
d9579d0f 30 box v as Box<SomeTrait+'a> //~ ERROR lifetime bound not satisfied
1a4d82fc
JJ
31}
32
33fn main() {
34}