Skip to content
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
7 changes: 7 additions & 0 deletions compiler/rustc_traits/src/coroutine_witnesses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ pub(crate) fn coroutine_hidden_types<'tcx>(
)
}

// FIXME: The assumptions are only used in the old solver when `-Zhigher-ranked-assumptions`
// is true. `-Zhigher-ranked-assumptions` is superseded by `assumptions-on-binders`.
// We can remove this function soon.
fn compute_assumptions<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
bound_tys: &'tcx ty::List<Ty<'tcx>>,
) -> &'tcx ty::List<ty::ArgOutlivesPredicate<'tcx>> {
if tcx.next_trait_solver_globally() || !tcx.sess.opts.unstable_opts.higher_ranked_assumptions {
return &ty::List::empty();
}

let infcx = tcx
.infer_ctxt()
.build(ty::TypingMode::Typeck { defining_opaque_types_and_generators: ty::List::empty() });
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/traits/next-solver/coroutine_query_cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ compile-flags: -Znext-solver
//@ edition: 2024
//@ check-pass

// Regression test for trait-system-refactor-initiative#282
// Previously we always computed higher ranked assumptions for coroutines.
// It led to query cycle in recursive functions like the one below.
// Thoses assumptions are not used in the next solver and
// the functionality is superseded by `assumptions-on-binders`.

fn go() -> impl Future + Send + 'static {
spawn(async {
go().await;
})
}
fn spawn(_: impl Future + Send + 'static) -> impl Future {
async {}
}

fn main() {}
Loading