about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-01 01:34:08 +0000
committerbors <bors@rust-lang.org>2015-02-01 01:34:08 +0000
commite8489d3cc7a44dc31030b17ec0faad795d3895df (patch)
tree8e3046a83a110f6761ddf2c8417ab8f7e7ac3dfe /src/test
parentf1398d2736f132dd4af828b3d9134691f924b7e1 (diff)
parent2c2879bbce4177552ce26c6445dcb7027a1245c7 (diff)
downloadrust-e8489d3cc7a44dc31030b17ec0faad795d3895df.tar.gz
rust-e8489d3cc7a44dc31030b17ec0faad795d3895df.zip
Auto merge of #21792 - nikomatsakis:orphan-ordered-first, r=aturon
Update the coherence rules to "covered first" -- the first type parameter to contain either a local type or a type parameter must contain only covered type parameters.

cc #19470.
Fixes #20974.
Fixes #20749.

r? @aturon 
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/coherence-all-remote.rs2
-rw-r--r--src/test/compile-fail/coherence-cow-no-cover.rs23
-rw-r--r--src/test/compile-fail/coherence-orphan.rs2
-rw-r--r--src/test/compile-fail/coherence-pair-covered-uncovered-1.rs24
-rw-r--r--src/test/run-pass/coherence-bigint-int.rs (renamed from src/test/compile-fail/coherence-bigint-int.rs)2
-rw-r--r--src/test/run-pass/coherence-bigint-vecint.rs (renamed from src/test/compile-fail/coherence-bigint-vecint.rs)2
-rw-r--r--src/test/run-pass/coherence-cow-1.rs23
-rw-r--r--src/test/run-pass/coherence-cow-2.rs23
8 files changed, 97 insertions, 4 deletions
diff --git a/src/test/compile-fail/coherence-all-remote.rs b/src/test/compile-fail/coherence-all-remote.rs
index f8ddf83c9c6..1e3b7f6dbd2 100644
--- a/src/test/compile-fail/coherence-all-remote.rs
+++ b/src/test/compile-fail/coherence-all-remote.rs
@@ -14,6 +14,6 @@ extern crate "coherence-lib" as lib;
 use lib::Remote1;
 
 impl<T> Remote1<T> for isize { }
-//~^ ERROR E0117
+//~^ ERROR E0210
 
 fn main() { }
diff --git a/src/test/compile-fail/coherence-cow-no-cover.rs b/src/test/compile-fail/coherence-cow-no-cover.rs
new file mode 100644
index 00000000000..8d14eb96c61
--- /dev/null
+++ b/src/test/compile-fail/coherence-cow-no-cover.rs
@@ -0,0 +1,23 @@
+// 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
+
+// Test that it's not ok for U to appear uncovered
+
+extern crate "coherence-lib" as lib;
+use lib::{Remote,Pair};
+
+pub struct Cover<T>(T);
+
+impl<T,U> Remote for Pair<Cover<T>,U> { }
+//~^ ERROR type parameter `U` is not constrained by any local type
+
+fn main() { }
diff --git a/src/test/compile-fail/coherence-orphan.rs b/src/test/compile-fail/coherence-orphan.rs
index f9f965e1ae3..d7cd68e73c3 100644
--- a/src/test/compile-fail/coherence-orphan.rs
+++ b/src/test/compile-fail/coherence-orphan.rs
@@ -21,7 +21,7 @@ struct TheType;
 
 impl TheTrait<usize> for isize { } //~ ERROR E0117
 
-impl TheTrait<TheType> for isize { } //~ ERROR E0117
+impl TheTrait<TheType> for isize { }
 
 impl TheTrait<isize> for TheType { }
 
diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs
new file mode 100644
index 00000000000..3655bca6f1d
--- /dev/null
+++ b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs
@@ -0,0 +1,24 @@
+// 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 same coverage rules apply even if the local type appears in the
+// list of type parameters, not the self type.
+
+// aux-build:coherence-lib.rs
+
+extern crate "coherence-lib" as lib;
+use lib::{Remote1, Pair};
+
+pub struct Local<T>(T);
+
+impl<T,U> Remote1<Pair<T,Local<U>>> for i32 { }
+//~^ ERROR type parameter `T` is not constrained
+
+fn main() { }
diff --git a/src/test/compile-fail/coherence-bigint-int.rs b/src/test/run-pass/coherence-bigint-int.rs
index 684773098cd..baf2f57206d 100644
--- a/src/test/compile-fail/coherence-bigint-int.rs
+++ b/src/test/run-pass/coherence-bigint-int.rs
@@ -15,6 +15,6 @@ use lib::Remote1;
 
 pub struct BigInt;
 
-impl Remote1<BigInt> for isize { } //~ ERROR E0117
+impl Remote1<BigInt> for isize { }
 
 fn main() { }
diff --git a/src/test/compile-fail/coherence-bigint-vecint.rs b/src/test/run-pass/coherence-bigint-vecint.rs
index 28747674b8b..cdc5bc11716 100644
--- a/src/test/compile-fail/coherence-bigint-vecint.rs
+++ b/src/test/run-pass/coherence-bigint-vecint.rs
@@ -15,6 +15,6 @@ use lib::Remote1;
 
 pub struct BigInt;
 
-impl Remote1<BigInt> for Vec<isize> { } //~ ERROR E0117
+impl Remote1<BigInt> for Vec<isize> { }
 
 fn main() { }
diff --git a/src/test/run-pass/coherence-cow-1.rs b/src/test/run-pass/coherence-cow-1.rs
new file mode 100644
index 00000000000..b380372b401
--- /dev/null
+++ b/src/test/run-pass/coherence-cow-1.rs
@@ -0,0 +1,23 @@
+// 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
+
+// Test that it's ok for T to appear first in the self-type, as long
+// as it's covered somewhere.
+
+extern crate "coherence-lib" as lib;
+use lib::{Remote,Pair};
+
+pub struct Cover<T>(T);
+
+impl<T> Remote for Pair<T,Cover<T>> { }
+
+fn main() { }
diff --git a/src/test/run-pass/coherence-cow-2.rs b/src/test/run-pass/coherence-cow-2.rs
new file mode 100644
index 00000000000..93e507c0d63
--- /dev/null
+++ b/src/test/run-pass/coherence-cow-2.rs
@@ -0,0 +1,23 @@
+// 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
+
+// Test that it's ok for T to appear second in the self-type, as long
+// as it's covered somewhere.
+
+extern crate "coherence-lib" as lib;
+use lib::{Remote,Pair};
+
+pub struct Cover<T>(T);
+
+impl<T> Remote for Pair<Cover<T>,T> { }
+
+fn main() { }