From 6ed3f2490742a5ccd924b6bf037b8fbf0cd93352 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 1 Jan 2015 16:45:59 -0500 Subject: [PATCH] New coherence tests covering patterns we want to work (and not work). --- src/test/auxiliary/coherence-lib.rs | 25 +++++++++++++++++++ src/test/compile-fail/coherence-all-remote.rs | 19 ++++++++++++++ .../compile-fail/coherence-bigint-param.rs | 21 ++++++++++++++++ .../coherence-iterator-vec-any-elem.rs | 21 ++++++++++++++++ .../coherence-lone-type-parameter.rs | 18 +++++++++++++ .../coherence-overlapping-pairs.rs | 21 ++++++++++++++++ .../coherence-pair-covered-uncovered.rs | 21 ++++++++++++++++ src/test/run-pass/coherence-bigint-int.rs | 20 +++++++++++++++ src/test/run-pass/coherence-bigint-vecint.rs | 20 +++++++++++++++ src/test/run-pass/coherence-blanket.rs | 22 ++++++++++++++++ .../coherence-covered-type-parameter.rs | 20 +++++++++++++++ src/test/run-pass/coherence-iterator-vec.rs | 20 +++++++++++++++ src/test/run-pass/coherence-local-1.rs | 20 +++++++++++++++ src/test/run-pass/coherence-local-2.rs | 20 +++++++++++++++ 14 files changed, 288 insertions(+) create mode 100644 src/test/auxiliary/coherence-lib.rs create mode 100644 src/test/compile-fail/coherence-all-remote.rs create mode 100644 src/test/compile-fail/coherence-bigint-param.rs create mode 100644 src/test/compile-fail/coherence-iterator-vec-any-elem.rs create mode 100644 src/test/compile-fail/coherence-lone-type-parameter.rs create mode 100644 src/test/compile-fail/coherence-overlapping-pairs.rs create mode 100644 src/test/compile-fail/coherence-pair-covered-uncovered.rs create mode 100644 src/test/run-pass/coherence-bigint-int.rs create mode 100644 src/test/run-pass/coherence-bigint-vecint.rs create mode 100644 src/test/run-pass/coherence-blanket.rs create mode 100644 src/test/run-pass/coherence-covered-type-parameter.rs create mode 100644 src/test/run-pass/coherence-iterator-vec.rs create mode 100644 src/test/run-pass/coherence-local-1.rs create mode 100644 src/test/run-pass/coherence-local-2.rs diff --git a/src/test/auxiliary/coherence-lib.rs b/src/test/auxiliary/coherence-lib.rs new file mode 100644 index 000000000000..daa123849e4e --- /dev/null +++ b/src/test/auxiliary/coherence-lib.rs @@ -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 or the MIT license +// , 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 { + fn foo(&self, t: T) { } +} + +pub trait Remote2 { + fn foo(&self, t: T, u: U) { } +} + +pub struct Pair(T,U); diff --git a/src/test/compile-fail/coherence-all-remote.rs b/src/test/compile-fail/coherence-all-remote.rs new file mode 100644 index 000000000000..67d96aa95a6a --- /dev/null +++ b/src/test/compile-fail/coherence-all-remote.rs @@ -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 or the MIT license +// , 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 Remote for int { } +//~^ ERROR cannot provide an extension implementation + +fn main() { } diff --git a/src/test/compile-fail/coherence-bigint-param.rs b/src/test/compile-fail/coherence-bigint-param.rs new file mode 100644 index 000000000000..a04dfd36c98f --- /dev/null +++ b/src/test/compile-fail/coherence-bigint-param.rs @@ -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 or the MIT license +// , 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 for T { } +//~^ ERROR type parameter `T` must also appear + +fn main() { } diff --git a/src/test/compile-fail/coherence-iterator-vec-any-elem.rs b/src/test/compile-fail/coherence-iterator-vec-any-elem.rs new file mode 100644 index 000000000000..2ed7a6db7ae1 --- /dev/null +++ b/src/test/compile-fail/coherence-iterator-vec-any-elem.rs @@ -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 or the MIT license +// , 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); + +impl Remote1 for Foo { } +//~^ ERROR type parameter `U` must also appear + +fn main() { } diff --git a/src/test/compile-fail/coherence-lone-type-parameter.rs b/src/test/compile-fail/coherence-lone-type-parameter.rs new file mode 100644 index 000000000000..0223dacd8eca --- /dev/null +++ b/src/test/compile-fail/coherence-lone-type-parameter.rs @@ -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 or the MIT license +// , 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 Remote for T { } //~ ERROR E0117 + +fn main() { } diff --git a/src/test/compile-fail/coherence-overlapping-pairs.rs b/src/test/compile-fail/coherence-overlapping-pairs.rs new file mode 100644 index 000000000000..d42bd529b666 --- /dev/null +++ b/src/test/compile-fail/coherence-overlapping-pairs.rs @@ -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 or the MIT license +// , 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 Remote for lib::Pair { } +//~^ ERROR type parameter `T` must also appear + +fn main() { } diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered.rs b/src/test/compile-fail/coherence-pair-covered-uncovered.rs new file mode 100644 index 000000000000..09895ec11db1 --- /dev/null +++ b/src/test/compile-fail/coherence-pair-covered-uncovered.rs @@ -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 or the MIT license +// , 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); + +impl Remote for Pair> { } +//~^ ERROR type parameter `T` must also appear + +fn main() { } diff --git a/src/test/run-pass/coherence-bigint-int.rs b/src/test/run-pass/coherence-bigint-int.rs new file mode 100644 index 000000000000..1e90453980f8 --- /dev/null +++ b/src/test/run-pass/coherence-bigint-int.rs @@ -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 or the MIT license +// , 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 for int { } + +fn main() { } diff --git a/src/test/run-pass/coherence-bigint-vecint.rs b/src/test/run-pass/coherence-bigint-vecint.rs new file mode 100644 index 000000000000..b100455eb339 --- /dev/null +++ b/src/test/run-pass/coherence-bigint-vecint.rs @@ -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 or the MIT license +// , 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 for Vec { } + +fn main() { } diff --git a/src/test/run-pass/coherence-blanket.rs b/src/test/run-pass/coherence-blanket.rs new file mode 100644 index 000000000000..e02117d1ca26 --- /dev/null +++ b/src/test/run-pass/coherence-blanket.rs @@ -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 or the MIT license +// , 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 Local for T { } + +fn main() { } diff --git a/src/test/run-pass/coherence-covered-type-parameter.rs b/src/test/run-pass/coherence-covered-type-parameter.rs new file mode 100644 index 000000000000..27f1f2dafb00 --- /dev/null +++ b/src/test/run-pass/coherence-covered-type-parameter.rs @@ -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 or the MIT license +// , 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); + +impl Remote for Foo { } + +fn main() { } diff --git a/src/test/run-pass/coherence-iterator-vec.rs b/src/test/run-pass/coherence-iterator-vec.rs new file mode 100644 index 000000000000..7077503f73ff --- /dev/null +++ b/src/test/run-pass/coherence-iterator-vec.rs @@ -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 or the MIT license +// , 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); + +impl Remote1 for Foo { } + +fn main() { } diff --git a/src/test/run-pass/coherence-local-1.rs b/src/test/run-pass/coherence-local-1.rs new file mode 100644 index 000000000000..a9bc3dc0e2f2 --- /dev/null +++ b/src/test/run-pass/coherence-local-1.rs @@ -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 or the MIT license +// , 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 { } + +fn main() { } diff --git a/src/test/run-pass/coherence-local-2.rs b/src/test/run-pass/coherence-local-2.rs new file mode 100644 index 000000000000..07a830cb1ac2 --- /dev/null +++ b/src/test/run-pass/coherence-local-2.rs @@ -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 or the MIT license +// , 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); + +impl Remote for Vec> { } + +fn main() { }