Skip to content

Commit 6a21237

Browse files
authored
Rollup merge of rust-lang#108285 - BoxyUwU:remove_pick_stable_before_unstable_flag, r=oli-obk
remove unstable `pick_stable_methods_before_any_unstable` flag This flag was only added in rust-lang#90329 in case there was any issue with the impl so that it would be easy to tell nightly users to use the flag to disable the new logic to fix their code. It's now been enabled for two years and also I can't find any issues corresponding to this new functionality? This flag made it way harder to understand how this code works so it would be nice to remove it and simplify what's going on. cc `@nbdd0121` r? `@oli-obk`
2 parents 7dcf7fe + 4f2001a commit 6a21237

File tree

4 files changed

+178
-234
lines changed

4 files changed

+178
-234
lines changed

compiler/rustc_hir_typeck/src/method/probe.rs

+2-54
Original file line numberDiff line numberDiff line change
@@ -1095,17 +1095,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
10951095
}
10961096

10971097
fn pick_core(&self) -> Option<PickResult<'tcx>> {
1098-
let pick = self.pick_all_method(Some(&mut vec![]));
1099-
1100-
// In this case unstable picking is done by `pick_method`.
1101-
if !self.tcx.sess.opts.unstable_opts.pick_stable_methods_before_any_unstable {
1102-
return pick;
1103-
}
1104-
1105-
if pick.is_none() {
1106-
return self.pick_all_method(None);
1107-
}
1108-
pick
1098+
// Pick stable methods only first, and consider unstable candidates if not found.
1099+
self.pick_all_method(Some(&mut vec![])).or_else(|| self.pick_all_method(None))
11091100
}
11101101

11111102
fn pick_all_method(
@@ -1244,54 +1235,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12441235
})
12451236
}
12461237

1247-
fn pick_method_with_unstable(&self, self_ty: Ty<'tcx>) -> Option<PickResult<'tcx>> {
1248-
debug!("pick_method_with_unstable(self_ty={})", self.ty_to_string(self_ty));
1249-
1250-
let mut possibly_unsatisfied_predicates = Vec::new();
1251-
1252-
for (kind, candidates) in
1253-
&[("inherent", &self.inherent_candidates), ("extension", &self.extension_candidates)]
1254-
{
1255-
debug!("searching {} candidates", kind);
1256-
let res = self.consider_candidates(
1257-
self_ty,
1258-
candidates,
1259-
&mut possibly_unsatisfied_predicates,
1260-
Some(&mut vec![]),
1261-
);
1262-
if res.is_some() {
1263-
return res;
1264-
}
1265-
}
1266-
1267-
for (kind, candidates) in
1268-
&[("inherent", &self.inherent_candidates), ("extension", &self.extension_candidates)]
1269-
{
1270-
debug!("searching unstable {kind} candidates");
1271-
let res = self.consider_candidates(
1272-
self_ty,
1273-
candidates,
1274-
&mut possibly_unsatisfied_predicates,
1275-
None,
1276-
);
1277-
if res.is_some() {
1278-
return res;
1279-
}
1280-
}
1281-
1282-
self.unsatisfied_predicates.borrow_mut().extend(possibly_unsatisfied_predicates);
1283-
None
1284-
}
1285-
12861238
fn pick_method(
12871239
&self,
12881240
self_ty: Ty<'tcx>,
12891241
mut unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
12901242
) -> Option<PickResult<'tcx>> {
1291-
if !self.tcx.sess.opts.unstable_opts.pick_stable_methods_before_any_unstable {
1292-
return self.pick_method_with_unstable(self_ty);
1293-
}
1294-
12951243
debug!("pick_method(self_ty={})", self.ty_to_string(self_ty));
12961244

12971245
let mut possibly_unsatisfied_predicates = Vec::new();

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ fn test_unstable_options_tracking_hash() {
776776
tracked!(packed_bundled_libs, true);
777777
tracked!(panic_abort_tests, true);
778778
tracked!(panic_in_drop, PanicStrategy::Abort);
779-
tracked!(pick_stable_methods_before_any_unstable, false);
780779
tracked!(plt, Some(true));
781780
tracked!(polonius, true);
782781
tracked!(precise_enum_drop_elaboration, false);

compiler/rustc_session/src/options.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1567,8 +1567,6 @@ options! {
15671567
"parse only; do not compile, assemble, or link (default: no)"),
15681568
perf_stats: bool = (false, parse_bool, [UNTRACKED],
15691569
"print some performance-related statistics (default: no)"),
1570-
pick_stable_methods_before_any_unstable: bool = (true, parse_bool, [TRACKED],
1571-
"try to pick stable methods first before picking any unstable methods (default: yes)"),
15721570
plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
15731571
"whether to use the PLT when calling into shared libraries;
15741572
only has effect for PIC code on systems with ELF binaries

0 commit comments

Comments
 (0)