Skip to content

Commit

Permalink
Rollup merge of #97171 - JohnTitor:issue-88119, r=compiler-errors
Browse files Browse the repository at this point in the history
Add regression test for #88119

Closes #88119
  • Loading branch information
Dylan-DPC authored May 19, 2022
2 parents 1759747 + 676604b commit 1fb9be0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/ui/const-generics/issues/issue-88119.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 1fb9be0

Please sign in to comment.