Remove struct_tail_no_normalization
This commit is contained in:
parent
b5d2079fb9
commit
f15997ffec
5 changed files with 10 additions and 13 deletions
|
@ -226,7 +226,7 @@ pub(super) fn op_to_const<'tcx>(
|
||||||
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap(); // `false` = no raw ptrs
|
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap(); // `false` = no raw ptrs
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
matches!(
|
matches!(
|
||||||
ecx.tcx.struct_tail_without_normalization(pointee_ty).kind(),
|
ecx.tcx.struct_tail_for_codegen(pointee_ty, ecx.param_env).kind(),
|
||||||
ty::Str | ty::Slice(..),
|
ty::Str | ty::Slice(..),
|
||||||
),
|
),
|
||||||
"`ConstValue::Slice` is for slice-tailed types only, but got {}",
|
"`ConstValue::Slice` is for slice-tailed types only, but got {}",
|
||||||
|
|
|
@ -70,7 +70,8 @@ impl<'a, 'tcx> Expectation<'tcx> {
|
||||||
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
|
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
|
||||||
/// for examples of where this comes up,.
|
/// for examples of where this comes up,.
|
||||||
pub(super) fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
|
pub(super) fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
|
||||||
match fcx.tcx.struct_tail_without_normalization(ty).kind() {
|
// FIXME: This is not right, even in the old solver...
|
||||||
|
match fcx.tcx.struct_tail_raw(ty, |ty| ty, || {}).kind() {
|
||||||
ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty),
|
ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty),
|
||||||
_ => ExpectHasType(ty),
|
_ => ExpectHasType(ty),
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,14 +171,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to returns the deeply last field of nested structures, but
|
|
||||||
/// does not apply any normalization in its search. Returns the same type
|
|
||||||
/// if input `ty` is not a structure at all.
|
|
||||||
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
|
||||||
let tcx = self;
|
|
||||||
tcx.struct_tail_raw(ty, |ty| ty, || {})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the deeply last field of nested structures, or the same type if
|
/// Returns the deeply last field of nested structures, or the same type if
|
||||||
/// not a structure at all. Corresponds to the only possible unsized field,
|
/// not a structure at all. Corresponds to the only possible unsized field,
|
||||||
/// and its type can be used to determine unsizing strategy.
|
/// and its type can be used to determine unsizing strategy.
|
||||||
|
|
|
@ -1149,10 +1149,10 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
||||||
| ty::Never
|
| ty::Never
|
||||||
// Extern types have unit metadata, according to RFC 2850
|
// Extern types have unit metadata, according to RFC 2850
|
||||||
| ty::Foreign(_)
|
| ty::Foreign(_)
|
||||||
// If returned by `struct_tail_without_normalization` this is a unit struct
|
// If returned by `struct_tail` this is a unit struct
|
||||||
// without any fields, or not a struct, and therefore is Sized.
|
// without any fields, or not a struct, and therefore is Sized.
|
||||||
| ty::Adt(..)
|
| ty::Adt(..)
|
||||||
// If returned by `struct_tail_without_normalization` this is the empty tuple.
|
// If returned by `struct_tail` this is the empty tuple.
|
||||||
| ty::Tuple(..)
|
| ty::Tuple(..)
|
||||||
// Integers and floats are always Sized, and so have unit type metadata.
|
// Integers and floats are always Sized, and so have unit type metadata.
|
||||||
| ty::Infer(ty::InferTy::IntVar(_) | ty::InferTy::FloatVar(..)) => true,
|
| ty::Infer(ty::InferTy::IntVar(_) | ty::InferTy::FloatVar(..)) => true,
|
||||||
|
|
|
@ -219,9 +219,13 @@ fn layout_of_uncached<'tcx>(
|
||||||
// its struct tail cannot be normalized either, so try to get a
|
// its struct tail cannot be normalized either, so try to get a
|
||||||
// more descriptive layout error here, which will lead to less confusing
|
// more descriptive layout error here, which will lead to less confusing
|
||||||
// diagnostics.
|
// diagnostics.
|
||||||
|
//
|
||||||
|
// We use the raw struct tail function here to get the first tail
|
||||||
|
// that is an alias, which is likely the cause of the normalization
|
||||||
|
// error.
|
||||||
match tcx.try_normalize_erasing_regions(
|
match tcx.try_normalize_erasing_regions(
|
||||||
param_env,
|
param_env,
|
||||||
tcx.struct_tail_without_normalization(pointee),
|
tcx.struct_tail_raw(pointee, |ty| ty, || {}),
|
||||||
) {
|
) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(better_err) => {
|
Err(better_err) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue