Skip to content

Commit 6c61db4

Browse files
committed
Use is_global in candidate_should_be_dropped_in_favor_of
This manifistated in #90195 with compiler being unable to keep one candidate for a trait impl, if where is a global impl and more than one trait bound in the where clause. Before #87280 `candidate_should_be_dropped_in_favor_of` was using `TypeFoldable::is_global()` that was enough to discard the two `ParamCandidate`s. But #87280 changed it to use `TypeFoldable::is_known_global()` instead, which is pessimistic, so now the compiler drops the global impl instead (because `is_known_global` is not sure) and then can't decide between the two `ParamCandidate`s. Switching it to use `is_global` again solves the issue. Fixes #90195.
1 parent 4e0d397 commit 6c61db4

File tree

1 file changed

+1
-1
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+1
-1
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15481548
// the param_env so that it can be given the lowest priority. See
15491549
// #50825 for the motivation for this.
15501550
let is_global =
1551-
|cand: &ty::PolyTraitRef<'_>| cand.is_known_global() && !cand.has_late_bound_regions();
1551+
|cand: &ty::PolyTraitRef<'tcx>| cand.is_global(self.infcx.tcx) && !cand.has_late_bound_regions();
15521552

15531553
// (*) Prefer `BuiltinCandidate { has_nested: false }`, `PointeeCandidate`,
15541554
// and `DiscriminantKindCandidate` to anything else.

0 commit comments

Comments
 (0)