]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 XL |
2 | #![allow(dead_code)] |
3 | #![allow(unused_variables)] | |
1a4d82fc JJ |
4 | // This is an example where the older inference algorithm failed. The |
5 | // specifics of why it failed are somewhat, but not entirely, tailed | |
6 | // to the algorithm. Ultimately the problem is that when computing the | |
7 | // mutual supertype of both sides of the `if` it would be faced with a | |
8 | // choice of tightening bounds or unifying variables and it took the | |
9 | // wrong path. The new algorithm avoids this problem and hence this | |
10 | // example typechecks correctly. | |
11 | ||
c34b1796 AL |
12 | // pretty-expanded FIXME #23616 |
13 | ||
1a4d82fc JJ |
14 | enum ScopeChain<'a> { |
15 | Link(Scope<'a>), | |
16 | End | |
17 | } | |
18 | ||
19 | type Scope<'a> = &'a ScopeChain<'a>; | |
20 | ||
21 | struct OuterContext; | |
22 | ||
23 | struct Context<'a> { | |
24 | foo: &'a OuterContext | |
25 | } | |
26 | ||
27 | impl<'a> Context<'a> { | |
28 | fn foo(&mut self, scope: Scope) { | |
85aaf69f | 29 | let link = if 1 < 2 { |
1a4d82fc JJ |
30 | let l = ScopeChain::Link(scope); |
31 | self.take_scope(&l); | |
32 | l | |
33 | } else { | |
34 | ScopeChain::Link(scope) | |
35 | }; | |
36 | self.take_scope(&link); | |
37 | } | |
38 | ||
39 | fn take_scope(&mut self, x: Scope) { | |
40 | } | |
41 | } | |
42 | ||
43 | fn main() { } |