From 676604bdd2788dab707ad795e8d76e46c5f7e00e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 19 May 2022 20:51:32 +0900 Subject: [PATCH] Add regression test for #88119 --- .../ui/const-generics/issues/issue-88119.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-88119.rs diff --git a/src/test/ui/const-generics/issues/issue-88119.rs b/src/test/ui/const-generics/issues/issue-88119.rs new file mode 100644 index 0000000000000..70dfa7f708b4f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-88119.rs @@ -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() -> usize { + T::NAME_BYTES.len() +} + +impl const ConstName for &T +where + [(); name_len::()]:, +{ + const NAME_BYTES: &'static [u8] = b"&T"; +} + +impl const ConstName for &mut T +where + [(); name_len::()]:, +{ + 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() {}