From 857ed93c04e99410ae1d9d3e6ab620cc5aeb8e59 Mon Sep 17 00:00:00 2001 From: Boxy Date: Sun, 14 Jul 2024 12:50:41 +0100 Subject: [PATCH] Forbid `!Sized` types and references --- core/src/marker.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/marker.rs b/core/src/marker.rs index 21abd7c036ba7..70bd4f67ebfde 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -995,13 +995,22 @@ marker_impls! { isize, i8, i16, i32, i64, i128, bool, char, - str /* Technically requires `[u8]: ConstParamTy` */, (), {T: ConstParamTy, const N: usize} [T; N], - {T: ConstParamTy} [T], - {T: ?Sized + ConstParamTy} &T, } +#[unstable(feature = "adt_const_params", issue = "95174")] +#[rustc_reservation_impl = "types that are not `Sized` are not supported as the type of a const generic parameter"] +impl ConstParamTy for [T] {} + +#[unstable(feature = "adt_const_params", issue = "95174")] +#[rustc_reservation_impl = "types that are not `Sized` are not supported as the type of a const generic parameter"] +impl ConstParamTy for str {} + +#[unstable(feature = "adt_const_params", issue = "95174")] +#[rustc_reservation_impl = "references are not supported as the type of a const generic parameter"] +impl ConstParamTy for &T {} + /// A common trait implemented by all function pointers. #[unstable( feature = "fn_ptr_trait",