Skip to content

Commit b8ee6fa

Browse files
committed
Add some tests
This copies and adjusts the existing coherence tests to ensure that they continue to work using the new implementation.
1 parent 3512a72 commit b8ee6fa

File tree

128 files changed

+3144
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+3144
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
#![crate_type = "rlib"]
12+
#![feature(fundamental)]
13+
14+
pub trait MyCopy { }
15+
impl MyCopy for i32 { }
16+
17+
pub struct MyStruct<T>(T);
18+
19+
#[fundamental]
20+
pub struct MyFundamentalStruct<T>(T);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2012 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+
#![crate_type="lib"]
12+
13+
pub trait Remote {
14+
fn foo(&self) { }
15+
}
16+
17+
pub trait Remote1<T> {
18+
fn foo(&self, t: T) { }
19+
}
20+
21+
pub trait Remote2<T, U> {
22+
fn foo(&self, t: T, u: U) { }
23+
}
24+
25+
pub struct Pair<T,U>(T,U);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
pub trait Backend{}
3+
pub trait SupportsDefaultKeyword {}
4+
5+
impl SupportsDefaultKeyword for Postgres {}
6+
7+
pub struct Postgres;
8+
9+
impl Backend for Postgres {}
10+
11+
pub struct AstPass<DB>(::std::marker::PhantomData<DB>);
12+
13+
pub trait QueryFragment<DB: Backend> {}
14+
15+
16+
#[derive(Debug, Clone, Copy)]
17+
pub struct BatchInsert<'a, T: 'a, Tab> {
18+
_marker: ::std::marker::PhantomData<(&'a T, Tab)>,
19+
}
20+
21+
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
22+
where DB: SupportsDefaultKeyword + Backend,
23+
{}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.
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+
#![feature(re_rebalance_coherence)]
12+
13+
// run-pass
14+
// aux-build:coherence_lib.rs
15+
16+
// pretty-expanded FIXME #23616
17+
18+
extern crate coherence_lib as lib;
19+
use lib::Remote1;
20+
21+
pub struct BigInt;
22+
23+
impl Remote1<BigInt> for isize { }
24+
25+
fn main() { }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.
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+
#![feature(re_rebalance_coherence)]
12+
13+
// run-pass
14+
// aux-build:coherence_lib.rs
15+
16+
// pretty-expanded FIXME #23616
17+
18+
extern crate coherence_lib as lib;
19+
use lib::Remote1;
20+
21+
pub struct BigInt;
22+
23+
impl Remote1<BigInt> for Vec<isize> { }
24+
25+
fn main() { }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.
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+
// run-pass
12+
#![allow(unused_imports)]
13+
#![feature(re_rebalance_coherence)]
14+
// aux-build:coherence_lib.rs
15+
16+
// pretty-expanded FIXME #23616
17+
18+
extern crate coherence_lib as lib;
19+
use lib::Remote1;
20+
21+
pub trait Local {
22+
fn foo(&self) { }
23+
}
24+
25+
impl<T> Local for T { }
26+
27+
fn main() { }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.
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+
// run-pass
12+
#![allow(dead_code)]
13+
#![feature(re_rebalance_coherence)]
14+
// aux-build:coherence_lib.rs
15+
16+
// pretty-expanded FIXME #23616
17+
18+
extern crate coherence_lib as lib;
19+
use lib::Remote;
20+
21+
struct Foo<T>(T);
22+
23+
impl<T> Remote for Foo<T> { }
24+
25+
fn main() { }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2012 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+
// run-pass
12+
#![allow(dead_code)]
13+
#![allow(non_camel_case_types)]
14+
#![feature(re_rebalance_coherence)]
15+
16+
pub fn main() {
17+
#[derive(Copy, Clone)]
18+
enum x { foo }
19+
impl ::std::cmp::PartialEq for x {
20+
fn eq(&self, other: &x) -> bool {
21+
(*self) as isize == (*other) as isize
22+
}
23+
fn ne(&self, other: &x) -> bool { !(*self).eq(other) }
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.
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+
// run-pass
12+
#![allow(dead_code)]
13+
#![feature(re_rebalance_coherence)]
14+
// aux-build:coherence_lib.rs
15+
16+
// pretty-expanded FIXME #23616
17+
18+
extern crate coherence_lib as lib;
19+
use lib::Remote1;
20+
21+
struct Foo<T>(T);
22+
23+
impl<T,U> Remote1<U> for Foo<T> { }
24+
25+
fn main() { }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.
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+
// run-pass
12+
#![allow(dead_code)]
13+
#![feature(re_rebalance_coherence)]
14+
// aux-build:coherence_lib.rs
15+
16+
// pretty-expanded FIXME #23616
17+
18+
extern crate coherence_lib as lib;
19+
use lib::Remote1;
20+
21+
struct Foo<T>(T);
22+
23+
impl<T> Remote1<T> for Foo<T> { }
24+
25+
fn main() { }
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.
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+
// run-pass
12+
#![allow(unused_imports)]
13+
#![feature(re_rebalance_coherence)]
14+
// pretty-expanded FIXME #23616
15+
16+
use std::fmt::Debug;
17+
use std::default::Default;
18+
19+
// Test that an impl for homogeneous pairs does not conflict with a
20+
// heterogeneous pair.
21+
22+
trait MyTrait {
23+
fn get(&self) -> usize;
24+
}
25+
26+
impl<T> MyTrait for (T,T) {
27+
fn get(&self) -> usize { 0 }
28+
}
29+
30+
impl MyTrait for (usize,isize) {
31+
fn get(&self) -> usize { 0 }
32+
}
33+
34+
fn main() {
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
// run-pass
12+
#![allow(dead_code)]
13+
// pretty-expanded FIXME #23616
14+
15+
#![feature(optin_builtin_traits)]
16+
#![feature(re_rebalance_coherence)]
17+
18+
use std::marker::Send;
19+
20+
struct TestType;
21+
22+
impl !Send for TestType {}
23+
24+
fn main() {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
#![feature(re_rebalance_coherence)]
12+
13+
// run-pass
14+
// check that trait matching can handle impls whose types are only
15+
// constrained by a projection.
16+
17+
trait IsU32 {}
18+
impl IsU32 for u32 {}
19+
20+
trait Mirror { type Image: ?Sized; }
21+
impl<T: ?Sized> Mirror for T { type Image = T; }
22+
23+
trait Bar {}
24+
impl<U: Mirror, V: Mirror<Image=L>, L: Mirror<Image=U>> Bar for V
25+
where U::Image: IsU32 {}
26+
27+
trait Foo { fn name() -> &'static str; }
28+
impl Foo for u64 { fn name() -> &'static str { "u64" } }
29+
impl<T: Bar> Foo for T { fn name() -> &'static str { "Bar" }}
30+
31+
fn main() {
32+
assert_eq!(<u64 as Foo>::name(), "u64");
33+
assert_eq!(<u32 as Foo>::name(), "Bar");
34+
}

0 commit comments

Comments
 (0)