about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-10-26 17:01:36 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-10-28 18:48:49 -0400
commitc81ce8249ccac031e5ab9848742ea9c226cb6e5d (patch)
tree3dcabee12c7d0bc61f25d8bb2d478632ed0a879f
parent6934618b7dd41d94022b686df208dda6b06d77d9 (diff)
Don't "double check" var-sub-var constraints, which are handled in
expansion already by growing the RHS to be bigger than LHS (all the way
to `'static` if necessary). This is needed because contraction doesn't
handle givens. Fixes #28934.
-rw-r--r--src/librustc/middle/infer/region_inference/mod.rs16
-rw-r--r--src/test/run-pass/issue-28934.rs26
2 files changed, 30 insertions, 12 deletions
diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs
index 3b2eacb9b29..947815951df 100644
--- a/src/librustc/middle/infer/region_inference/mod.rs
+++ b/src/librustc/middle/infer/region_inference/mod.rs
@@ -983,18 +983,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
                                    .unwrap()
                                    );
             match *constraint {
-              ConstrainRegSubVar(..) => {
-                // This is an expansion constraint.  Ignore.
-                false
-              }
-              ConstrainVarSubVar(a_vid, b_vid) => {
-                match var_data[b_vid.index as usize].value {
-                  ErrorValue => false,
-                  Value(b_region) => {
-                    let a_data = &mut var_data[a_vid.index as usize];
-                    self.contract_node(free_regions, a_vid, a_data, b_region)
-                  }
-                }
+              ConstrainRegSubVar(..) |
+              ConstrainVarSubVar(..) => {
+                  // Expansion will ensure that these constraints hold. Ignore.
+                  false
               }
               ConstrainVarSubReg(a_vid, b_region) => {
                 let a_data = &mut var_data[a_vid.index as usize];
diff --git a/src/test/run-pass/issue-28934.rs b/src/test/run-pass/issue-28934.rs
new file mode 100644
index 00000000000..f4cb7d717e5
--- /dev/null
+++ b/src/test/run-pass/issue-28934.rs
@@ -0,0 +1,26 @@
+// 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.
+
+// Regression test: issue had to do with "givens" in region inference,
+// which were not being considered during the contraction phase.
+
+struct Parser<'i: 't, 't>(&'i u8, &'t u8);
+
+impl<'i, 't> Parser<'i, 't> {
+    fn parse_nested_block<F, T>(&mut self, parse: F) -> Result<T, ()>
+        where for<'tt> F: FnOnce(&mut Parser<'i, 'tt>) -> T { panic!() }
+
+    fn expect_exhausted(&mut self) -> Result<(), ()> { Ok(()) }
+}
+
+fn main() {
+    let x = 0u8;
+    Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwrap();
+}