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