New coherence tests covering patterns we want to work (and not work).
This commit is contained in:
parent
5c34781a7d
commit
6ed3f24907
14 changed files with 288 additions and 0 deletions
25
src/test/auxiliary/coherence-lib.rs
Normal file
25
src/test/auxiliary/coherence-lib.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2012 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.
|
||||
|
||||
#![crate_type="lib"]
|
||||
|
||||
pub trait Remote {
|
||||
fn foo(&self) { }
|
||||
}
|
||||
|
||||
pub trait Remote1<T> {
|
||||
fn foo(&self, t: T) { }
|
||||
}
|
||||
|
||||
pub trait Remote2<T, U> {
|
||||
fn foo(&self, t: T, u: U) { }
|
||||
}
|
||||
|
||||
pub struct Pair<T,U>(T,U);
|
||||
19
src/test/compile-fail/coherence-all-remote.rs
Normal file
19
src/test/compile-fail/coherence-all-remote.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote;
|
||||
|
||||
impl<T> Remote for int { }
|
||||
//~^ ERROR cannot provide an extension implementation
|
||||
|
||||
fn main() { }
|
||||
21
src/test/compile-fail/coherence-bigint-param.rs
Normal file
21
src/test/compile-fail/coherence-bigint-param.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub struct BigInt;
|
||||
|
||||
impl<T> Remote1<BigInt> for T { }
|
||||
//~^ ERROR type parameter `T` must also appear
|
||||
|
||||
fn main() { }
|
||||
21
src/test/compile-fail/coherence-iterator-vec-any-elem.rs
Normal file
21
src/test/compile-fail/coherence-iterator-vec-any-elem.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
||||
impl<T,U> Remote1<U> for Foo<T> { }
|
||||
//~^ ERROR type parameter `U` must also appear
|
||||
|
||||
fn main() { }
|
||||
18
src/test/compile-fail/coherence-lone-type-parameter.rs
Normal file
18
src/test/compile-fail/coherence-lone-type-parameter.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote;
|
||||
|
||||
impl<T> Remote for T { } //~ ERROR E0117
|
||||
|
||||
fn main() { }
|
||||
21
src/test/compile-fail/coherence-overlapping-pairs.rs
Normal file
21
src/test/compile-fail/coherence-overlapping-pairs.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl<T> Remote for lib::Pair<T,Foo> { }
|
||||
//~^ ERROR type parameter `T` must also appear
|
||||
|
||||
fn main() { }
|
||||
21
src/test/compile-fail/coherence-pair-covered-uncovered.rs
Normal file
21
src/test/compile-fail/coherence-pair-covered-uncovered.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::{Remote, Pair};
|
||||
|
||||
struct Local<T>(T);
|
||||
|
||||
impl<T,U> Remote for Pair<T,Local<U>> { }
|
||||
//~^ ERROR type parameter `T` must also appear
|
||||
|
||||
fn main() { }
|
||||
20
src/test/run-pass/coherence-bigint-int.rs
Normal file
20
src/test/run-pass/coherence-bigint-int.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub struct BigInt;
|
||||
|
||||
impl Remote1<BigInt> for int { }
|
||||
|
||||
fn main() { }
|
||||
20
src/test/run-pass/coherence-bigint-vecint.rs
Normal file
20
src/test/run-pass/coherence-bigint-vecint.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub struct BigInt;
|
||||
|
||||
impl Remote1<BigInt> for Vec<int> { }
|
||||
|
||||
fn main() { }
|
||||
22
src/test/run-pass/coherence-blanket.rs
Normal file
22
src/test/run-pass/coherence-blanket.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub trait Local {
|
||||
fn foo(&self) { }
|
||||
}
|
||||
|
||||
impl<T> Local for T { }
|
||||
|
||||
fn main() { }
|
||||
20
src/test/run-pass/coherence-covered-type-parameter.rs
Normal file
20
src/test/run-pass/coherence-covered-type-parameter.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
||||
impl<T> Remote for Foo<T> { }
|
||||
|
||||
fn main() { }
|
||||
20
src/test/run-pass/coherence-iterator-vec.rs
Normal file
20
src/test/run-pass/coherence-iterator-vec.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
||||
impl<T> Remote1<T> for Foo<T> { }
|
||||
|
||||
fn main() { }
|
||||
20
src/test/run-pass/coherence-local-1.rs
Normal file
20
src/test/run-pass/coherence-local-1.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Local;
|
||||
|
||||
impl Remote for Vec<Local> { }
|
||||
|
||||
fn main() { }
|
||||
20
src/test/run-pass/coherence-local-2.rs
Normal file
20
src/test/run-pass/coherence-local-2.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Local<T>(T);
|
||||
|
||||
impl<T> Remote for Vec<Local<T>> { }
|
||||
|
||||
fn main() { }
|
||||
Loading…
Add table
Add a link
Reference in a new issue