diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-01-14 21:21:40 -0500 |
|---|---|---|
| committer | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-02-07 15:07:03 -0500 |
| commit | 7ad48bd4e22aaffa5ac32809b9196fab9c04de2c (patch) | |
| tree | 7f104f51d9c3cc783c369204a97dff84d4022eb0 /compiler/rustc_trait_selection/src/traits | |
| parent | 3602e0e262275c898966c45553c406c4873472fe (diff) | |
Change inference var check to be in project_type
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
3 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 9a7d06ef640..b594723aa0b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2470,7 +2470,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let projection_ty = ty::ProjectionTy { // `T` substs: self.tcx.mk_substs_trait( - trait_ref.self_ty().skip_binder(), + trait_pred.self_ty().skip_binder(), &self.fresh_substs_for_item(span, item_def_id)[1..], ), // `Future::Output` diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 5e7d4c8b415..36cc14610cb 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1073,6 +1073,16 @@ fn project<'cx, 'tcx>( return Ok(Projected::Progress(Progress::error(selcx.tcx()))); } + // If the obligation contains any inference types or consts in associated + // type substs, then we don't assemble any candidates. + // This isn't really correct, but otherwise we can end up in a case where + // we constrain inference variables by selecting a single predicate, when + // we need to stay general. See issue #91762. + let (_, predicate_own_substs) = obligation.predicate.trait_ref_and_own_substs(selcx.tcx()); + if predicate_own_substs.iter().any(|g| g.has_infer_types_or_consts()) { + return Err(ProjectionError::TooManyCandidates); + } + let mut candidates = ProjectionCandidateSet::None; // Make sure that the following procedures are kept in order. ParamEnv diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 562535b0fea..47427395b93 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1521,16 +1521,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { infer_predicate.projection_ty }; - // If the obligation contains any inference types or consts in associated - // type substs, then we don't match any projection candidates against it. - // This isn't really correct, but otherwise we can end up in a case where - // we constrain inference variables by selecting a single predicate, when - // we need to stay general. See issue #91762. - let (_, predicate_own_substs) = - obligation.predicate.trait_ref_and_own_substs(self.infcx.tcx); - if predicate_own_substs.iter().any(|g| g.has_infer_types_or_consts()) { - return false; - } self.infcx .at(&obligation.cause, obligation.param_env) .sup(obligation.predicate, infer_projection) |
