Stop bubbling out hidden types from the eval obligation queries

This commit is contained in:
Oli Scherer 2023-02-10 10:26:26 +00:00
parent 54d6738a8d
commit c996cfec80
2 changed files with 6 additions and 17 deletions

View File

@ -1,6 +1,5 @@
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::traits::DefiningAnchor;
use rustc_middle::ty::{ParamEnvAnd, TyCtxt}; use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_span::source_map::DUMMY_SP; use rustc_span::source_map::DUMMY_SP;
use rustc_trait_selection::traits::query::CanonicalPredicateGoal; use rustc_trait_selection::traits::query::CanonicalPredicateGoal;
@ -18,12 +17,8 @@ fn evaluate_obligation<'tcx>(
) -> Result<EvaluationResult, OverflowError> { ) -> Result<EvaluationResult, OverflowError> {
assert!(!tcx.next_trait_solver_globally()); assert!(!tcx.next_trait_solver_globally());
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal); debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
// HACK This bubble is required for this tests to pass: let (ref infcx, goal, _canonical_inference_vars) =
// impl-trait/issue99642.rs tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical_goal);
let (ref infcx, goal, _canonical_inference_vars) = tcx
.infer_ctxt()
.with_opaque_type_inference(DefiningAnchor::Bubble)
.build_with_canonical(DUMMY_SP, &canonical_goal);
debug!("evaluate_obligation: goal={:#?}", goal); debug!("evaluate_obligation: goal={:#?}", goal);
let ParamEnvAnd { param_env, value: predicate } = goal; let ParamEnvAnd { param_env, value: predicate } = goal;

View File

@ -2,7 +2,6 @@ use rustc_infer::infer::canonical::{Canonical, QueryResponse};
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::DefiningAnchor;
use rustc_middle::ty::{FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable}; use rustc_middle::ty::{FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable};
use rustc_middle::ty::{ParamEnvAnd, Predicate}; use rustc_middle::ty::{ParamEnvAnd, Predicate};
use rustc_trait_selection::infer::InferCtxtBuilderExt; use rustc_trait_selection::infer::InferCtxtBuilderExt;
@ -106,15 +105,10 @@ fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
// HACK This bubble is required for this test to pass: tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
// impl-trait/issue-99642.rs type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query( Ok(())
&canonicalized, })
|ocx, key| {
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
Ok(())
},
)
} }
/// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors, /// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,