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.
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.
11 // Check that child trait who only has items via its *parent* trait
12 // does cause dropck to inject extra region constraints.
14 #![allow(non_camel_case_types)]
16 trait Parent { fn foo(&self); }
17 trait Child: Parent { }
19 impl Parent for i32 { fn foo(&self) { } }
20 impl<'a> Parent for &'a D_Child<i32> {
22 println!("accessing child value: {}", self.0);
26 impl Child for i32 { }
27 impl<'a> Child for &'a D_Child<i32> { }
29 struct D_Child<T:Child>(T);
30 impl <T:Child> Drop for D_Child<T> { fn drop(&mut self) { self.0.foo() } }
33 // `_d` and `d1` are assigned the *same* lifetime by region inference ...
37 // ... we store a reference to `d1` within `_d` ...
39 //~^ ERROR `d1` does not live long enough
41 // ... dropck *should* complain, because Drop of _d could (and
42 // does) access the already dropped `d1` via the `foo` method.