diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-10-30 20:30:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-30 20:30:27 +0200 |
| commit | 06bb1ff1b58c8663493d2c3c8f3eee7a0cce46cc (patch) | |
| tree | ebf8f663487f3823c6fd21d7abb8278355a77dc0 /compiler/rustc_trait_selection/src | |
| parent | 1a1f525bb0d9897673b2445122ffd6f7aa265c9e (diff) | |
| parent | 9a0a622a042d0ed04ad349d8bb778e40dd417a16 (diff) | |
| download | rust-06bb1ff1b58c8663493d2c3c8f3eee7a0cce46cc.tar.gz rust-06bb1ff1b58c8663493d2c3c8f3eee7a0cce46cc.zip | |
Rollup merge of #90375 - yanok:master, r=lcnr
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.
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 5 |
1 files changed, 3 insertions, 2 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..60676ad3f4f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1547,8 +1547,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Check if a bound would previously have been removed when normalizing // 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(); + let is_global = |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. |
