Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9676755

Browse files
authoredJun 9, 2025··
Auto merge of #141762 - compiler-errors:witnesser, r=<try>
[experimental] Make witnesses more eager r? lcnr
2 parents 14863ea + 5862717 commit 9676755

File tree

19 files changed

+200
-183
lines changed

19 files changed

+200
-183
lines changed
 

‎compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
161161
// Resume type defaults to `()` if the coroutine has no argument.
162162
let resume_ty = liberated_sig.inputs().get(0).copied().unwrap_or(tcx.types.unit);
163163

164-
// In the new solver, we can just instantiate this eagerly
165-
// with the witness. This will ensure that goals that don't need
166-
// to stall on interior types will get processed eagerly.
167-
let interior = if self.next_trait_solver() {
168-
Ty::new_coroutine_witness(tcx, expr_def_id.to_def_id(), parent_args)
169-
} else {
170-
self.next_ty_var(expr_span)
171-
};
172-
173-
self.deferred_coroutine_interiors.borrow_mut().push((expr_def_id, interior));
164+
let interior = Ty::new_coroutine_witness(tcx, expr_def_id.to_def_id(), parent_args);
174165

175166
// Coroutines that come from coroutine closures have not yet determined
176167
// their kind ty, so make a fresh infer var which will be constrained

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -628,50 +628,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
628628
// trigger query cycle ICEs, as doing so requires MIR.
629629
self.select_obligations_where_possible(|_| {});
630630

631-
let coroutines = std::mem::take(&mut *self.deferred_coroutine_interiors.borrow_mut());
632-
debug!(?coroutines);
633-
634-
let mut obligations = vec![];
635-
636-
if !self.next_trait_solver() {
637-
for &(coroutine_def_id, interior) in coroutines.iter() {
638-
debug!(?coroutine_def_id);
639-
640-
// Create the `CoroutineWitness` type that we will unify with `interior`.
641-
let args = ty::GenericArgs::identity_for_item(
642-
self.tcx,
643-
self.tcx.typeck_root_def_id(coroutine_def_id.to_def_id()),
644-
);
645-
let witness =
646-
Ty::new_coroutine_witness(self.tcx, coroutine_def_id.to_def_id(), args);
647-
648-
// Unify `interior` with `witness` and collect all the resulting obligations.
649-
let span = self.tcx.hir_body_owned_by(coroutine_def_id).value.span;
650-
let ty::Infer(ty::InferTy::TyVar(_)) = interior.kind() else {
651-
span_bug!(span, "coroutine interior witness not infer: {:?}", interior.kind())
652-
};
653-
let ok = self
654-
.at(&self.misc(span), self.param_env)
655-
// Will never define opaque types, as all we do is instantiate a type variable.
656-
.eq(DefineOpaqueTypes::Yes, interior, witness)
657-
.expect("Failed to unify coroutine interior type");
658-
659-
obligations.extend(ok.obligations);
660-
}
661-
}
631+
let ty::TypingMode::Analysis { defining_opaque_types_and_generators } = self.typing_mode()
632+
else {
633+
bug!();
634+
};
662635

663-
if !coroutines.is_empty() {
664-
obligations.extend(
636+
if defining_opaque_types_and_generators
637+
.iter()
638+
.any(|def_id| self.tcx.is_coroutine(def_id.to_def_id()))
639+
{
640+
self.typeck_results.borrow_mut().coroutine_stalled_predicates.extend(
665641
self.fulfillment_cx
666642
.borrow_mut()
667-
.drain_stalled_obligations_for_coroutines(&self.infcx),
643+
.drain_stalled_obligations_for_coroutines(&self.infcx)
644+
.into_iter()
645+
.map(|o| (o.predicate, o.cause)),
668646
);
669647
}
670-
671-
self.typeck_results
672-
.borrow_mut()
673-
.coroutine_stalled_predicates
674-
.extend(obligations.into_iter().map(|o| (o.predicate, o.cause)));
675648
}
676649

677650
#[instrument(skip(self), level = "debug")]

‎compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ pub(crate) struct TypeckRootCtxt<'tcx> {
6363

6464
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, HirId)>>,
6565

66-
pub(super) deferred_coroutine_interiors: RefCell<Vec<(LocalDefId, Ty<'tcx>)>>,
67-
6866
pub(super) deferred_repeat_expr_checks:
6967
RefCell<Vec<(&'tcx hir::Expr<'tcx>, Ty<'tcx>, ty::Const<'tcx>)>>,
7068

@@ -103,7 +101,6 @@ impl<'tcx> TypeckRootCtxt<'tcx> {
103101
deferred_cast_checks: RefCell::new(Vec::new()),
104102
deferred_transmute_checks: RefCell::new(Vec::new()),
105103
deferred_asm_checks: RefCell::new(Vec::new()),
106-
deferred_coroutine_interiors: RefCell::new(Vec::new()),
107104
deferred_repeat_expr_checks: RefCell::new(Vec::new()),
108105
diverging_type_vars: RefCell::new(Default::default()),
109106
infer_var_info: RefCell::new(Default::default()),

‎compiler/rustc_infer/src/infer/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_data_structures::undo_log::{Rollback, UndoLogs};
2020
use rustc_data_structures::unify as ut;
2121
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
2222
use rustc_hir as hir;
23+
use rustc_hir::def::DefKind;
2324
use rustc_hir::def_id::{DefId, LocalDefId};
2425
use rustc_macros::extension;
2526
pub use rustc_macros::{TypeFoldable, TypeVisitable};
@@ -1249,8 +1250,16 @@ impl<'tcx> InferCtxt<'tcx> {
12491250
// to handle them without proper canonicalization. This means we may cause cycle
12501251
// errors and fail to reveal opaques while inside of bodies. We should rename this
12511252
// function and require explicit comments on all use-sites in the future.
1252-
ty::TypingMode::Analysis { defining_opaque_types_and_generators: _ }
1253-
| ty::TypingMode::Borrowck { defining_opaque_types: _ } => {
1253+
ty::TypingMode::Analysis { defining_opaque_types_and_generators } => {
1254+
TypingMode::Analysis {
1255+
defining_opaque_types_and_generators: self.tcx.mk_local_def_ids_from_iter(
1256+
defining_opaque_types_and_generators.iter().filter(|def_id| {
1257+
!matches!(self.tcx.def_kind(*def_id), DefKind::OpaqueTy)
1258+
}),
1259+
),
1260+
}
1261+
}
1262+
ty::TypingMode::Borrowck { defining_opaque_types: _ } => {
12541263
TypingMode::non_body_analysis()
12551264
}
12561265
mode @ (ty::TypingMode::Coherence

‎compiler/rustc_middle/src/ty/context.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -698,17 +698,13 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
698698
self,
699699
defining_anchor: Self::LocalDefId,
700700
) -> Self::LocalDefIds {
701-
if self.next_trait_solver_globally() {
702-
let coroutines_defined_by = self
703-
.nested_bodies_within(defining_anchor)
704-
.iter()
705-
.filter(|def_id| self.is_coroutine(def_id.to_def_id()));
706-
self.mk_local_def_ids_from_iter(
707-
self.opaque_types_defined_by(defining_anchor).iter().chain(coroutines_defined_by),
708-
)
709-
} else {
710-
self.opaque_types_defined_by(defining_anchor)
711-
}
701+
let coroutines_defined_by = self
702+
.nested_bodies_within(defining_anchor)
703+
.iter()
704+
.filter(|def_id| self.is_coroutine(def_id.to_def_id()));
705+
self.mk_local_def_ids_from_iter(
706+
self.opaque_types_defined_by(defining_anchor).iter().chain(coroutines_defined_by),
707+
)
712708
}
713709
}
714710

‎compiler/rustc_trait_selection/src/infer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ impl<'tcx> InferCtxt<'tcx> {
3333
let ty = self.resolve_vars_if_possible(ty);
3434

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

‎compiler/rustc_trait_selection/src/solve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod normalize;
77
mod select;
88

99
pub(crate) use delegate::SolverDelegate;
10-
pub use fulfill::{FulfillmentCtxt, NextSolverError};
10+
pub use fulfill::{FulfillmentCtxt, NextSolverError, StalledOnCoroutines};
1111
pub(crate) use normalize::deeply_normalize_for_diagnostics;
1212
pub use normalize::{
1313
deeply_normalize, deeply_normalize_with_skipped_universes,

‎compiler/rustc_trait_selection/src/solve/fulfill.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ where
264264
&mut self,
265265
infcx: &InferCtxt<'tcx>,
266266
) -> PredicateObligations<'tcx> {
267-
let stalled_generators = match infcx.typing_mode() {
267+
let stalled_coroutines = match infcx.typing_mode() {
268268
TypingMode::Analysis { defining_opaque_types_and_generators } => {
269269
defining_opaque_types_and_generators
270270
}
@@ -274,7 +274,7 @@ where
274274
| TypingMode::PostAnalysis => return Default::default(),
275275
};
276276

277-
if stalled_generators.is_empty() {
277+
if stalled_coroutines.is_empty() {
278278
return Default::default();
279279
}
280280

@@ -285,7 +285,7 @@ where
285285
.visit_proof_tree(
286286
obl.as_goal(),
287287
&mut StalledOnCoroutines {
288-
stalled_generators,
288+
stalled_coroutines,
289289
span: obl.cause.span,
290290
cache: Default::default(),
291291
},
@@ -307,10 +307,10 @@ where
307307
///
308308
/// This function can be also return false positives, which will lead to poor diagnostics
309309
/// so we want to keep this visitor *precise* too.
310-
struct StalledOnCoroutines<'tcx> {
311-
stalled_generators: &'tcx ty::List<LocalDefId>,
312-
span: Span,
313-
cache: DelayedSet<Ty<'tcx>>,
310+
pub struct StalledOnCoroutines<'tcx> {
311+
pub stalled_coroutines: &'tcx ty::List<LocalDefId>,
312+
pub span: Span,
313+
pub cache: DelayedSet<Ty<'tcx>>,
314314
}
315315

316316
impl<'tcx> inspect::ProofTreeVisitor<'tcx> for StalledOnCoroutines<'tcx> {
@@ -340,12 +340,14 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for StalledOnCoroutines<'tcx> {
340340
}
341341

342342
if let ty::CoroutineWitness(def_id, _) = *ty.kind()
343-
&& def_id.as_local().is_some_and(|def_id| self.stalled_generators.contains(&def_id))
343+
&& def_id.as_local().is_some_and(|def_id| self.stalled_coroutines.contains(&def_id))
344344
{
345345
return ControlFlow::Break(());
346+
} else if ty.has_coroutines() {
347+
ty.super_visit_with(self)
348+
} else {
349+
ControlFlow::Continue(())
346350
}
347-
348-
ty.super_visit_with(self)
349351
}
350352
}
351353

‎compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::marker::PhantomData;
33
use rustc_data_structures::obligation_forest::{
44
Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult,
55
};
6+
use rustc_hir::def_id::LocalDefId;
67
use rustc_infer::infer::DefineOpaqueTypes;
78
use rustc_infer::traits::{
89
FromSolverError, PolyTraitObligation, PredicateObligations, ProjectionCacheKey, SelectionError,
@@ -11,7 +12,10 @@ use rustc_infer::traits::{
1112
use rustc_middle::bug;
1213
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
1314
use rustc_middle::ty::error::{ExpectedFound, TypeError};
14-
use rustc_middle::ty::{self, Binder, Const, GenericArgsRef, TypeVisitableExt, TypingMode};
15+
use rustc_middle::ty::{
16+
self, Binder, Const, GenericArgsRef, TypeVisitable, TypeVisitableExt, TypingMode,
17+
};
18+
use rustc_span::DUMMY_SP;
1519
use thin_vec::ThinVec;
1620
use tracing::{debug, debug_span, instrument};
1721

@@ -24,6 +28,7 @@ use super::{
2428
};
2529
use crate::error_reporting::InferCtxtErrorExt;
2630
use crate::infer::{InferCtxt, TyOrConstInferVar};
31+
use crate::solve::StalledOnCoroutines;
2732
use crate::traits::normalize::normalize_with_depth_to;
2833
use crate::traits::project::{PolyProjectionObligation, ProjectionCacheKeyExt as _};
2934
use crate::traits::query::evaluate_obligation::InferCtxtExt;
@@ -166,15 +171,33 @@ where
166171
&mut self,
167172
infcx: &InferCtxt<'tcx>,
168173
) -> PredicateObligations<'tcx> {
169-
let mut processor =
170-
DrainProcessor { removed_predicates: PredicateObligations::new(), infcx };
174+
let stalled_coroutines = match infcx.typing_mode() {
175+
TypingMode::Analysis { defining_opaque_types_and_generators } => {
176+
defining_opaque_types_and_generators
177+
}
178+
TypingMode::Coherence
179+
| TypingMode::Borrowck { defining_opaque_types: _ }
180+
| TypingMode::PostBorrowckAnalysis { defined_opaque_types: _ }
181+
| TypingMode::PostAnalysis => return Default::default(),
182+
};
183+
184+
if stalled_coroutines.is_empty() {
185+
return Default::default();
186+
}
187+
188+
let mut processor = DrainProcessor {
189+
infcx,
190+
removed_predicates: PredicateObligations::new(),
191+
stalled_coroutines,
192+
};
171193
let outcome: Outcome<_, _> = self.predicates.process_obligations(&mut processor);
172194
assert!(outcome.errors.is_empty());
173195
return processor.removed_predicates;
174196

175197
struct DrainProcessor<'a, 'tcx> {
176198
infcx: &'a InferCtxt<'tcx>,
177199
removed_predicates: PredicateObligations<'tcx>,
200+
stalled_coroutines: &'tcx ty::List<LocalDefId>,
178201
}
179202

180203
impl<'tcx> ObligationProcessor for DrainProcessor<'_, 'tcx> {
@@ -183,10 +206,14 @@ where
183206
type OUT = Outcome<Self::Obligation, Self::Error>;
184207

185208
fn needs_process_obligation(&self, pending_obligation: &Self::Obligation) -> bool {
186-
pending_obligation
187-
.stalled_on
188-
.iter()
189-
.any(|&var| self.infcx.ty_or_const_infer_var_changed(var))
209+
self.infcx
210+
.resolve_vars_if_possible(pending_obligation.obligation.predicate)
211+
.visit_with(&mut StalledOnCoroutines {
212+
stalled_coroutines: self.stalled_coroutines,
213+
span: DUMMY_SP,
214+
cache: Default::default(),
215+
})
216+
.is_break()
190217
}
191218

192219
fn process_obligation(

‎compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
820820
}
821821
}
822822

823+
ty::CoroutineWitness(def_id, _) => {
824+
if self.should_stall_coroutine_witness(def_id) {
825+
candidates.ambiguous = true;
826+
} else {
827+
candidates.vec.push(AutoImplCandidate);
828+
}
829+
}
830+
823831
ty::Bool
824832
| ty::Char
825833
| ty::Int(_)
@@ -839,7 +847,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
839847
| ty::Coroutine(..)
840848
| ty::Never
841849
| ty::Tuple(_)
842-
| ty::CoroutineWitness(..)
843850
| ty::UnsafeBinder(_) => {
844851
// Only consider auto impls of unsafe traits when there are
845852
// no unsafe fields.

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,13 +2224,17 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
22242224
}
22252225

22262226
ty::CoroutineWitness(def_id, args) => {
2227-
let hidden_types = rebind_coroutine_witness_types(
2228-
self.infcx.tcx,
2229-
def_id,
2230-
args,
2231-
obligation.predicate.bound_vars(),
2232-
);
2233-
Where(hidden_types)
2227+
if self.should_stall_coroutine_witness(def_id) {
2228+
Ambiguous
2229+
} else {
2230+
let hidden_types = rebind_coroutine_witness_types(
2231+
self.infcx.tcx,
2232+
def_id,
2233+
args,
2234+
obligation.predicate.bound_vars(),
2235+
);
2236+
Where(hidden_types)
2237+
}
22342238
}
22352239

22362240
ty::Closure(_, args) => {
@@ -2856,6 +2860,22 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
28562860

28572861
obligations
28582862
}
2863+
2864+
fn should_stall_coroutine_witness(&self, def_id: DefId) -> bool {
2865+
match self.infcx.typing_mode() {
2866+
TypingMode::Analysis { defining_opaque_types_and_generators: stalled_generators } => {
2867+
if def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id)) {
2868+
return true;
2869+
}
2870+
}
2871+
TypingMode::Coherence
2872+
| TypingMode::PostAnalysis
2873+
| TypingMode::Borrowck { defining_opaque_types: _ }
2874+
| TypingMode::PostBorrowckAnalysis { defined_opaque_types: _ } => {}
2875+
}
2876+
2877+
false
2878+
}
28592879
}
28602880

28612881
fn rebind_coroutine_witness_types<'tcx>(

‎compiler/rustc_type_ir/src/flags.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ bitflags::bitflags! {
130130

131131
/// Does this have any binders with bound vars (e.g. that need to be anonymized)?
132132
const HAS_BINDER_VARS = 1 << 23;
133+
134+
const HAS_TY_CORO = 1 << 24;
133135
}
134136
}
135137

@@ -240,10 +242,12 @@ impl<I: Interner> FlagComputation<I> {
240242
self.add_flags(TypeFlags::HAS_TY_PARAM);
241243
}
242244

243-
ty::Closure(_, args)
244-
| ty::Coroutine(_, args)
245-
| ty::CoroutineClosure(_, args)
246-
| ty::CoroutineWitness(_, args) => {
245+
ty::Closure(_, args) | ty::Coroutine(_, args) | ty::CoroutineClosure(_, args) => {
246+
self.add_args(args.as_slice());
247+
}
248+
249+
ty::CoroutineWitness(_, args) => {
250+
self.add_flags(TypeFlags::HAS_TY_CORO);
247251
self.add_args(args.as_slice());
248252
}
249253

‎compiler/rustc_type_ir/src/visit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
269269
self.has_type_flags(TypeFlags::HAS_TY_OPAQUE)
270270
}
271271

272+
fn has_coroutines(&self) -> bool {
273+
self.has_type_flags(TypeFlags::HAS_TY_CORO)
274+
}
275+
272276
fn references_error(&self) -> bool {
273277
self.has_type_flags(TypeFlags::HAS_ERROR)
274278
}

‎tests/ui/async-await/async-closures/def-path.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ LL | let x = async || {};
55
| -- the expected `async` closure body
66
LL |
77
LL | let () = x();
8-
| ^^ --- this expression has type `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?5t}`
8+
| ^^ --- this expression has type `{static main::{closure#0}::{closure#0}<?16t> upvar_tys=?15t resume_ty=ResumeTy yield_ty=() return_ty=() witness={main::{closure#0}::{closure#0}}}`
99
| |
1010
| expected `async` closure body, found `()`
1111
|
12-
= note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?5t}`
12+
= note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?16t> upvar_tys=?15t resume_ty=ResumeTy yield_ty=() return_ty=() witness={main::{closure#0}::{closure#0}}}`
1313
found unit type `()`
1414

1515
error: aborting due to 1 previous error

‎tests/ui/coroutine/clone-impl.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,36 @@ fn test3() {
4242
let clonable_0: Vec<u32> = Vec::new();
4343
let gen_clone_0 = #[coroutine]
4444
move || {
45-
let v = vec!['a'];
46-
yield;
47-
drop(v);
4845
drop(clonable_0);
4946
};
5047
check_copy(&gen_clone_0);
5148
//~^ ERROR the trait bound `Vec<u32>: Copy` is not satisfied
52-
//~| ERROR the trait bound `Vec<char>: Copy` is not satisfied
5349
check_clone(&gen_clone_0);
5450
}
5551

52+
fn test3_witness() {
53+
let gen_clone_1 = #[coroutine]
54+
move || {
55+
let v = vec!['a'];
56+
yield;
57+
drop(v);
58+
};
59+
check_copy(&gen_clone_1);
60+
//~^ ERROR the trait bound `Vec<char>: Copy` is not satisfied
61+
check_clone(&gen_clone_1);
62+
}
63+
5664
fn test4() {
5765
let clonable_1: Vec<u32> = Vec::new();
5866
let gen_clone_1 = #[coroutine]
5967
move || {
60-
let v = vec!['a'];
61-
/*
62-
let n = NonClone;
63-
drop(n);
64-
*/
6568
yield;
6669
let n = NonClone;
6770
drop(n);
68-
drop(v);
6971
drop(clonable_1);
7072
};
7173
check_copy(&gen_clone_1);
7274
//~^ ERROR the trait bound `Vec<u32>: Copy` is not satisfied
73-
//~| ERROR the trait bound `Vec<char>: Copy` is not satisfied
7475
check_clone(&gen_clone_1);
7576
}
7677

‎tests/ui/coroutine/clone-impl.stderr

Lines changed: 45 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,59 @@
11
error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`
2-
--> $DIR/clone-impl.rs:50:5
2+
--> $DIR/clone-impl.rs:47:16
33
|
44
LL | move || {
55
| ------- within this `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`
66
...
77
LL | check_copy(&gen_clone_0);
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`, the trait `Copy` is not implemented for `Vec<u32>`
8+
| ^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`, the trait `Copy` is not implemented for `Vec<u32>`
99
|
1010
note: captured value does not implement `Copy`
11-
--> $DIR/clone-impl.rs:48:14
11+
--> $DIR/clone-impl.rs:45:14
1212
|
1313
LL | drop(clonable_0);
1414
| ^^^^^^^^^^ has type `Vec<u32>` which does not implement `Copy`
1515
note: required by a bound in `check_copy`
16-
--> $DIR/clone-impl.rs:90:18
16+
--> $DIR/clone-impl.rs:91:18
1717
|
1818
LL | fn check_copy<T: Copy>(_x: &T) {}
1919
| ^^^^ required by this bound in `check_copy`
2020

21-
error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`
22-
--> $DIR/clone-impl.rs:50:5
21+
error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:67:5: 67:12}`
22+
--> $DIR/clone-impl.rs:73:16
2323
|
2424
LL | move || {
25-
| ------- within this `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`
26-
...
27-
LL | check_copy(&gen_clone_0);
28-
| ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:44:5: 44:12}`, the trait `Copy` is not implemented for `Vec<char>`
29-
|
30-
note: coroutine does not implement `Copy` as this value is used across a yield
31-
--> $DIR/clone-impl.rs:46:9
32-
|
33-
LL | let v = vec!['a'];
34-
| - has type `Vec<char>` which does not implement `Copy`
35-
LL | yield;
36-
| ^^^^^ yield occurs here, with `v` maybe used later
37-
note: required by a bound in `check_copy`
38-
--> $DIR/clone-impl.rs:90:18
39-
|
40-
LL | fn check_copy<T: Copy>(_x: &T) {}
41-
| ^^^^ required by this bound in `check_copy`
42-
43-
error[E0277]: the trait bound `Vec<u32>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:59:5: 59:12}`
44-
--> $DIR/clone-impl.rs:71:5
45-
|
46-
LL | move || {
47-
| ------- within this `{coroutine@$DIR/clone-impl.rs:59:5: 59:12}`
25+
| ------- within this `{coroutine@$DIR/clone-impl.rs:67:5: 67:12}`
4826
...
4927
LL | check_copy(&gen_clone_1);
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:59:5: 59:12}`, the trait `Copy` is not implemented for `Vec<u32>`
28+
| ^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:67:5: 67:12}`, the trait `Copy` is not implemented for `Vec<u32>`
5129
|
5230
note: captured value does not implement `Copy`
53-
--> $DIR/clone-impl.rs:69:14
31+
--> $DIR/clone-impl.rs:71:14
5432
|
5533
LL | drop(clonable_1);
5634
| ^^^^^^^^^^ has type `Vec<u32>` which does not implement `Copy`
5735
note: required by a bound in `check_copy`
58-
--> $DIR/clone-impl.rs:90:18
59-
|
60-
LL | fn check_copy<T: Copy>(_x: &T) {}
61-
| ^^^^ required by this bound in `check_copy`
62-
63-
error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:59:5: 59:12}`
64-
--> $DIR/clone-impl.rs:71:5
65-
|
66-
LL | move || {
67-
| ------- within this `{coroutine@$DIR/clone-impl.rs:59:5: 59:12}`
68-
...
69-
LL | check_copy(&gen_clone_1);
70-
| ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:59:5: 59:12}`, the trait `Copy` is not implemented for `Vec<char>`
71-
|
72-
note: coroutine does not implement `Copy` as this value is used across a yield
73-
--> $DIR/clone-impl.rs:65:9
74-
|
75-
LL | let v = vec!['a'];
76-
| - has type `Vec<char>` which does not implement `Copy`
77-
...
78-
LL | yield;
79-
| ^^^^^ yield occurs here, with `v` maybe used later
80-
note: required by a bound in `check_copy`
81-
--> $DIR/clone-impl.rs:90:18
36+
--> $DIR/clone-impl.rs:91:18
8237
|
8338
LL | fn check_copy<T: Copy>(_x: &T) {}
8439
| ^^^^ required by this bound in `check_copy`
8540

86-
error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:80:5: 80:12}`
87-
--> $DIR/clone-impl.rs:84:5
41+
error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:81:5: 81:12}`
42+
--> $DIR/clone-impl.rs:85:16
8843
|
8944
LL | move || {
90-
| ------- within this `{coroutine@$DIR/clone-impl.rs:80:5: 80:12}`
45+
| ------- within this `{coroutine@$DIR/clone-impl.rs:81:5: 81:12}`
9146
...
9247
LL | check_copy(&gen_non_clone);
93-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:80:5: 80:12}`, the trait `Copy` is not implemented for `NonClone`
48+
| ^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:81:5: 81:12}`, the trait `Copy` is not implemented for `NonClone`
9449
|
9550
note: captured value does not implement `Copy`
96-
--> $DIR/clone-impl.rs:82:14
51+
--> $DIR/clone-impl.rs:83:14
9752
|
9853
LL | drop(non_clonable);
9954
| ^^^^^^^^^^^^ has type `NonClone` which does not implement `Copy`
10055
note: required by a bound in `check_copy`
101-
--> $DIR/clone-impl.rs:90:18
56+
--> $DIR/clone-impl.rs:91:18
10257
|
10358
LL | fn check_copy<T: Copy>(_x: &T) {}
10459
| ^^^^ required by this bound in `check_copy`
@@ -108,22 +63,22 @@ LL + #[derive(Copy)]
10863
LL | struct NonClone;
10964
|
11065

111-
error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{coroutine@$DIR/clone-impl.rs:80:5: 80:12}`
112-
--> $DIR/clone-impl.rs:86:5
66+
error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{coroutine@$DIR/clone-impl.rs:81:5: 81:12}`
67+
--> $DIR/clone-impl.rs:87:17
11368
|
11469
LL | move || {
115-
| ------- within this `{coroutine@$DIR/clone-impl.rs:80:5: 80:12}`
70+
| ------- within this `{coroutine@$DIR/clone-impl.rs:81:5: 81:12}`
11671
...
11772
LL | check_clone(&gen_non_clone);
118-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:80:5: 80:12}`, the trait `Clone` is not implemented for `NonClone`
73+
| ^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:81:5: 81:12}`, the trait `Clone` is not implemented for `NonClone`
11974
|
12075
note: captured value does not implement `Clone`
121-
--> $DIR/clone-impl.rs:82:14
76+
--> $DIR/clone-impl.rs:83:14
12277
|
12378
LL | drop(non_clonable);
12479
| ^^^^^^^^^^^^ has type `NonClone` which does not implement `Clone`
12580
note: required by a bound in `check_clone`
126-
--> $DIR/clone-impl.rs:91:19
81+
--> $DIR/clone-impl.rs:92:19
12782
|
12883
LL | fn check_clone<T: Clone>(_x: &T) {}
12984
| ^^^^^ required by this bound in `check_clone`
@@ -133,6 +88,28 @@ LL + #[derive(Clone)]
13388
LL | struct NonClone;
13489
|
13590

136-
error: aborting due to 6 previous errors
91+
error[E0277]: the trait bound `Vec<char>: Copy` is not satisfied in `{coroutine@$DIR/clone-impl.rs:54:5: 54:12}`
92+
--> $DIR/clone-impl.rs:59:5
93+
|
94+
LL | move || {
95+
| ------- within this `{coroutine@$DIR/clone-impl.rs:54:5: 54:12}`
96+
...
97+
LL | check_copy(&gen_clone_1);
98+
| ^^^^^^^^^^^^^^^^^^^^^^^^ within `{coroutine@$DIR/clone-impl.rs:54:5: 54:12}`, the trait `Copy` is not implemented for `Vec<char>`
99+
|
100+
note: coroutine does not implement `Copy` as this value is used across a yield
101+
--> $DIR/clone-impl.rs:56:9
102+
|
103+
LL | let v = vec!['a'];
104+
| - has type `Vec<char>` which does not implement `Copy`
105+
LL | yield;
106+
| ^^^^^ yield occurs here, with `v` maybe used later
107+
note: required by a bound in `check_copy`
108+
--> $DIR/clone-impl.rs:91:18
109+
|
110+
LL | fn check_copy<T: Copy>(_x: &T) {}
111+
| ^^^^ required by this bound in `check_copy`
112+
113+
error: aborting due to 5 previous errors
137114

138115
For more information about this error, try `rustc --explain E0277`.

‎tests/ui/coroutine/print/coroutine-print-verbose-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | | };
1111
| |_____^ expected `()`, found coroutine
1212
|
1313
= note: expected unit type `()`
14-
found coroutine `{main::{closure#0} upvar_tys=?4t resume_ty=() yield_ty=i32 return_ty=&'?1 str witness=?6t}`
14+
found coroutine `{main::{closure#0} upvar_tys=?4t resume_ty=() yield_ty=i32 return_ty=&'?1 str witness={main::{closure#0}}}`
1515

1616
error: aborting due to 1 previous error
1717

‎tests/ui/impl-trait/issues/issue-55872-3.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ impl<S> Bar for S {
1414
fn foo<T>() -> Self::E {
1515
//~^ ERROR : Copy` is not satisfied [E0277]
1616
//~| ERROR type parameter `T` is part of concrete type
17+
//~| ERROR type parameter `T` is part of concrete type
1718
async {}
1819
}
1920
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
error[E0277]: the trait bound `{async block@$DIR/issue-55872-3.rs:17:9: 17:14}: Copy` is not satisfied
1+
error[E0277]: the trait bound `{async block@$DIR/issue-55872-3.rs:18:9: 18:14}: Copy` is not satisfied
22
--> $DIR/issue-55872-3.rs:14:20
33
|
44
LL | fn foo<T>() -> Self::E {
5-
| ^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/issue-55872-3.rs:17:9: 17:14}`
5+
| ^^^^^^^ the trait `Copy` is not implemented for `{async block@$DIR/issue-55872-3.rs:18:9: 18:14}`
66
...
77
LL | async {}
8-
| -------- return type was inferred to be `{async block@$DIR/issue-55872-3.rs:17:9: 17:14}` here
8+
| -------- return type was inferred to be `{async block@$DIR/issue-55872-3.rs:18:9: 18:14}` here
99

1010
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
1111
--> $DIR/issue-55872-3.rs:14:20
1212
|
1313
LL | fn foo<T>() -> Self::E {
1414
| ^^^^^^^
1515

16-
error: aborting due to 2 previous errors
16+
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
17+
--> $DIR/issue-55872-3.rs:14:20
18+
|
19+
LL | fn foo<T>() -> Self::E {
20+
| ^^^^^^^
21+
|
22+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
23+
24+
error: aborting due to 3 previous errors
1725

1826
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)
Please sign in to comment.