Impl StructuralEq
& ConstParamTy
for str
, &T
, [T; N]
and [T]
This commit is contained in:
parent
2205c3fa5f
commit
1bf6bbb1bd
2 changed files with 17 additions and 1 deletions
|
@ -93,7 +93,14 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
|
||||||
) -> Result<(), ConstParamTyImplementationError<'tcx>> {
|
) -> Result<(), ConstParamTyImplementationError<'tcx>> {
|
||||||
let (adt, substs) = match self_type.kind() {
|
let (adt, substs) = match self_type.kind() {
|
||||||
// `core` provides these impls.
|
// `core` provides these impls.
|
||||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Char => return Ok(()),
|
ty::Uint(_)
|
||||||
|
| ty::Int(_)
|
||||||
|
| ty::Bool
|
||||||
|
| ty::Char
|
||||||
|
| ty::Str
|
||||||
|
| ty::Array(..)
|
||||||
|
| ty::Slice(_)
|
||||||
|
| ty::Ref(.., hir::Mutability::Not) => return Ok(()),
|
||||||
|
|
||||||
&ty::Adt(adt, substs) => (adt, substs),
|
&ty::Adt(adt, substs) => (adt, substs),
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,7 @@ pub trait StructuralEq {
|
||||||
// Empty.
|
// Empty.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Remove special cases of these types from the compiler pattern checking code and always check `T: StructuralEq` instead
|
||||||
marker_impls! {
|
marker_impls! {
|
||||||
#[unstable(feature = "structural_match", issue = "31434")]
|
#[unstable(feature = "structural_match", issue = "31434")]
|
||||||
StructuralEq for
|
StructuralEq for
|
||||||
|
@ -275,6 +276,10 @@ marker_impls! {
|
||||||
isize, i8, i16, i32, i64, i128,
|
isize, i8, i16, i32, i64, i128,
|
||||||
bool,
|
bool,
|
||||||
char,
|
char,
|
||||||
|
str /* Technically requires `[u8]: StructuralEq` */,
|
||||||
|
{T: ConstParamTy, const N: usize} [T; N],
|
||||||
|
{T: ConstParamTy} [T],
|
||||||
|
{T: ConstParamTy} &T,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Types whose values can be duplicated simply by copying bits.
|
/// Types whose values can be duplicated simply by copying bits.
|
||||||
|
@ -988,6 +993,10 @@ marker_impls! {
|
||||||
isize, i8, i16, i32, i64, i128,
|
isize, i8, i16, i32, i64, i128,
|
||||||
bool,
|
bool,
|
||||||
char,
|
char,
|
||||||
|
str /* Technically requires `[u8]: ConstParamTy` */,
|
||||||
|
{T: ConstParamTy, const N: usize} [T; N],
|
||||||
|
{T: ConstParamTy} [T],
|
||||||
|
{T: ConstParamTy} &T,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A common trait implemented by all function pointers.
|
/// A common trait implemented by all function pointers.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue