about summary refs log tree commit diff
path: root/src/librustc_driver
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-12-01 10:11:59 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-12-19 03:29:29 -0500
commit3efc9d2c55af6e58dd96c5814260bacc2b582ef3 (patch)
tree0c9d4717d2ef6cb41fc29d666da5f81c01ddf7e3 /src/librustc_driver
parent514dfdbf12b71758c7abc3219ae1a3936e4d59d9 (diff)
downloadrust-3efc9d2c55af6e58dd96c5814260bacc2b582ef3.tar.gz
rust-3efc9d2c55af6e58dd96c5814260bacc2b582ef3.zip
Fix bug in higher-ranked code that would sometimes leak skolemized regions and/or cause incorrect results.
Diffstat (limited to 'src/librustc_driver')
-rw-r--r--src/librustc_driver/test.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs
index 943650ce8a6..14d36432afa 100644
--- a/src/librustc_driver/test.rs
+++ b/src/librustc_driver/test.rs
@@ -503,6 +503,26 @@ fn sub_free_bound_false_infer() {
 }
 
 #[test]
+fn lub_free_bound_infer() {
+    //! Test result of:
+    //!
+    //!     LUB(fn(_#1), for<'b> fn(&'b int))
+    //!
+    //! This should yield `fn(&'_ int)`. We check
+    //! that it yields `fn(&'x int)` for some free `'x`,
+    //! anyhow.
+
+    test_env(EMPTY_SOURCE_STR, errors(&[]), |env| {
+        let t_infer1 = env.infcx.next_ty_var();
+        let t_rptr_bound1 = env.t_rptr_late_bound(1);
+        let t_rptr_free1 = env.t_rptr_free(0, 1);
+        env.check_lub(env.t_fn(&[t_infer1], ty::mk_int()),
+                      env.t_fn(&[t_rptr_bound1], ty::mk_int()),
+                      env.t_fn(&[t_rptr_free1], ty::mk_int()));
+    });
+}
+
+#[test]
 fn lub_bound_bound() {
     test_env(EMPTY_SOURCE_STR, errors(&[]), |env| {
         let t_rptr_bound1 = env.t_rptr_late_bound(1);
@@ -606,6 +626,28 @@ fn glb_bound_free() {
 }
 
 #[test]
+fn glb_bound_free_infer() {
+    test_env(EMPTY_SOURCE_STR, errors(&[]), |env| {
+        let t_rptr_bound1 = env.t_rptr_late_bound(1);
+        let t_infer1 = env.infcx.next_ty_var();
+
+        // compute GLB(fn(_) -> int, for<'b> fn(&'b int) -> int),
+        // which should yield for<'b> fn(&'b int) -> int
+        env.check_glb(env.t_fn(&[t_rptr_bound1], ty::mk_int()),
+                      env.t_fn(&[t_infer1], ty::mk_int()),
+                      env.t_fn(&[t_rptr_bound1], ty::mk_int()));
+
+        // as a side-effect, computing GLB should unify `_` with
+        // `&'_ int`
+        let t_resolve1 = env.infcx.shallow_resolve(t_infer1);
+        match t_resolve1.sty {
+            ty::ty_rptr(..) => { }
+            _ => { panic!("t_resolve1={}", t_resolve1.repr(env.infcx.tcx)); }
+        }
+    })
+}
+
+#[test]
 fn glb_bound_static() {
     test_env(EMPTY_SOURCE_STR, errors(&[]), |env| {
         let t_rptr_bound1 = env.t_rptr_late_bound(1);