@@ -97,7 +97,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
97
97
} else if lang_items. tuple_trait ( ) == Some ( def_id) {
98
98
self . assemble_candidate_for_tuple ( obligation, & mut candidates) ;
99
99
} 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) ;
101
101
} else if lang_items. fn_ptr_trait ( ) == Some ( def_id) {
102
102
self . assemble_candidates_for_fn_ptr_trait ( obligation, & mut candidates) ;
103
103
} else {
@@ -942,25 +942,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
942
942
}
943
943
}
944
944
945
- fn assemble_candidate_for_ptr_sized (
945
+ fn assemble_candidate_for_pointer_like (
946
946
& mut self ,
947
947
obligation : & TraitObligation < ' tcx > ,
948
948
candidates : & mut SelectionCandidateSet < ' tcx > ,
949
949
) {
950
950
// 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 ( ) ) ) ;
954
954
955
955
// But if there are inference variables, we have to wait until it's resolved.
956
956
if self_ty. has_non_region_infer ( ) {
957
957
candidates. ambiguous = true ;
958
958
return ;
959
959
}
960
960
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 )
964
963
{
965
964
candidates. vec . push ( BuiltinCandidate { has_nested : false } ) ;
966
965
}
0 commit comments