mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Rollup merge of #97171 - JohnTitor:issue-88119, r=compiler-errors
Add regression test for #88119 Closes #88119
This commit is contained in:
commit
1fb9be0cee
35
src/test/ui/const-generics/issues/issue-88119.rs
Normal file
35
src/test/ui/const-generics/issues/issue-88119.rs
Normal file
@ -0,0 +1,35 @@
|
||||
// check-pass
|
||||
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(const_trait_impl, generic_const_exprs)]
|
||||
|
||||
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() {}
|
Loading…
Reference in New Issue
Block a user