]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/hrtb-binder-levels-in-object-types.rs
auto merge of #19648 : mquandalle/rust/patch-1, r=alexcrichton
[rust.git] / src / test / run-pass / hrtb-binder-levels-in-object-types.rs
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 // Test that we handle binder levels in object types correctly.
12 // Initially, the reference to `'tcx` in the object type
13 // `&Typer<'tcx>` was getting an incorrect binder level, yielding
14 // weird compilation ICEs and so forth.
15
16 trait Typer<'tcx> {
17     fn method(&self, data: &'tcx int) -> &'tcx int { data }
18 }
19
20 struct Tcx<'tcx> {
21     fields: &'tcx int
22 }
23
24 impl<'tcx> Typer<'tcx> for Tcx<'tcx> {
25 }
26
27 fn g<'tcx>(typer: &Typer<'tcx>) {
28 }
29
30 fn check_static_type<'x>(tcx: &Tcx<'x>) {
31     g(tcx)
32 }
33
34 fn main() { }