Skip to content

Commit 86455bf

Browse files
committed
Address review feedback
1 parent 43d183d commit 86455bf

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

  • compiler
    • rustc_hir_analysis/src/hir_ty_lowering
    • rustc_hir_typeck/src/method

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
12671267
/// associated item, this function eliminates any traits which are a
12681268
/// supertrait of another candidate trait.
12691269
///
1270+
/// This is the type-level analogue of
1271+
/// `rustc_hir_typeck::method::probe::ProbeContext::collapse_candidates_to_subtrait_pick`;
1272+
/// keep both implementations in sync.
1273+
///
12701274
/// This implements RFC #3624.
12711275
fn collapse_candidates_to_subtrait_pick(
12721276
&self,
@@ -1291,8 +1295,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
12911295
continue;
12921296
}
12931297

1294-
// This pick is not a supertrait of the `child_pick`.
1295-
// Check if it's a subtrait of the `child_pick`, instead.
1298+
// This candidate is not a supertrait of the `child_trait`.
1299+
// Check if it's a subtrait of the `child_trait`, instead.
12961300
// If it is, then it must have been a subtrait of every
12971301
// other pick we've eliminated at this point. It will
12981302
// take over at this point.
@@ -1305,7 +1309,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13051309
continue;
13061310
}
13071311

1308-
// `child_pick` is not a supertrait of this pick.
1312+
// Neither `child_trait` or the current candidate are
1313+
// supertraits of each other.
13091314
// Don't bail here, since we may be comparing two supertraits
13101315
// of a common subtrait. These two supertraits won't be related
13111316
// at all, but we will pick them up next round when we find their
@@ -1318,7 +1323,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13181323
remaining_candidates = next_round;
13191324
} else {
13201325
// Otherwise, we must have at least two candidates which
1321-
// are not related to each other at all.;
1326+
// are not related to each other at all.
13221327
return None;
13231328
}
13241329
}
@@ -1362,8 +1367,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13621367
if let Some(bound2) = matching_candidates.next() {
13631368
let all_matching_candidates: Vec<_> =
13641369
[bound1, bound2].into_iter().chain(matching_candidates).collect();
1365-
if let Some(bound) =
1366-
self.collapse_candidates_to_subtrait_pick(&all_matching_candidates)
1370+
if let Some(bound) = self.collapse_candidates_to_subtrait_pick(&all_matching_candidates)
13671371
{
13681372
return Ok(bound);
13691373
}

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
23592359
/// multiple conflicting picks if there is one pick whose trait container is a subtrait
23602360
/// of the trait containers of all of the other picks.
23612361
///
2362+
/// This is the method-probe analogue of
2363+
/// `rustc_hir_analysis::hir_ty_lowering::HirTyLowerer::collapse_candidates_to_subtrait_pick`;
2364+
/// keep both implementations in sync.
2365+
///
23622366
/// This implements RFC #3624.
23632367
fn collapse_candidates_to_subtrait_pick(
23642368
&self,

0 commit comments

Comments
 (0)