@@ -1045,12 +1045,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1045
1045
1046
1046
fn pick_core ( & self ) -> Option < PickResult < ' tcx > > {
1047
1047
// Pick stable methods only first, and consider unstable candidates if not found.
1048
- self . pick_all_method ( Some ( & mut vec ! [ ] ) ) . or_else ( || self . pick_all_method ( None ) )
1048
+ self . pick_all_method ( Some ( vec ! [ ] ) ) . or_else ( || self . pick_all_method ( None ) )
1049
1049
}
1050
1050
1051
1051
fn pick_all_method (
1052
1052
& self ,
1053
- mut unstable_candidates : Option < & mut Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1053
+ mut unstable_candidates : Option < Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1054
1054
) -> Option < PickResult < ' tcx > > {
1055
1055
self . steps
1056
1056
. iter ( )
@@ -1071,30 +1071,23 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1071
1071
. unwrap_or_else ( |_| {
1072
1072
span_bug ! ( self . span, "{:?} was applicable but now isn't?" , step. self_ty)
1073
1073
} ) ;
1074
- self . pick_by_value_method ( step, self_ty, unstable_candidates. as_deref_mut ( ) )
1074
+ self . pick_by_value_method ( step, self_ty, & mut unstable_candidates) . or_else ( || {
1075
+ self . pick_autorefd_method (
1076
+ step,
1077
+ self_ty,
1078
+ hir:: Mutability :: Not ,
1079
+ & mut unstable_candidates,
1080
+ )
1075
1081
. or_else ( || {
1076
1082
self . pick_autorefd_method (
1077
1083
step,
1078
1084
self_ty,
1079
- hir:: Mutability :: Not ,
1080
- unstable_candidates. as_deref_mut ( ) ,
1085
+ hir:: Mutability :: Mut ,
1086
+ & mut unstable_candidates,
1081
1087
)
1082
- . or_else ( || {
1083
- self . pick_autorefd_method (
1084
- step,
1085
- self_ty,
1086
- hir:: Mutability :: Mut ,
1087
- unstable_candidates. as_deref_mut ( ) ,
1088
- )
1089
- } )
1090
- . or_else ( || {
1091
- self . pick_const_ptr_method (
1092
- step,
1093
- self_ty,
1094
- unstable_candidates. as_deref_mut ( ) ,
1095
- )
1096
- } )
1097
1088
} )
1089
+ . or_else ( || self . pick_const_ptr_method ( step, self_ty, & mut unstable_candidates) )
1090
+ } )
1098
1091
} )
1099
1092
}
1100
1093
@@ -1108,7 +1101,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1108
1101
& self ,
1109
1102
step : & CandidateStep < ' tcx > ,
1110
1103
self_ty : Ty < ' tcx > ,
1111
- unstable_candidates : Option < & mut Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1104
+ unstable_candidates : & mut Option < Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1112
1105
) -> Option < PickResult < ' tcx > > {
1113
1106
if step. unsize {
1114
1107
return None ;
@@ -1137,7 +1130,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1137
1130
step : & CandidateStep < ' tcx > ,
1138
1131
self_ty : Ty < ' tcx > ,
1139
1132
mutbl : hir:: Mutability ,
1140
- unstable_candidates : Option < & mut Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1133
+ unstable_candidates : & mut Option < Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1141
1134
) -> Option < PickResult < ' tcx > > {
1142
1135
let tcx = self . tcx ;
1143
1136
@@ -1162,7 +1155,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1162
1155
& self ,
1163
1156
step : & CandidateStep < ' tcx > ,
1164
1157
self_ty : Ty < ' tcx > ,
1165
- unstable_candidates : Option < & mut Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1158
+ unstable_candidates : & mut Option < Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1166
1159
) -> Option < PickResult < ' tcx > > {
1167
1160
// Don't convert an unsized reference to ptr
1168
1161
if step. unsize {
@@ -1186,7 +1179,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1186
1179
fn pick_method (
1187
1180
& self ,
1188
1181
self_ty : Ty < ' tcx > ,
1189
- mut unstable_candidates : Option < & mut Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1182
+ unstable_candidates : & mut Option < Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1190
1183
) -> Option < PickResult < ' tcx > > {
1191
1184
debug ! ( "pick_method(self_ty={})" , self . ty_to_string( self_ty) ) ;
1192
1185
@@ -1200,7 +1193,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1200
1193
self_ty,
1201
1194
candidates,
1202
1195
& mut possibly_unsatisfied_predicates,
1203
- unstable_candidates. as_deref_mut ( ) ,
1196
+ unstable_candidates,
1204
1197
) ;
1205
1198
if let Some ( pick) = res {
1206
1199
return Some ( pick) ;
@@ -1209,7 +1202,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1209
1202
1210
1203
if self . private_candidate . get ( ) . is_none ( ) {
1211
1204
if let Some ( Ok ( pick) ) =
1212
- self . consider_candidates ( self_ty, & self . private_candidates , & mut vec ! [ ] , None )
1205
+ self . consider_candidates ( self_ty, & self . private_candidates , & mut vec ! [ ] , & mut None )
1213
1206
{
1214
1207
self . private_candidate . set ( Some ( ( pick. item . kind . as_def_kind ( ) , pick. item . def_id ) ) ) ;
1215
1208
}
@@ -1232,7 +1225,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1232
1225
Option < ty:: Predicate < ' tcx > > ,
1233
1226
Option < ObligationCause < ' tcx > > ,
1234
1227
) > ,
1235
- mut unstable_candidates : Option < & mut Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1228
+ unstable_candidates : & mut Option < Vec < ( Candidate < ' tcx > , Symbol ) > > ,
1236
1229
) -> Option < PickResult < ' tcx > > {
1237
1230
let mut applicable_candidates: Vec < _ > = candidates
1238
1231
. iter ( )
@@ -1252,7 +1245,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1252
1245
}
1253
1246
}
1254
1247
1255
- if let Some ( uc) = & mut unstable_candidates {
1248
+ if let Some ( uc) = unstable_candidates {
1256
1249
applicable_candidates. retain ( |& ( candidate, _) | {
1257
1250
if let stability:: EvalResult :: Deny { feature, .. } =
1258
1251
self . tcx . eval_stability ( candidate. item . def_id , None , self . span , None )
@@ -1270,10 +1263,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1270
1263
}
1271
1264
1272
1265
applicable_candidates. pop ( ) . map ( |( probe, status) | match status {
1273
- ProbeResult :: Match => {
1274
- Ok ( probe
1275
- . to_unadjusted_pick ( self_ty , unstable_candidates . cloned ( ) . unwrap_or_default ( ) ) )
1276
- }
1266
+ ProbeResult :: Match => Ok ( probe . to_unadjusted_pick (
1267
+ self_ty ,
1268
+ unstable_candidates . as_ref ( ) . cloned ( ) . unwrap_or_default ( ) ,
1269
+ ) ) ,
1277
1270
ProbeResult :: NoMatch | ProbeResult :: BadReturnType => Err ( MethodError :: BadReturnType ) ,
1278
1271
} )
1279
1272
}
0 commit comments