diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
| commit | 1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (patch) | |
| tree | 552fabade603ab0d148a49ae3cf1abd3f399740a /src/test/auxiliary | |
| parent | 3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff) | |
| download | rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.tar.gz rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.zip | |
Implement generalized object and type parameter bounds (Fixes #16462)
Diffstat (limited to 'src/test/auxiliary')
| -rw-r--r-- | src/test/auxiliary/issue-2380.rs | 4 | ||||
| -rw-r--r-- | src/test/auxiliary/issue-7178.rs | 2 | ||||
| -rw-r--r-- | src/test/auxiliary/macro_crate_test.rs | 6 | ||||
| -rw-r--r-- | src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs | 33 | ||||
| -rw-r--r-- | src/test/auxiliary/syntax-extension-with-dll-deps-2.rs | 2 |
5 files changed, 40 insertions, 7 deletions
diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index c617c1b2d03..1cba738c564 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -14,8 +14,8 @@ pub trait i<T> { } -pub fn f<T>() -> Box<i<T>> { +pub fn f<T>() -> Box<i<T>+'static> { impl<T> i<T> for () { } - box() () as Box<i<T>> + box() () as Box<i<T>+'static> } diff --git a/src/test/auxiliary/issue-7178.rs b/src/test/auxiliary/issue-7178.rs index fe3842ef174..18b464bd924 100644 --- a/src/test/auxiliary/issue-7178.rs +++ b/src/test/auxiliary/issue-7178.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct Foo<'a, A>(&'a A); +pub struct Foo<'a, A:'a>(&'a A); impl<'a, A> Foo<'a, A> { pub fn new(a: &'a A) -> Foo<'a, A> { diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index b6283206676..0a9cfb5884f 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -40,7 +40,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box<MacResult> { + -> Box<MacResult+'static> { if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } @@ -49,7 +49,7 @@ fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) // See Issue #15750 fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) - -> Box<MacResult> { + -> Box<MacResult+'static> { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), Vec::from_slice(tts)); @@ -65,7 +65,7 @@ fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>) } } -fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult> { +fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> { use syntax::ext::quote::rt::*; if !tts.is_empty() { diff --git a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs new file mode 100644 index 00000000000..a7429ca534b --- /dev/null +++ b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that method bounds declared on traits/impls in a cross-crate +// scenario work. This is the libary portion of the test. + +pub enum MaybeOwned<'a> { + Owned(int), + Borrowed(&'a int) +} + +struct Inv<'a> { // invariant w/r/t 'a + x: &'a mut &'a int +} + +// I encountered a bug at some point with encoding the IntoMaybeOwned +// trait, so I'll use that as the template for this test. +pub trait IntoMaybeOwned<'a> { + fn into_maybe_owned(self) -> MaybeOwned<'a>; + fn bigger_region<'b:'a>(self, b: Inv<'b>); +} + +impl<'a> IntoMaybeOwned<'a> for Inv<'a> { + fn into_maybe_owned(self) -> MaybeOwned<'a> { fail!() } + fn bigger_region<'b:'a>(self, b: Inv<'b>) { fail!() } +} diff --git a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs index b5d13d15493..7a4339aa9f0 100644 --- a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs +++ b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs @@ -29,7 +29,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box<MacResult> { + -> Box<MacResult+'static> { let answer = other::the_answer(); MacExpr::new(quote_expr!(cx, $answer)) } |
