@@ -378,6 +378,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
378
378
goal : Goal < ' tcx , Self > ,
379
379
) -> QueryResult < ' tcx > {
380
380
let tcx = ecx. tcx ( ) ;
381
+ let metadata_def_id = tcx. require_lang_item ( LangItem :: Metadata , None ) ;
382
+ assert_eq ! ( metadata_def_id, goal. predicate. def_id( ) ) ;
381
383
ecx. probe_misc_candidate ( "builtin pointee" ) . enter ( |ecx| {
382
384
let metadata_ty = match goal. predicate . self_ty ( ) . kind ( ) {
383
385
ty:: Bool
@@ -422,13 +424,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
422
424
423
425
ty:: Adt ( def, args) if def. is_struct ( ) => match def. non_enum_variant ( ) . tail_opt ( ) {
424
426
None => tcx. types . unit ,
425
- Some ( field_def) => {
426
- let self_ty = field_def. ty ( tcx, args) ;
427
+ Some ( tail_def) => {
428
+ let tail_ty = tail_def. ty ( tcx, args) ;
429
+ let predicate = goal. predicate . with_self_ty ( tcx, tail_ty) . as_projection ( ) ;
427
430
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
428
- ecx. add_goal (
429
- GoalSource :: Misc ,
430
- goal. with ( tcx, goal. predicate . with_self_ty ( tcx, self_ty) ) ,
431
- ) ;
431
+ ecx. add_goal ( GoalSource :: Misc , goal. with ( tcx, predicate) ) ;
432
432
return ecx
433
433
. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
434
434
}
@@ -437,12 +437,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
437
437
438
438
ty:: Tuple ( elements) => match elements. last ( ) {
439
439
None => tcx. types . unit ,
440
- Some ( & self_ty) => {
440
+ Some ( & tail_ty) => {
441
+ let predicate = goal. predicate . with_self_ty ( tcx, tail_ty) . as_projection ( ) ;
441
442
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
442
- ecx. add_goal (
443
- GoalSource :: Misc ,
444
- goal. with ( tcx, goal. predicate . with_self_ty ( tcx, self_ty) ) ,
445
- ) ;
443
+ ecx. add_goal ( GoalSource :: Misc , goal. with ( tcx, predicate) ) ;
446
444
return ecx
447
445
. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
448
446
}
0 commit comments