@@ -378,6 +378,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
378378 goal : Goal < ' tcx , Self > ,
379379 ) -> QueryResult < ' tcx > {
380380 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( ) ) ;
381383 ecx. probe_misc_candidate ( "builtin pointee" ) . enter ( |ecx| {
382384 let metadata_ty = match goal. predicate . self_ty ( ) . kind ( ) {
383385 ty:: Bool
@@ -422,13 +424,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
422424
423425 ty:: Adt ( def, args) if def. is_struct ( ) => match def. non_enum_variant ( ) . tail_opt ( ) {
424426 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 ( ) ;
427430 // 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) ) ;
432432 return ecx
433433 . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
434434 }
@@ -437,12 +437,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
437437
438438 ty:: Tuple ( elements) => match elements. last ( ) {
439439 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 ( ) ;
441442 // 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) ) ;
446444 return ecx
447445 . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
448446 }
0 commit comments