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 // Test that type IDs correctly account for higher-rank lifetimes
12 // Also acts as a regression test for an ICE (issue #19791)
14 #![feature(unboxed_closures, core)]
21 let a = TypeId::of::<fn(&'static int, &'static int)>();
22 let b = TypeId::of::<for<'a> fn(&'static int, &'a int)>();
23 let c = TypeId::of::<for<'a, 'b> fn(&'a int, &'b int)>();
24 let d = TypeId::of::<for<'a, 'b> fn(&'b int, &'a int)>();
32 // Make sure De Bruijn indices are handled correctly
33 let e = TypeId::of::<for<'a> fn(fn(&'a int) -> &'a int)>();
34 let f = TypeId::of::<fn(for<'a> fn(&'a int) -> &'a int)>();
37 // Boxed unboxed closures
39 let a = TypeId::of::<Box<Fn(&'static int, &'static int)>>();
40 let b = TypeId::of::<Box<for<'a> Fn(&'static int, &'a int)>>();
41 let c = TypeId::of::<Box<for<'a, 'b> Fn(&'a int, &'b int)>>();
42 let d = TypeId::of::<Box<for<'a, 'b> Fn(&'b int, &'a int)>>();
50 // Make sure De Bruijn indices are handled correctly
51 let e = TypeId::of::<Box<for<'a> Fn(Box<Fn(&'a int) -> &'a int>)>>();
52 let f = TypeId::of::<Box<Fn(Box<for<'a> Fn(&'a int) -> &'a int>)>>();
55 // Raw unboxed closures
56 // Note that every unboxed closure has its own anonymous type,
57 // so no two IDs should equal each other, even when compatible
59 let a = id(|_: &int, _: &int| {});
60 let b = id(|_: &int, _: &int| {});
64 fn id<T:'static>(_: T) -> TypeId {