Skip to content

Commit 32f6878

Browse files
committed
Stop bubbling out hidden types from the eval obligation queries
1 parent f715e43 commit 32f6878

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

compiler/rustc_trait_selection/src/infer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub trait InferCtxtExt<'tcx> {
4646
param_env: ty::ParamEnv<'tcx>,
4747
) -> traits::EvaluationResult;
4848
}
49+
4950
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
5051
fn type_is_copy_modulo_regions(
5152
&self,

compiler/rustc_traits/src/evaluate_obligation.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_infer::infer::{DefiningAnchor, TyCtxtInferExt};
1+
use rustc_infer::infer::TyCtxtInferExt;
22
use rustc_middle::ty::query::Providers;
33
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
44
use rustc_span::source_map::DUMMY_SP;
@@ -16,12 +16,8 @@ fn evaluate_obligation<'tcx>(
1616
canonical_goal: CanonicalPredicateGoal<'tcx>,
1717
) -> Result<EvaluationResult, OverflowError> {
1818
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
19-
// HACK This bubble is required for this tests to pass:
20-
// impl-trait/issue99642.rs
21-
let (ref infcx, goal, _canonical_inference_vars) = tcx
22-
.infer_ctxt()
23-
.with_opaque_type_inference(DefiningAnchor::Bubble)
24-
.build_with_canonical(DUMMY_SP, &canonical_goal);
19+
let (ref infcx, goal, _canonical_inference_vars) =
20+
tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical_goal);
2521
debug!("evaluate_obligation: goal={:#?}", goal);
2622
let ParamEnvAnd { param_env, value: predicate } = goal;
2723

compiler/rustc_traits/src/type_op.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_hir as hir;
22
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
3-
use rustc_infer::infer::{DefiningAnchor, TyCtxtInferExt};
3+
use rustc_infer::infer::TyCtxtInferExt;
44
use rustc_infer::traits::ObligationCauseCode;
55
use rustc_middle::ty::query::Providers;
66
use rustc_middle::ty::{self, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable};
@@ -212,15 +212,10 @@ fn type_op_prove_predicate<'tcx>(
212212
tcx: TyCtxt<'tcx>,
213213
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
214214
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
215-
// HACK This bubble is required for this test to pass:
216-
// impl-trait/issue-99642.rs
217-
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
218-
&canonicalized,
219-
|ocx, key| {
220-
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
221-
Ok(())
222-
},
223-
)
215+
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
216+
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
217+
Ok(())
218+
})
224219
}
225220

226221
/// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,

tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
error[E0275]: overflow evaluating the requirement `Foo: Sized`
1+
error[E0275]: overflow evaluating the requirement `<fn() -> Foo {foo} as FnOnce<()>>::Output == fn() -> Foo {foo}`
22
--> $DIR/issue-53398-cyclic-types.rs:5:13
33
|
44
LL | fn foo() -> Foo {
55
| ^^^
6-
|
7-
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)
8-
= note: required because it appears within the type `fn() -> Foo {foo}`
96

107
error: aborting due to previous error
118

0 commit comments

Comments
 (0)