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
14 changes: 1 addition & 13 deletions compiler/rustc_trait_selection/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_middle::infer::canonical::{
Canonical, CanonicalQueryInput, CanonicalQueryResponse, QueryResponse,
};
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast};
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, Upcast};
use rustc_span::DUMMY_SP;
use tracing::instrument;

Expand All @@ -31,19 +31,7 @@ impl<'tcx> InferCtxt<'tcx> {

fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
let ty = self.resolve_vars_if_possible(ty);

// FIXME(#132279): This should be removed as it causes us to incorrectly
// handle opaques in their defining scope, and stalled coroutines.
if !self.next_trait_solver() && !(param_env, ty).has_infer() && !ty.has_coroutines() {
return self.tcx.type_is_copy_modulo_regions(self.typing_env(param_env), ty);
}

let copy_def_id = self.tcx.require_lang_item(LangItem::Copy, DUMMY_SP);

// This can get called from typeck (by euv), and `moves_by_default`
// rightly refuses to work with inference variables, but
// moves_by_default has a cache, which we want to use in other
// cases.
traits::type_known_to_meet_bound_modulo_regions(self, param_env, ty, copy_def_id)
}

Expand Down
40 changes: 40 additions & 0 deletions tests/ui/coroutine/copy-fast-path-query-cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//@ edition: 2024
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ check-pass

// Regression test for #146813. We previously used a pseudo-canonical
// query during HIR typeck which caused a query cycle when looking at the
// witness of a coroutine.

use std::future::Future;

trait ConnectMiddleware {}

trait ConnectHandler: Sized {
fn with<M>(self, _: M) -> impl ConnectHandler
where
M: ConnectMiddleware,
{
LayeredConnectHandler
}
}

struct LayeredConnectHandler;
impl ConnectHandler for LayeredConnectHandler {}
impl<F> ConnectHandler for F where F: FnOnce() {}

impl<F, Fut> ConnectMiddleware for F
where
F: FnOnce() -> Fut,
Fut: Future<Output = ()> + Send,
{
}

pub async fn fails() {
{ || {} }
.with(async || ())
.with(async || ())
.with(async || ());
}
fn main() {}
19 changes: 0 additions & 19 deletions tests/ui/lang-items/missing-copy-lang-item-issue-19660.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/lang-items/missing-copy-lang-item-issue-19660.stderr

This file was deleted.

Loading