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.
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 method bounds declared on traits/impls in a cross-crate
12 // scenario work. This is the library portion of the test.
14 pub enum MaybeOwned<'a> {
19 pub struct Inv<'a> { // invariant w/r/t 'a
23 // I encountered a bug at some point with encoding the IntoMaybeOwned
24 // trait, so I'll use that as the template for this test.
25 pub trait IntoMaybeOwned<'a> {
26 fn into_maybe_owned(self) -> MaybeOwned<'a>;
28 // Note: without this `into_inv` method, the trait is
29 // contravariant w/r/t `'a`, since if you look strictly at the
30 // interface, it only returns `'a`. This complicates the
31 // downstream test since it wants invariance to force an error.
32 // Hence we add this method.
33 fn into_inv(self) -> Inv<'a>;
35 fn bigger_region<'b:'a>(self, b: Inv<'b>);
38 impl<'a> IntoMaybeOwned<'a> for Inv<'a> {
39 fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() }
40 fn into_inv(self) -> Inv<'a> { panic!() }
41 fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() }