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.
This commit is contained in:
Niko Matsakis 2015-10-26 17:01:36 -04:00
parent 6934618b7d
commit c81ce8249c
2 changed files with 30 additions and 12 deletions

View File

@ -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];

View File

@ -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();
}