Skip to content

Commit d97bb19

Browse files
committed
Auto merge of #117787 - ouz-a:smir_coroutinewitness, r=celinval
Add CoroutineWitness to covered types in smir Previously we accepted `CouroutineWitness` as `unreachable!` but rust-lang/project-stable-mir#50 shows it is indeed reachable, this pr fixes that and covers `CouroutineWitness`
2 parents fa14810 + 6812f64 commit d97bb19

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

compiler/rustc_smir/src/rustc_internal/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ impl<'tcx> Tables<'tcx> {
104104
stable_mir::ty::RegionDef(self.create_def_id(did))
105105
}
106106

107+
pub fn coroutine_witness_def(&mut self, did: DefId) -> stable_mir::ty::CoroutineWitnessDef {
108+
stable_mir::ty::CoroutineWitnessDef(self.create_def_id(did))
109+
}
110+
107111
pub fn prov(&mut self, aid: AllocId) -> stable_mir::ty::Prov {
108112
stable_mir::ty::Prov(self.create_alloc_id(aid))
109113
}

compiler/rustc_smir/src/rustc_smir/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,11 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
12921292
ty::Bound(debruijn_idx, bound_ty) => {
12931293
TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
12941294
}
1295-
ty::Placeholder(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => {
1295+
ty::CoroutineWitness(def_id, args) => TyKind::RigidTy(RigidTy::CoroutineWitness(
1296+
tables.coroutine_witness_def(*def_id),
1297+
args.stable(tables),
1298+
)),
1299+
ty::Placeholder(..) | ty::Infer(_) | ty::Error(_) => {
12961300
unreachable!();
12971301
}
12981302
}

compiler/stable_mir/src/ty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ pub enum RigidTy {
156156
Dynamic(Vec<Binder<ExistentialPredicate>>, Region, DynKind),
157157
Never,
158158
Tuple(Vec<Ty>),
159+
CoroutineWitness(CoroutineWitnessDef, GenericArgs),
159160
}
160161

161162
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -235,6 +236,9 @@ pub struct ImplDef(pub DefId);
235236
#[derive(Clone, PartialEq, Eq, Debug)]
236237
pub struct RegionDef(pub DefId);
237238

239+
#[derive(Clone, PartialEq, Eq, Debug)]
240+
pub struct CoroutineWitnessDef(pub DefId);
241+
238242
/// A list of generic arguments.
239243
#[derive(Clone, Debug, Eq, PartialEq)]
240244
pub struct GenericArgs(pub Vec<GenericArgKind>);

compiler/stable_mir/src/visitor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ impl Visitable for RigidTy {
149149
RigidTy::FnPtr(sig) => sig.visit(visitor),
150150
RigidTy::Closure(_, args) => args.visit(visitor),
151151
RigidTy::Coroutine(_, args, _) => args.visit(visitor),
152+
RigidTy::CoroutineWitness(_, args) => args.visit(visitor),
152153
RigidTy::Dynamic(pred, r, _) => {
153154
pred.visit(visitor)?;
154155
r.visit(visitor)

0 commit comments

Comments
 (0)