about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2017-08-10 13:52:05 -0700
committerRalf Jung <post@ralfj.de>2017-08-18 11:29:51 +0200
commit90edc03eeaa94bdf21c35a6bbe9320d922b1f8a2 (patch)
tree0f62bb0c3a6081ed4e9a0354d0f96a2b2f72968b
parent5d60c614e644cda97758bba5eaa6feb6b0dc5854 (diff)
downloadrust-90edc03eeaa94bdf21c35a6bbe9320d922b1f8a2.tar.gz
rust-90edc03eeaa94bdf21c35a6bbe9320d922b1f8a2.zip
Add a test demonstrating the limitations of our lfietime resolution
-rw-r--r--tests/run-pass/validation_lifetime_resolution.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/run-pass/validation_lifetime_resolution.rs b/tests/run-pass/validation_lifetime_resolution.rs
new file mode 100644
index 00000000000..4d919f73525
--- /dev/null
+++ b/tests/run-pass/validation_lifetime_resolution.rs
@@ -0,0 +1,30 @@
+trait Id {
+    type Out;
+
+    fn id(self) -> Self::Out;
+}
+
+impl<'a> Id for &'a mut i32 {
+    type Out = &'a mut i32;
+
+    fn id(self) -> Self { self }
+}
+
+impl<'a> Id for &'a mut u32 {
+    type Out = &'a mut u32;
+
+    fn id(self) -> Self { self }
+}
+
+fn foo<T>(mut x: T) where for<'a> &'a mut T: Id
+{
+    let x = &mut x;
+    let _y = x.id();
+    // Inspecting the trace should show that _y has a type involving a local lifetime, when it gets validated.
+    // Unfortunately, there doesn't seem to be a way to actually have a test fail if it does not have the right
+    // type.  Currently, this is NOT working correctly; see <https://github.com/solson/miri/issues/298>.
+}
+
+fn main() {
+    foo(3)
+}