@@ -928,21 +928,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
928928 // we get a value of a built-in pointer type.
929929 //
930930 // This is also relevant for `Pin<&mut Self>`, where we need to peel the `Pin`.
931- ' descend_newtypes: while !op. layout . ty . is_unsafe_ptr ( )
932- && !op. layout . ty . is_ref ( )
933- {
934- for i in 0 ..op. layout . fields . count ( ) {
935- let field = op. extract_field ( bx, i) ;
936- if !field. layout . is_1zst ( ) {
937- // we found the one non-1-ZST field that is allowed
938- // now find *its* non-zero-sized field, or stop if it's a
939- // pointer
940- op = field;
941- continue ' descend_newtypes;
942- }
943- }
944-
945- span_bug ! ( span, "receiver has no non-zero-sized fields {:?}" , op) ;
931+ while !op. layout . ty . is_unsafe_ptr ( ) && !op. layout . ty . is_ref ( ) {
932+ let ( idx, _) = op. layout . non_1zst_field ( bx) . expect (
933+ "not exactly one non-1-ZST field in a `DispatchFromDyn` type" ,
934+ ) ;
935+ op = op. extract_field ( bx, idx) ;
946936 }
947937
948938 // now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
@@ -970,22 +960,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
970960 }
971961 Immediate ( _) => {
972962 // See comment above explaining why we peel these newtypes
973- ' descend_newtypes: while !op. layout . ty . is_unsafe_ptr ( )
974- && !op. layout . ty . is_ref ( )
975- {
976- for i in 0 ..op. layout . fields . count ( ) {
977- let field = op. extract_field ( bx, i) ;
978- if !field. layout . is_1zst ( ) {
979- // We found the one non-1-ZST field that is allowed. (The rules
980- // for `DispatchFromDyn` ensure there's exactly one such field.)
981- // Now find *its* non-zero-sized field, or stop if it's a
982- // pointer.
983- op = field;
984- continue ' descend_newtypes;
985- }
986- }
987-
988- span_bug ! ( span, "receiver has no non-zero-sized fields {:?}" , op) ;
963+ while !op. layout . ty . is_unsafe_ptr ( ) && !op. layout . ty . is_ref ( ) {
964+ let ( idx, _) = op. layout . non_1zst_field ( bx) . expect (
965+ "not exactly one non-1-ZST field in a `DispatchFromDyn` type" ,
966+ ) ;
967+ op = op. extract_field ( bx, idx) ;
989968 }
990969
991970 // Make sure that we've actually unwrapped the rcvr down
0 commit comments