1
Fork 0

remove unreachable cases

`ty::Placeholder` is used by the trait solver and computing its layout
was necessary, because the `PointerLike` trait used to be automatically
implemented for all types with pointer-like layout.
Nowadays, `PointerLike` requires user-written impls and the trait solver
no longer computes any layouts, so this can be removed.

Unevaluated constants that aren't generic should have caused a const eval
error earlier during normalization.
This commit is contained in:
Lukas Markeffsky 2025-02-16 00:19:56 +01:00
parent 802b7abab7
commit 7a667d206c

View file

@ -155,19 +155,12 @@ fn extract_const_value<'tcx>(
ty::ConstKind::Error(guar) => {
return Err(error(cx, LayoutError::ReferencesError(guar)));
}
ty::ConstKind::Param(_) | ty::ConstKind::Expr(_) => {
ty::ConstKind::Param(_) | ty::ConstKind::Expr(_) | ty::ConstKind::Unevaluated(_) => {
if !const_.has_param() {
bug!("no generic type found in the type: {ty:?}");
bug!("failed to normalize const, but it is not generic: {const_:?}");
}
return Err(error(cx, LayoutError::TooGeneric(ty)));
}
ty::ConstKind::Unevaluated(_) => {
if !const_.has_param() {
return Err(error(cx, LayoutError::Unknown(ty)));
} else {
return Err(error(cx, LayoutError::TooGeneric(ty)));
}
}
ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => {
bug!("unexpected type: {ty:?}");
}
@ -728,17 +721,17 @@ fn layout_of_uncached<'tcx>(
return Err(error(cx, LayoutError::Unknown(ty)));
}
ty::Bound(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => {
bug!("Layout::compute: unexpected type `{}`", ty)
ty::Placeholder(..)
| ty::Bound(..)
| ty::CoroutineWitness(..)
| ty::Infer(_)
| ty::Error(_) => {
bug!("layout_of: unexpected type `{ty}`")
}
ty::Param(_) => {
return Err(error(cx, LayoutError::TooGeneric(ty)));
}
ty::Placeholder(..) => {
return Err(error(cx, LayoutError::Unknown(ty)));
}
})
}