Skip to content

Commit 4a0473c

Browse files
committed
Bubble up obligations
1 parent 64dc377 commit 4a0473c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

compiler/rustc_traits/src/evaluate_obligation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_infer::infer::TyCtxtInferExt;
1+
use rustc_infer::infer::{DefiningAnchor, TyCtxtInferExt};
22
use rustc_middle::ty::query::Providers;
33
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
44
use rustc_span::source_map::DUMMY_SP;
@@ -16,7 +16,7 @@ fn evaluate_obligation<'tcx>(
1616
canonical_goal: CanonicalPredicateGoal<'tcx>,
1717
) -> Result<EvaluationResult, OverflowError> {
1818
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
19-
tcx.infer_ctxt().enter_with_canonical(
19+
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_with_canonical(
2020
DUMMY_SP,
2121
&canonical_goal,
2222
|ref infcx, goal, _canonical_inference_vars| {

compiler/rustc_traits/src/type_op.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_hir as hir;
22
use rustc_hir::def_id::DefId;
33
use rustc_infer::infer::at::ToTrace;
44
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
5-
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
5+
use rustc_infer::infer::{DefiningAnchor, InferCtxt, TyCtxtInferExt};
66
use rustc_infer::traits::TraitEngineExt as _;
77
use rustc_middle::ty::query::Providers;
88
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
@@ -258,10 +258,13 @@ fn type_op_prove_predicate<'tcx>(
258258
tcx: TyCtxt<'tcx>,
259259
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
260260
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
261-
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
262-
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
263-
Ok(())
264-
})
261+
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
262+
&canonicalized,
263+
|infcx, fulfill_cx, key| {
264+
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
265+
Ok(())
266+
},
267+
)
265268
}
266269

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

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0275]: overflow evaluating the requirement `<fn() -> Foo {foo} as FnOnce<()>>::Output == fn() -> Foo {foo}`
1+
error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
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`)
68

79
error: aborting due to previous error
810

0 commit comments

Comments
 (0)