Skip to content

Stop bubbling out hidden types from the eval obligation queries #112963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions compiler/rustc_traits/src/evaluate_obligation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers;
use rustc_middle::traits::DefiningAnchor;
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_span::source_map::DUMMY_SP;
use rustc_trait_selection::traits::query::CanonicalPredicateGoal;
Expand All @@ -18,12 +17,8 @@ fn evaluate_obligation<'tcx>(
) -> Result<EvaluationResult, OverflowError> {
assert!(!tcx.next_trait_solver_globally());
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
// HACK This bubble is required for this tests to pass:
// impl-trait/issue99642.rs
let (ref infcx, goal, _canonical_inference_vars) = tcx
.infer_ctxt()
.with_opaque_type_inference(DefiningAnchor::Bubble)
.build_with_canonical(DUMMY_SP, &canonical_goal);
let (ref infcx, goal, _canonical_inference_vars) =
tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical_goal);
debug!("evaluate_obligation: goal={:#?}", goal);
let ParamEnvAnd { param_env, value: predicate } = goal;

Expand Down
14 changes: 4 additions & 10 deletions compiler/rustc_traits/src/type_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use rustc_infer::infer::canonical::{Canonical, QueryResponse};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers;
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::{ParamEnvAnd, Predicate};
use rustc_trait_selection::infer::InferCtxtBuilderExt;
Expand Down Expand Up @@ -106,15 +105,10 @@ fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
// HACK This bubble is required for this test to pass:
// impl-trait/issue-99642.rs
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
&canonicalized,
|ocx, key| {
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
Ok(())
},
)
tcx.infer_ctxt().enter_canonical_trait_query(&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,
Expand Down