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)]
16 use std::intrinsics::TypeId;
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)>();
39 let a = TypeId::of::<|&'static int, &'static int|>();
40 let b = TypeId::of::<for<'a> |&'static int, &'a int|>();
41 let c = TypeId::of::<for<'a, 'b> |&'a int, &'b int|>();
42 let d = TypeId::of::<for<'a, 'b> |&'b int, &'a int|>();
50 // Make sure De Bruijn indices are handled correctly
51 let e = TypeId::of::<for<'a> |(|&'a int| -> &'a int)|>();
52 let f = TypeId::of::<|for<'a> |&'a int| -> &'a int|>();
55 // Boxed unboxed closures
57 let a = TypeId::of::<Box<Fn(&'static int, &'static int)>>();
58 let b = TypeId::of::<Box<for<'a> Fn(&'static int, &'a int)>>();
59 let c = TypeId::of::<Box<for<'a, 'b> Fn(&'a int, &'b int)>>();
60 let d = TypeId::of::<Box<for<'a, 'b> Fn(&'b int, &'a int)>>();
68 // Make sure De Bruijn indices are handled correctly
69 let e = TypeId::of::<Box<for<'a> Fn(Box<Fn(&'a int) -> &'a int>)>>();
70 let f = TypeId::of::<Box<Fn(Box<for<'a> Fn(&'a int) -> &'a int>)>>();
73 // Raw unboxed closures
74 // Note that every unboxed closure has its own anonymous type,
75 // so no two IDs should equal each other, even when compatible
77 let a = id(|&: _: &int, _: &int| {});
78 let b = id(|&: _: &int, _: &int| {});
82 fn id<T:'static>(_: T) -> TypeId {