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.
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.
11 // This is an example where the older inference algorithm failed. The
12 // specifics of why it failed are somewhat, but not entirely, tailed
13 // to the algorithm. Ultimately the problem is that when computing the
14 // mutual supertype of both sides of the `if` it would be faced with a
15 // choice of tightening bounds or unifying variables and it took the
16 // wrong path. The new algorithm avoids this problem and hence this
17 // example typechecks correctly.
19 // pretty-expanded FIXME #23616
26 type Scope<'a> = &'a ScopeChain<'a>;
34 impl<'a> Context<'a> {
35 fn foo(&mut self, scope: Scope) {
37 let l = ScopeChain::Link(scope);
41 ScopeChain::Link(scope)
43 self.take_scope(&link);
46 fn take_scope(&mut self, x: Scope) {