blob: 647b0eea86dafc1557874a386a0b128bab418640 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// check-pass
#![allow(incomplete_features)]
#![feature(const_trait_impl, generic_const_exprs)]
#[const_trait]
trait ConstName {
const NAME_BYTES: &'static [u8];
}
impl const ConstName for u8 {
const NAME_BYTES: &'static [u8] = b"u8";
}
const fn name_len<T: ?Sized + ConstName>() -> usize {
T::NAME_BYTES.len()
}
impl<T: ?Sized + ConstName> const ConstName for &T
where
[(); name_len::<T>()]:,
{
const NAME_BYTES: &'static [u8] = b"&T";
}
impl<T: ?Sized + ConstName> const ConstName for &mut T
where
[(); name_len::<T>()]:,
{
const NAME_BYTES: &'static [u8] = b"&mut T";
}
pub const ICE_1: &'static [u8] = <&&mut u8 as ConstName>::NAME_BYTES;
pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES;
fn main() {}
|