]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/type-id-higher-rank.rs
2 // Test that type IDs correctly account for higher-rank lifetimes
3 // Also acts as a regression test for an ICE (issue #19791)
5 use std
::any
::{Any, TypeId}
;
7 struct Struct
<'a
>(&'
a ());
13 let a
= TypeId
::of
::<fn(&'
static isize, &'
static isize)>();
14 let b
= TypeId
::of
::<for<'a
> fn(&'
static isize, &'a
isize)>();
15 let c
= TypeId
::of
::<for<'a
, 'b
> fn(&'a
isize, &'b
isize)>();
16 let d
= TypeId
::of
::<for<'a
, 'b
> fn(&'b
isize, &'a
isize)>();
24 // Make sure De Bruijn indices are handled correctly
25 let e
= TypeId
::of
::<for<'a
> fn(fn(&'a
isize) -> &'a
isize)>();
26 let f
= TypeId
::of
::<fn(for<'a
> fn(&'a
isize) -> &'a
isize)>();
29 // Make sure lifetime parameters of items are not ignored.
30 let g
= TypeId
::of
::<for<'a
> fn(&'a
dyn Trait
<'a
>) -> Struct
<'a
>>();
31 let h
= TypeId
::of
::<for<'a
> fn(&'a
dyn Trait
<'a
>) -> Struct
<'
static>>();
32 let i
= TypeId
::of
::<for<'a
, 'b
> fn(&'a
dyn Trait
<'b
>) -> Struct
<'b
>>();
37 // Make sure lifetime anonymization handles nesting correctly
38 let j
= TypeId
::of
::<fn(for<'a
> fn(&'a
isize) -> &'a
usize)>();
39 let k
= TypeId
::of
::<fn(for<'b
> fn(&'b
isize) -> &'b
usize)>();
42 // Boxed unboxed closures
44 let a
= TypeId
::of
::<Box
<dyn Fn(&'
static isize, &'
static isize)>>();
45 let b
= TypeId
::of
::<Box
<dyn for<'a
> Fn(&'
static isize, &'a
isize)>>();
46 let c
= TypeId
::of
::<Box
<dyn for<'a
, 'b
> Fn(&'a
isize, &'b
isize)>>();
47 let d
= TypeId
::of
::<Box
<dyn for<'a
, 'b
> Fn(&'b
isize, &'a
isize)>>();
55 // Make sure De Bruijn indices are handled correctly
56 let e
= TypeId
::of
::<Box
<dyn for<'a
> Fn(Box
<dyn Fn(&'a
isize) -> &'a
isize>)>>();
57 let f
= TypeId
::of
::<Box
<dyn Fn(Box
<dyn for<'a
> Fn(&'a
isize) -> &'a
isize>)>>();
60 // Raw unboxed closures
61 // Note that every unboxed closure has its own anonymous type,
62 // so no two IDs should equal each other, even when compatible
64 let a
= id(|_
: &isize, _
: &isize| {}
);
65 let b
= id(|_
: &isize, _
: &isize| {}
);
69 fn id
<T
:Any
>(_
: T
) -> TypeId
{