about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIlya Yanok <ilya.yanok@gmail.com>2021-10-28 12:49:46 +0000
committerIlya Yanok <ilya.yanok@gmail.com>2021-10-28 12:49:46 +0000
commit6c61db44073ce96176850ea5db5dc99624823d91 (patch)
tree478f38ac81e762825397acec45f5804700e039f1
parent4e0d3973fafdfb1c51011bc74e44257b5e3863f1 (diff)
downloadrust-6c61db44073ce96176850ea5db5dc99624823d91.tar.gz
rust-6c61db44073ce96176850ea5db5dc99624823d91.zip
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.
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index 1b26e38fe0e..8bd842a5e06 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -1548,7 +1548,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
         // the param_env so that it can be given the lowest priority. See
         // #50825 for the motivation for this.
         let is_global =
-            |cand: &ty::PolyTraitRef<'_>| cand.is_known_global() && !cand.has_late_bound_regions();
+            |cand: &ty::PolyTraitRef<'tcx>| cand.is_global(self.infcx.tcx) && !cand.has_late_bound_regions();
 
         // (*) Prefer `BuiltinCandidate { has_nested: false }`, `PointeeCandidate`,
         // and `DiscriminantKindCandidate` to anything else.