Skip to content

Commit

Permalink
Auto merge of #117787 - ouz-a:smir_coroutinewitness, r=celinval
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Nov 14, 2023
2 parents fa14810 + 6812f64 commit d97bb19
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ impl<'tcx> Tables<'tcx> {
stable_mir::ty::RegionDef(self.create_def_id(did))
}

pub fn coroutine_witness_def(&mut self, did: DefId) -> stable_mir::ty::CoroutineWitnessDef {
stable_mir::ty::CoroutineWitnessDef(self.create_def_id(did))
}

pub fn prov(&mut self, aid: AllocId) -> stable_mir::ty::Prov {
stable_mir::ty::Prov(self.create_alloc_id(aid))
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,11 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
ty::Bound(debruijn_idx, bound_ty) => {
TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
}
ty::Placeholder(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => {
ty::CoroutineWitness(def_id, args) => TyKind::RigidTy(RigidTy::CoroutineWitness(
tables.coroutine_witness_def(*def_id),
args.stable(tables),
)),
ty::Placeholder(..) | ty::Infer(_) | ty::Error(_) => {
unreachable!();
}
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/stable_mir/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ pub enum RigidTy {
Dynamic(Vec<Binder<ExistentialPredicate>>, Region, DynKind),
Never,
Tuple(Vec<Ty>),
CoroutineWitness(CoroutineWitnessDef, GenericArgs),
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -235,6 +236,9 @@ pub struct ImplDef(pub DefId);
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct RegionDef(pub DefId);

#[derive(Clone, PartialEq, Eq, Debug)]
pub struct CoroutineWitnessDef(pub DefId);

/// A list of generic arguments.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct GenericArgs(pub Vec<GenericArgKind>);
Expand Down
1 change: 1 addition & 0 deletions compiler/stable_mir/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl Visitable for RigidTy {
RigidTy::FnPtr(sig) => sig.visit(visitor),
RigidTy::Closure(_, args) => args.visit(visitor),
RigidTy::Coroutine(_, args, _) => args.visit(visitor),
RigidTy::CoroutineWitness(_, args) => args.visit(visitor),
RigidTy::Dynamic(pred, r, _) => {
pred.visit(visitor)?;
r.visit(visitor)
Expand Down

0 comments on commit d97bb19

Please sign in to comment.