]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/object-lifetime-default-mybox.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / object-lifetime-default-mybox.rs
CommitLineData
85aaf69f
SL
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 a "pass-through" object-lifetime-default that produces errors.
12
13#![allow(dead_code)]
14
15trait SomeTrait {
16 fn dummy(&self) { }
17}
18
19struct MyBox<T:?Sized> {
20 r: Box<T>
21}
22
23fn deref<T>(ss: &T) -> T {
24 // produces the type of a deref without worrying about whether a
25 // move out would actually be legal
26 loop { }
27}
28
29fn load0(ss: &MyBox<SomeTrait>) -> MyBox<SomeTrait> {
c1a9b12d 30 deref(ss)
85aaf69f
SL
31}
32
33fn load1<'a,'b>(a: &'a MyBox<SomeTrait>,
34 b: &'b MyBox<SomeTrait>)
35 -> &'b MyBox<SomeTrait>
36{
54a0048b 37 a //~ ERROR E0312
85aaf69f
SL
38}
39
62682a34 40fn load2<'a>(ss: &MyBox<SomeTrait+'a>) -> MyBox<SomeTrait+'a> {
c1a9b12d 41 load0(ss) //~ ERROR mismatched types
62682a34
SL
42}
43
85aaf69f
SL
44fn main() {
45}