Skip to content

Commit 91b8b9b

Browse files
authored
Rollup merge of rust-lang#99714 - ouz-a:issue_57961, r=oli-obk
Fix regression introduced with rust-lang#99383 Fixes rust-lang#99642
2 parents 48316df + 8716eae commit 91b8b9b

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

compiler/rustc_traits/src/evaluate_obligation.rs

+4-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,9 @@ 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+
// HACK This bubble is required for this tests to pass:
20+
// impl-trait/issue99642.rs
21+
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_with_canonical(
2022
DUMMY_SP,
2123
&canonical_goal,
2224
|ref infcx, goal, _canonical_inference_vars| {

compiler/rustc_traits/src/type_op.rs

+10-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,15 @@ 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+
// HACK This bubble is required for this test to pass:
262+
// impl-trait/issue-99642.rs
263+
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
264+
&canonicalized,
265+
|infcx, fulfill_cx, key| {
266+
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
267+
Ok(())
268+
},
269+
)
265270
}
266271

267272
/// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
type Opq = impl Sized;
5+
fn test() -> impl Iterator<Item = Opq> {
6+
Box::new(0..) as Box<dyn Iterator<Item = _>>
7+
}
8+
fn main(){}

src/test/ui/impl-trait/issue-99642.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// check-pass
2+
3+
fn test() -> impl Iterator<Item = impl Sized> {
4+
Box::new(0..) as Box<dyn Iterator<Item = _>>
5+
}
6+
7+
fn main() {}

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)