Skip to content

Commit edcebef

Browse files
committed
Add a ConstParamTy trait
1 parent fb8692b commit edcebef

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

core/src/marker.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,40 @@ pub trait Tuple {}
912912
)]
913913
pub trait PointerLike {}
914914

915+
/// A marker for types which can be used as types of `const` generic parameters.
916+
#[cfg_attr(not(bootstrap), lang = "const_param_ty")]
917+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
918+
#[rustc_on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
919+
pub trait ConstParamTy: StructuralEq {}
920+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
921+
impl ConstParamTy for usize {}
922+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
923+
impl ConstParamTy for u8 {}
924+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
925+
impl ConstParamTy for u16 {}
926+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
927+
impl ConstParamTy for u32 {}
928+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
929+
impl ConstParamTy for u64 {}
930+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
931+
impl ConstParamTy for u128 {}
932+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
933+
impl ConstParamTy for isize {}
934+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
935+
impl ConstParamTy for i8 {}
936+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
937+
impl ConstParamTy for i16 {}
938+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
939+
impl ConstParamTy for i32 {}
940+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
941+
impl ConstParamTy for i64 {}
942+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
943+
impl ConstParamTy for i128 {}
944+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
945+
impl ConstParamTy for bool {}
946+
#[unstable(feature = "const_param_ty_trait", issue = "none")]
947+
impl ConstParamTy for char {}
948+
915949
/// Implementations of `Copy` for primitive types.
916950
///
917951
/// Implementations that cannot be described in Rust

0 commit comments

Comments
 (0)