about summary refs log tree commit diff
diff options
context:
space:
mode:
authortoidiu <apoorv@toidiu.com>2018-07-26 22:58:03 -0400
committertoidiu <apoorv@toidiu.com>2018-07-26 22:58:03 -0400
commit0fd7fee5c639f8cdbec8c50e86316e19e61fbb5f (patch)
tree44409f00e554b7022daee6546903b18eb6ec851f
parent429ae93c09055a1fde14ef4cbf807bdfcbe65584 (diff)
downloadrust-0fd7fee5c639f8cdbec8c50e86316e19e61fbb5f.tar.gz
rust-0fd7fee5c639f8cdbec8c50e86316e19e61fbb5f.zip
fix test and add feature gate test
-rw-r--r--src/test/ui/feature-gate-infer_static_outlives_requirements.rs22
-rw-r--r--src/test/ui/feature-gate-infer_static_outlives_requirements.stderr17
-rw-r--r--src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr8
3 files changed, 43 insertions, 4 deletions
diff --git a/src/test/ui/feature-gate-infer_static_outlives_requirements.rs b/src/test/ui/feature-gate-infer_static_outlives_requirements.rs
new file mode 100644
index 00000000000..7b68449859e
--- /dev/null
+++ b/src/test/ui/feature-gate-infer_static_outlives_requirements.rs
@@ -0,0 +1,22 @@
+// Copyright 2015 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.
+
+// Needs an explicit where clause stating outlives condition. (RFC 2093)
+
+// Type T needs to outlive lifetime 'static.
+struct Foo<U> {
+    bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
+}
+struct Bar<T: 'static> {
+    x: T,
+}
+
+
+fn main() { }
diff --git a/src/test/ui/feature-gate-infer_static_outlives_requirements.stderr b/src/test/ui/feature-gate-infer_static_outlives_requirements.stderr
new file mode 100644
index 00000000000..13022b901a7
--- /dev/null
+++ b/src/test/ui/feature-gate-infer_static_outlives_requirements.stderr
@@ -0,0 +1,17 @@
+error[E0310]: the parameter type `U` may not live long enough
+  --> $DIR/feature-gate-infer_static_outlives_requirements.rs:15:5
+   |
+LL | struct Foo<U> {
+   |            - help: consider adding an explicit lifetime bound `U: 'static`...
+LL |     bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
+   |     ^^^^^^^^^^^
+   |
+note: ...so that the type `U` will meet its required lifetime bounds
+  --> $DIR/feature-gate-infer_static_outlives_requirements.rs:15:5
+   |
+LL |     bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
+   |     ^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0310`.
diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
index 38cc215ea99..775ac215e19 100644
--- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
+++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
@@ -1,15 +1,15 @@
 error[E0310]: the parameter type `U` may not live long enough
-  --> $DIR/dont-infer-static.rs:16:5
+  --> $DIR/dont-infer-static.rs:22:5
    |
 LL | struct Foo<U> {
    |            - help: consider adding an explicit lifetime bound `U: 'static`...
-LL |     bar: Bar<U> //~ ERROR 16:5: 16:16: the parameter type `U` may not live long enough [E0310]
+LL |     bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
    |     ^^^^^^^^^^^
    |
 note: ...so that the type `U` will meet its required lifetime bounds
-  --> $DIR/dont-infer-static.rs:16:5
+  --> $DIR/dont-infer-static.rs:22:5
    |
-LL |     bar: Bar<U> //~ ERROR 16:5: 16:16: the parameter type `U` may not live long enough [E0310]
+LL |     bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
    |     ^^^^^^^^^^^
 
 error: aborting due to previous error