File tree 5 files changed +10
-13
lines changed
rustc_const_eval/src/const_eval
rustc_trait_selection/src/traits
5 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ pub(super) fn op_to_const<'tcx>(
226
226
let pointee_ty = imm. layout . ty . builtin_deref ( false ) . unwrap ( ) ; // `false` = no raw ptrs
227
227
debug_assert ! (
228
228
matches!(
229
- ecx. tcx. struct_tail_without_normalization ( pointee_ty) . kind( ) ,
229
+ ecx. tcx. struct_tail_for_codegen ( pointee_ty, ecx . param_env ) . kind( ) ,
230
230
ty:: Str | ty:: Slice ( ..) ,
231
231
) ,
232
232
"`ConstValue::Slice` is for slice-tailed types only, but got {}" ,
Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ impl<'a, 'tcx> Expectation<'tcx> {
70
70
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
71
71
/// for examples of where this comes up,.
72
72
pub ( super ) fn rvalue_hint ( fcx : & FnCtxt < ' a , ' tcx > , ty : Ty < ' tcx > ) -> Expectation < ' tcx > {
73
- match fcx. tcx . struct_tail_without_normalization ( ty) . kind ( ) {
73
+ // FIXME: This is not right, even in the old solver...
74
+ match fcx. tcx . struct_tail_raw ( ty, |ty| ty, || { } ) . kind ( ) {
74
75
ty:: Slice ( _) | ty:: Str | ty:: Dynamic ( ..) => ExpectRvalueLikeUnsized ( ty) ,
75
76
_ => ExpectHasType ( ty) ,
76
77
}
Original file line number Diff line number Diff line change @@ -171,14 +171,6 @@ impl<'tcx> TyCtxt<'tcx> {
171
171
}
172
172
}
173
173
174
- /// Attempts to returns the deeply last field of nested structures, but
175
- /// does not apply any normalization in its search. Returns the same type
176
- /// if input `ty` is not a structure at all.
177
- pub fn struct_tail_without_normalization ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
178
- let tcx = self ;
179
- tcx. struct_tail_raw ( ty, |ty| ty, || { } )
180
- }
181
-
182
174
/// Returns the deeply last field of nested structures, or the same type if
183
175
/// not a structure at all. Corresponds to the only possible unsized field,
184
176
/// and its type can be used to determine unsizing strategy.
Original file line number Diff line number Diff line change @@ -1149,10 +1149,10 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
1149
1149
| ty:: Never
1150
1150
// Extern types have unit metadata, according to RFC 2850
1151
1151
| ty:: Foreign ( _)
1152
- // If returned by `struct_tail_without_normalization ` this is a unit struct
1152
+ // If returned by `struct_tail ` this is a unit struct
1153
1153
// without any fields, or not a struct, and therefore is Sized.
1154
1154
| ty:: Adt ( ..)
1155
- // If returned by `struct_tail_without_normalization ` this is the empty tuple.
1155
+ // If returned by `struct_tail ` this is the empty tuple.
1156
1156
| ty:: Tuple ( ..)
1157
1157
// Integers and floats are always Sized, and so have unit type metadata.
1158
1158
| ty:: Infer ( ty:: InferTy :: IntVar ( _) | ty:: InferTy :: FloatVar ( ..) ) => true ,
Original file line number Diff line number Diff line change @@ -219,9 +219,13 @@ fn layout_of_uncached<'tcx>(
219
219
// its struct tail cannot be normalized either, so try to get a
220
220
// more descriptive layout error here, which will lead to less confusing
221
221
// diagnostics.
222
+ //
223
+ // We use the raw struct tail function here to get the first tail
224
+ // that is an alias, which is likely the cause of the normalization
225
+ // error.
222
226
match tcx. try_normalize_erasing_regions (
223
227
param_env,
224
- tcx. struct_tail_without_normalization ( pointee) ,
228
+ tcx. struct_tail_raw ( pointee, |ty| ty , || { } ) ,
225
229
) {
226
230
Ok ( _) => { }
227
231
Err ( better_err) => {
You can’t perform that action at this time.
0 commit comments