Skip to content

Commit 71fe44d

Browse files
committed
auto merge of #15113 : pnkfelix/rust/fsk-add-regression-test-for-ice-from-10846, r=alexcrichton
Includes a bit more comments than usual for a regression test; I felt like documenting Niko's diagnosis of the original problem here. Fix #15111 r? anyone.
2 parents 58bf8b2 + 7be2019 commit 71fe44d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2014 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+
// This is a regression test for the ICE from issue #10846.
12+
//
13+
// The original issue causing the ICE: the LUB-computations during
14+
// type inference were encountering late-bound lifetimes, and
15+
// asserting that such lifetimes should have already been subsituted
16+
// with a concrete lifetime.
17+
//
18+
// However, those encounters were occurring within the lexical scope
19+
// of the binding for the late-bound lifetime; that is, the late-bound
20+
// lifetimes were perfectly valid. The core problem was that the type
21+
// folding code was over-zealously passing back all lifetimes when
22+
// doing region-folding, when really all clients of the region-folding
23+
// case only want to see FREE lifetime variables, not bound ones.
24+
25+
pub fn main() {
26+
fn explicit() {
27+
fn test(_x: Option<|f: <'a> |g: &'a int||>) {}
28+
test(Some(|_f: <'a> |g: &'a int|| {}));
29+
}
30+
31+
// The code below is shorthand for the code above (and more likely
32+
// to represent what one encounters in practice).
33+
fn implicit() {
34+
fn test(_x: Option<|f: |g: & int||>) {}
35+
test(Some(|_f: |g: & int|| {}));
36+
}
37+
38+
explicit();
39+
implicit();
40+
}

0 commit comments

Comments
 (0)