Skip to content

Commit 1fb9be0

Browse files
authored
Rollup merge of rust-lang#97171 - JohnTitor:issue-88119, r=compiler-errors
Add regression test for rust-lang#88119 Closes rust-lang#88119
2 parents 1759747 + 676604b commit 1fb9be0

File tree

1 file changed

+35
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)