Remove the witness type from coroutine args

This commit is contained in:
Michael Goulet
2025-07-25 16:46:11 +00:00
parent d05bb98d6b
commit e9765781b2
18 changed files with 54 additions and 136 deletions

View File

@@ -1166,9 +1166,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if self.tcx().features().coroutine_clone() {
let resolved_upvars =
self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
let resolved_witness =
self.infcx.shallow_resolve(args.as_coroutine().witness());
if resolved_upvars.is_ty_var() || resolved_witness.is_ty_var() {
if resolved_upvars.is_ty_var() {
// Not yet resolved.
candidates.ambiguous = true;
} else {

View File

@@ -2196,7 +2196,11 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
args.as_coroutine()
.upvar_tys()
.iter()
.chain([args.as_coroutine().witness()])
.chain([Ty::new_coroutine_witness(
self.tcx(),
coroutine_def_id,
self.tcx().mk_args(args.as_coroutine().parent_args()),
)])
.collect::<Vec<_>>(),
)
} else {
@@ -2327,9 +2331,13 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
}
ty::Coroutine(_, args) => {
ty::Coroutine(def_id, args) => {
let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
let witness = args.as_coroutine().witness();
let witness = Ty::new_coroutine_witness(
self.tcx(),
def_id,
self.tcx().mk_args(args.as_coroutine().parent_args()),
);
ty::Binder::dummy(AutoImplConstituents {
types: [ty].into_iter().chain(iter::once(witness)).collect(),
assumptions: vec![],