Skip to content

Commit 042018d

Browse files
committed
respond to review
1 parent 744c670 commit 042018d

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

compiler/rustc_trait_selection/src/traits/effects.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,24 @@ fn evaluate_host_effect_for_copy_clone_goal<'tcx>(
368368

369369
// only when `coroutine_clone` is enabled and the coroutine is movable
370370
// impl Copy/Clone for Coroutine where T: Copy/Clone forall T in (upvars, witnesses)
371-
ty::Coroutine(def_id, args) => match tcx.coroutine_movability(def_id) {
372-
ty::Movability::Static => Err(EvaluationFailure::NoSolution),
373-
ty::Movability::Movable => {
374-
if tcx.features().coroutine_clone() {
375-
Ok(ty::Binder::dummy(vec![
376-
args.as_coroutine().tupled_upvars_ty(),
377-
Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args),
378-
]))
379-
} else {
380-
Err(EvaluationFailure::NoSolution)
371+
ty::Coroutine(def_id, args) => {
372+
if selcx.should_stall_coroutine(def_id) {
373+
return Err(EvaluationFailure::Ambiguous);
374+
}
375+
match tcx.coroutine_movability(def_id) {
376+
ty::Movability::Static => Err(EvaluationFailure::NoSolution),
377+
ty::Movability::Movable => {
378+
if tcx.features().coroutine_clone() {
379+
Ok(ty::Binder::dummy(vec![
380+
args.as_coroutine().tupled_upvars_ty(),
381+
Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args),
382+
]))
383+
} else {
384+
Err(EvaluationFailure::NoSolution)
385+
}
381386
}
382387
}
383-
},
388+
}
384389

385390
ty::UnsafeBinder(_) => Err(EvaluationFailure::NoSolution),
386391

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
28772877
obligations
28782878
}
28792879

2880-
fn should_stall_coroutine(&self, def_id: DefId) -> bool {
2880+
pub(super) fn should_stall_coroutine(&self, def_id: DefId) -> bool {
28812881
match self.infcx.typing_mode() {
28822882
TypingMode::Analysis { defining_opaque_types_and_generators: stalled_generators } => {
28832883
def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id))

compiler/rustc_type_ir/src/predicate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<I: Interner> ty::Binder<I, TraitRef<I>> {
121121
}
122122

123123
pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause {
124-
self.map_bound(|trait_ref: TraitRef<I>| {
124+
self.map_bound(|trait_ref| {
125125
ty::ClauseKind::HostEffect(HostEffectPredicate { trait_ref, constness })
126126
})
127127
.upcast(cx)

0 commit comments

Comments
 (0)