diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-19 17:22:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-19 17:22:51 +0200 |
| commit | 1fb9be0cee828d29cfe38fa61c6b3f1c21424f1c (patch) | |
| tree | 0b8d32d306bf518a31f92226418a1f786343ac6d | |
| parent | 175974743abb6b27e70ee9cda14104a8616c0949 (diff) | |
| parent | 676604bdd2788dab707ad795e8d76e46c5f7e00e (diff) | |
| download | rust-1fb9be0cee828d29cfe38fa61c6b3f1c21424f1c.tar.gz rust-1fb9be0cee828d29cfe38fa61c6b3f1c21424f1c.zip | |
Rollup merge of #97171 - JohnTitor:issue-88119, r=compiler-errors
Add regression test for #88119 Closes #88119
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-88119.rs | 35 |
1 files changed, 35 insertions, 0 deletions
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 00000000000..70dfa7f708b --- /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<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() {} |
