Skip to content

Commit

Permalink
Don't "double check" var-sub-var constraints, which are handled in
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikomatsakis committed Oct 28, 2015
1 parent 6934618 commit c81ce82
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/librustc/middle/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
26 changes: 26 additions & 0 deletions src/test/run-pass/issue-28934.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit c81ce82

Please sign in to comment.