forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test for equivalency to include region binders in object types…
…, add new tests relating to HRTB, consolidate the `unboxed_closures` and `overloaded_calls` feature gates.
- Loading branch information
1 parent
7a846b8
commit 56ba260
Showing
48 changed files
with
531 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// 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. | ||
|
||
// Test HRTB supertraits with several levels of expansion required. | ||
|
||
trait Foo<'tcx> | ||
{ | ||
fn foo(&'tcx self) -> &'tcx int; | ||
} | ||
|
||
trait Bar<'ccx> | ||
: for<'tcx> Foo<'tcx> | ||
{ | ||
fn bar(&'ccx self) -> &'ccx int; | ||
} | ||
|
||
trait Baz | ||
: for<'ccx> Bar<'ccx> | ||
{ | ||
fn dummy(&self); | ||
} | ||
|
||
trait Qux | ||
: Bar<'static> | ||
{ | ||
fn dummy(&self); | ||
} | ||
|
||
fn want_foo_for_any_tcx<F>(f: &F) | ||
where F : for<'tcx> Foo<'tcx> | ||
{ | ||
} | ||
|
||
fn want_bar_for_any_ccx<B>(b: &B) | ||
where B : for<'ccx> Bar<'ccx> | ||
{ | ||
} | ||
|
||
fn want_baz<B>(b: &B) | ||
where B : Baz | ||
{ | ||
want_foo_for_any_tcx(b); | ||
want_bar_for_any_ccx(b); | ||
} | ||
|
||
fn want_qux<B>(b: &B) | ||
where B : Qux | ||
{ | ||
want_foo_for_any_tcx(b); | ||
want_bar_for_any_ccx(b); //~ ERROR not implemented | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// 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. | ||
|
||
// Test a trait (`Bar`) with a higher-ranked supertrait. | ||
|
||
trait Foo<'tcx> | ||
{ | ||
fn foo(&'tcx self) -> &'tcx int; | ||
} | ||
|
||
trait Bar<'ccx> | ||
: for<'tcx> Foo<'tcx> | ||
{ | ||
fn bar(&'ccx self) -> &'ccx int; | ||
} | ||
|
||
fn want_foo_for_some_tcx<'x,F>(f: &'x F) | ||
where F : Foo<'x> | ||
{ | ||
want_foo_for_some_tcx(f); | ||
want_foo_for_any_tcx(f); //~ ERROR not implemented | ||
} | ||
|
||
fn want_foo_for_any_tcx<F>(f: &F) | ||
where F : for<'tcx> Foo<'tcx> | ||
{ | ||
want_foo_for_some_tcx(f); | ||
want_foo_for_any_tcx(f); | ||
} | ||
|
||
fn want_bar_for_some_ccx<'x,B>(b: &B) | ||
where B : Bar<'x> | ||
{ | ||
want_foo_for_some_tcx(b); | ||
want_foo_for_any_tcx(b); | ||
|
||
want_bar_for_some_ccx(b); | ||
want_bar_for_any_ccx(b); //~ ERROR not implemented | ||
} | ||
|
||
fn want_bar_for_any_ccx<B>(b: &B) | ||
where B : for<'ccx> Bar<'ccx> | ||
{ | ||
want_foo_for_some_tcx(b); | ||
want_foo_for_any_tcx(b); | ||
|
||
want_bar_for_some_ccx(b); | ||
want_bar_for_any_ccx(b); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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. | ||
|
||
// Test that the `'a` in the where clause correctly links the region | ||
// of the output to the region of the input. | ||
|
||
trait FnLike<A,R> { | ||
fn call(&self, arg: A) -> R; | ||
} | ||
|
||
fn call_repeatedly<F>(f: F) | ||
where F : for<'a> FnLike<&'a int, &'a int> | ||
{ | ||
// Result is stored: cannot re-assign `x` | ||
let mut x = 3; | ||
let y = f.call(&x); | ||
x = 5; //~ ERROR cannot assign | ||
|
||
// Result is not stored: can re-assign `x` | ||
let mut x = 3; | ||
f.call(&x); | ||
f.call(&x); | ||
f.call(&x); | ||
x = 5; | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/compile-fail/stage0-clone-contravariant-lifetime.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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. | ||
|
||
// A zero-dependency test that covers some basic traits, default | ||
// methods, etc. When mucking about with basic type system stuff I | ||
// often encounter problems in the iterator trait, so it's useful to | ||
// have hanging around. -nmatsakis | ||
|
||
// error-pattern: requires `start` lang_item | ||
|
||
#![no_std] | ||
#![feature(lang_items)] | ||
|
||
#[lang = "sized"] | ||
pub trait Sized for Sized? { | ||
// Empty. | ||
} | ||
|
||
pub mod std { | ||
pub mod clone { | ||
pub trait Clone { | ||
fn clone(&self) -> Self; | ||
} | ||
} | ||
} | ||
|
||
pub struct ContravariantLifetime<'a>; | ||
|
||
impl <'a> ::std::clone::Clone for ContravariantLifetime<'a> { | ||
#[inline] | ||
fn clone(&self) -> ContravariantLifetime<'a> { | ||
match *self { ContravariantLifetime => ContravariantLifetime, } | ||
} | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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. | ||
|
||
|
||
// A zero-dependency test that covers some basic traits, default | ||
// methods, etc. When mucking about with basic type system stuff I | ||
// often encounter problems in the iterator trait, so it's useful to | ||
// have hanging around. -nmatsakis | ||
|
||
// error-pattern: requires `start` lang_item | ||
|
||
#![no_std] | ||
#![feature(lang_items)] | ||
|
||
#[lang = "sized"] | ||
pub trait Sized for Sized? { | ||
// Empty. | ||
} | ||
|
||
#[unstable = "Definition may change slightly after trait reform"] | ||
pub trait PartialEq for Sized? { | ||
/// This method tests for `self` and `other` values to be equal, and is used by `==`. | ||
fn eq(&self, other: &Self) -> bool; | ||
} | ||
|
||
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot | ||
#[unstable = "Trait is unstable."] | ||
impl<'a, Sized? T: PartialEq> PartialEq for &'a T { | ||
#[inline] | ||
fn eq(&self, other: & &'a T) -> bool { PartialEq::eq(*self, *other) } | ||
} | ||
|
||
fn main() { } |
Oops, something went wrong.
56ba260
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=pcwalton p=1