Files
rust/tests/ui/const-generics/issues/issue-88119.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
803 B
Rust
Raw Normal View History

2024-06-30 17:08:45 +00:00
//@ known-bug: #110395
//@ compile-flags: -Znext-solver
2022-05-19 20:51:32 +09:00
#![allow(incomplete_features)]
2024-10-30 18:03:44 +00:00
#![feature(const_trait_impl, generic_const_exprs)]
2022-05-19 20:51:32 +09:00
2022-08-28 06:27:31 +00:00
#[const_trait]
2022-05-19 20:51:32 +09:00
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() {}