Skip to content

Commit c81ce82

Browse files
committed
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.
1 parent 6934618 commit c81ce82

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/librustc/middle/infer/region_inference/mod.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -983,18 +983,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
983983
.unwrap()
984984
);
985985
match *constraint {
986-
ConstrainRegSubVar(..) => {
987-
// This is an expansion constraint. Ignore.
988-
false
989-
}
990-
ConstrainVarSubVar(a_vid, b_vid) => {
991-
match var_data[b_vid.index as usize].value {
992-
ErrorValue => false,
993-
Value(b_region) => {
994-
let a_data = &mut var_data[a_vid.index as usize];
995-
self.contract_node(free_regions, a_vid, a_data, b_region)
996-
}
997-
}
986+
ConstrainRegSubVar(..) |
987+
ConstrainVarSubVar(..) => {
988+
// Expansion will ensure that these constraints hold. Ignore.
989+
false
998990
}
999991
ConstrainVarSubReg(a_vid, b_region) => {
1000992
let a_data = &mut var_data[a_vid.index as usize];

src/test/run-pass/issue-28934.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test: issue had to do with "givens" in region inference,
12+
// which were not being considered during the contraction phase.
13+
14+
struct Parser<'i: 't, 't>(&'i u8, &'t u8);
15+
16+
impl<'i, 't> Parser<'i, 't> {
17+
fn parse_nested_block<F, T>(&mut self, parse: F) -> Result<T, ()>
18+
where for<'tt> F: FnOnce(&mut Parser<'i, 'tt>) -> T { panic!() }
19+
20+
fn expect_exhausted(&mut self) -> Result<(), ()> { Ok(()) }
21+
}
22+
23+
fn main() {
24+
let x = 0u8;
25+
Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwrap();
26+
}

0 commit comments

Comments
 (0)