@@ -97,7 +97,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
9797 } else if lang_items. tuple_trait ( ) == Some ( def_id) {
9898 self . assemble_candidate_for_tuple ( obligation, & mut candidates) ;
9999 } else if lang_items. pointer_like ( ) == Some ( def_id) {
100- self . assemble_candidate_for_ptr_sized ( obligation, & mut candidates) ;
100+ self . assemble_candidate_for_pointer_like ( obligation, & mut candidates) ;
101101 } else if lang_items. fn_ptr_trait ( ) == Some ( def_id) {
102102 self . assemble_candidates_for_fn_ptr_trait ( obligation, & mut candidates) ;
103103 } else {
@@ -942,25 +942,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
942942 }
943943 }
944944
945- fn assemble_candidate_for_ptr_sized (
945+ fn assemble_candidate_for_pointer_like (
946946 & mut self ,
947947 obligation : & TraitObligation < ' tcx > ,
948948 candidates : & mut SelectionCandidateSet < ' tcx > ,
949949 ) {
950950 // The regions of a type don't affect the size of the type
951- let self_ty = self
952- . tcx ( )
953- . erase_regions ( self . tcx ( ) . erase_late_bound_regions ( obligation. predicate . self_ty ( ) ) ) ;
951+ let tcx = self . tcx ( ) ;
952+ let self_ty =
953+ tcx . erase_regions ( tcx. erase_late_bound_regions ( obligation. predicate . self_ty ( ) ) ) ;
954954
955955 // But if there are inference variables, we have to wait until it's resolved.
956956 if self_ty. has_non_region_infer ( ) {
957957 candidates. ambiguous = true ;
958958 return ;
959959 }
960960
961- if let Ok ( layout) = self . tcx ( ) . layout_of ( obligation. param_env . and ( self_ty) )
962- && layout. layout . size ( ) == self . tcx ( ) . data_layout . pointer_size
963- && layout. layout . align ( ) . abi == self . tcx ( ) . data_layout . pointer_align . abi
961+ if let Ok ( layout) = tcx. layout_of ( obligation. param_env . and ( self_ty) )
962+ && layout. layout . is_pointer_like ( & tcx. data_layout )
964963 {
965964 candidates. vec . push ( BuiltinCandidate { has_nested : false } ) ;
966965 }
0 commit comments