about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-07-18 13:54:32 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-07-18 14:14:04 +0200
commit442d5d83e29470ef07d29bd02f7974c7d99fae91 (patch)
tree1943b76a6d66a82945aaf9217bf891a3fd23570e
parentf3b44929856283c43742f86692349c27bb701034 (diff)
downloadrust-442d5d83e29470ef07d29bd02f7974c7d99fae91.tar.gz
rust-442d5d83e29470ef07d29bd02f7974c7d99fae91.zip
Adjust run pass test to stricter existential type rules
-rw-r--r--src/test/run-pass/existential_type.rs25
-rw-r--r--src/test/ui/existential_types/unused_generic_param.rs30
-rw-r--r--src/test/ui/existential_types/unused_generic_param.stderr15
3 files changed, 48 insertions, 22 deletions
diff --git a/src/test/run-pass/existential_type.rs b/src/test/run-pass/existential_type.rs
index d2cecd83036..e63d5c2293a 100644
--- a/src/test/run-pass/existential_type.rs
+++ b/src/test/run-pass/existential_type.rs
@@ -75,10 +75,10 @@ fn my_other_iter<U>(u: U) -> MyOtherIter<U> {
 }
 
 trait Trait {}
-existential type GenericBound<T: Trait>: 'static;
+existential type GenericBound<'a, T: Trait>: 'a;
 
-fn generic_bound<T: Trait>(_: T) -> GenericBound<T> {
-    unimplemented!()
+fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> {
+    t
 }
 
 mod pass_through {
@@ -92,22 +92,3 @@ mod pass_through {
 fn use_passthrough(x: pass_through::Passthrough<u32>) -> pass_through::Passthrough<u32> {
     x
 }
-
-existential type PartiallyDefined<T>: 'static;
-
-// doesn't declare all PartiallyDefined for all possible `T`, but since it's the only
-// function producing the value, noone can ever get a value that is problematic
-fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
-    4u32
-}
-
-existential type PartiallyDefined2<T>: 'static;
-
-fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
-    4u32
-}
-
-// fully defines PartiallyDefine2
-fn partially_defined22<T>(_: T) -> PartiallyDefined2<T> {
-    4u32
-}
diff --git a/src/test/ui/existential_types/unused_generic_param.rs b/src/test/ui/existential_types/unused_generic_param.rs
new file mode 100644
index 00000000000..420ce89cc37
--- /dev/null
+++ b/src/test/ui/existential_types/unused_generic_param.rs
@@ -0,0 +1,30 @@
+// Copyright 2018 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.
+
+#![feature(existential_type)]
+
+fn main() {
+}
+
+existential type PartiallyDefined<T>: 'static; //~ `T` is unused
+
+fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
+    4u32
+}
+
+existential type PartiallyDefined2<T>: 'static; //~ `T` is unused
+
+fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
+    4u32
+}
+
+fn partially_defined22<T>(_: T) -> PartiallyDefined2<T> {
+    4u32
+}
diff --git a/src/test/ui/existential_types/unused_generic_param.stderr b/src/test/ui/existential_types/unused_generic_param.stderr
new file mode 100644
index 00000000000..7ad5eab0b0a
--- /dev/null
+++ b/src/test/ui/existential_types/unused_generic_param.stderr
@@ -0,0 +1,15 @@
+error[E0091]: type parameter `T` is unused
+  --> $DIR/unused_generic_param.rs:16:35
+   |
+LL | existential type PartiallyDefined<T>: 'static; //~ `T` is unused
+   |                                   ^ unused type parameter
+
+error[E0091]: type parameter `T` is unused
+  --> $DIR/unused_generic_param.rs:22:36
+   |
+LL | existential type PartiallyDefined2<T>: 'static; //~ `T` is unused
+   |                                    ^ unused type parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0091`.