Split part of adt_const_params into unsized_const_params · model-checking/verify-rust-std@be0c06b (original) (raw)

`@@ -975,41 +975,74 @@ pub trait PointerLike {}

`

975

975

`` /// that all fields are also ConstParamTy, which implies that recursively, all fields

``

976

976

`` /// are StructuralPartialEq.

``

977

977

`#[lang = "const_param_ty"]

`

978

``

`-

#[unstable(feature = "adt_const_params", issue = "95174")]

`

``

978

`+

#[unstable(feature = "unsized_const_params", issue = "95174")]

`

979

979

`` #[diagnostic::on_unimplemented(message = "{Self} can't be used as a const parameter type")]

``

980

980

`#[allow(multiple_supertrait_upcastable)]

`

981

``

`-

pub trait ConstParamTy: StructuralPartialEq + Eq {}

`

``

981

`` +

// We name this differently than the derive macro so that the adt_const_params can

``

``

982

`` +

// be used independently of unsized_const_params without requiring a full path

``

``

983

`+

// to the derive macro every time it is used. This should be renamed on stabilization.

`

``

984

`+

pub trait ConstParamTy_: UnsizedConstParamTy + StructuralPartialEq + Eq {}

`

982

985

``

983

986

`` /// Derive macro generating an impl of the trait ConstParamTy.

``

984

987

`#[rustc_builtin_macro]

`

``

988

`+

#[allow_internal_unstable(unsized_const_params)]

`

985

989

`#[unstable(feature = "adt_const_params", issue = "95174")]

`

986

990

`pub macro ConstParamTy($item:item) {

`

987

991

`/* compiler built-in */

`

988

992

`}

`

989

993

``

``

994

`+

#[cfg_attr(not(bootstrap), lang = "unsized_const_param_ty")]

`

``

995

`+

#[unstable(feature = "unsized_const_params", issue = "95174")]

`

``

996

`` +

#[diagnostic::on_unimplemented(message = "{Self} can't be used as a const parameter type")]

``

``

997

`` +

/// A marker for types which can be used as types of const generic parameters.

``

``

998

`+

///

`

``

999

`` +

/// Equivalent to [ConstParamTy_] except that this is used by

``

``

1000

`` +

/// the unsized_const_params to allow for fake unstable impls.

``

``

1001

`+

pub trait UnsizedConstParamTy: StructuralPartialEq + Eq {}

`

``

1002

+

``

1003

`` +

/// Derive macro generating an impl of the trait ConstParamTy.

``

``

1004

`+

#[cfg(not(bootstrap))]

`

``

1005

`+

#[cfg_attr(not(bootstrap), rustc_builtin_macro)]

`

``

1006

`+

#[cfg_attr(not(bootstrap), allow_internal_unstable(unsized_const_params))]

`

``

1007

`+

#[cfg_attr(not(bootstrap), unstable(feature = "unsized_const_params", issue = "95174"))]

`

``

1008

`+

pub macro UnsizedConstParamTy($item:item) {

`

``

1009

`+

/* compiler built-in */

`

``

1010

`+

}

`

``

1011

+

990

1012

`` // FIXME(adt_const_params): handle ty::FnDef/ty::Closure

``

991

1013

`marker_impls! {

`

992

1014

` #[unstable(feature = "adt_const_params", issue = "95174")]

`

993

``

`-

ConstParamTy for

`

``

1015

`+

ConstParamTy_ for

`

994

1016

`usize, u8, u16, u32, u64, u128,

`

995

1017

`isize, i8, i16, i32, i64, i128,

`

996

1018

`bool,

`

997

1019

`char,

`

998

1020

`(),

`

999

``

`-

{T: ConstParamTy, const N: usize} [T; N],

`

``

1021

`+

{T: ConstParamTy_, const N: usize} [T; N],

`

``

1022

`+

}

`

``

1023

`+

#[cfg(bootstrap)]

`

``

1024

`+

marker_impls! {

`

``

1025

`+

#[unstable(feature = "adt_const_params", issue = "95174")]

`

``

1026

`+

ConstParamTy_ for

`

``

1027

`+

str,

`

``

1028

`+

{T: ConstParamTy_} [T],

`

``

1029

`+

{T: ConstParamTy_ + ?Sized} &T,

`

1000

1030

`}

`

1001

1031

``

1002

``

`-

#[unstable(feature = "adt_const_params", issue = "95174")]

`

1003

``

`` -

#[rustc_reservation_impl = "types that are not Sized are not supported as the type of a const generic parameter"]

``

1004

``

`-

impl ConstParamTy for [T] {}

`

1005

``

-

1006

``

`-

#[unstable(feature = "adt_const_params", issue = "95174")]

`

1007

``

`` -

#[rustc_reservation_impl = "types that are not Sized are not supported as the type of a const generic parameter"]

``

1008

``

`-

impl ConstParamTy for str {}

`

``

1032

`+

marker_impls! {

`

``

1033

`+

#[unstable(feature = "unsized_const_params", issue = "95174")]

`

``

1034

`+

UnsizedConstParamTy for

`

``

1035

`+

usize, u8, u16, u32, u64, u128,

`

``

1036

`+

isize, i8, i16, i32, i64, i128,

`

``

1037

`+

bool,

`

``

1038

`+

char,

`

``

1039

`+

(),

`

``

1040

`+

{T: UnsizedConstParamTy, const N: usize} [T; N],

`

1009

1041

``

1010

``

`-

#[unstable(feature = "adt_const_params", issue = "95174")]

`

1011

``

`-

#[rustc_reservation_impl = "references are not supported as the type of a const generic parameter"]

`

1012

``

`-

impl<T: ?Sized> ConstParamTy for &T {}

`

``

1042

`+

str,

`

``

1043

`+

{T: UnsizedConstParamTy} [T],

`

``

1044

`+

{T: UnsizedConstParamTy + ?Sized} &T,

`

``

1045

`+

}

`

1013

1046

``

1014

1047

`/// A common trait implemented by all function pointers.

`

1015

1048

`#[unstable(

`