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 or the MIT license +// , 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(&mut self, parse: F) -> Result + 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(); +}