Skip to content

Commit db3cdb6

Browse files
committed
make reg public and add visit, fold
1 parent 1e2bde6 commit db3cdb6

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

compiler/rustc_smir/src/stable_mir/fold.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::rustc_internal::Opaque;
44

55
use super::ty::{
66
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig, GenericArgKind,
7-
GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
7+
GenericArgs, Promoted, Region, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
88
};
99

1010
pub trait Folder: Sized {
@@ -106,6 +106,12 @@ impl Foldable for GenericArgs {
106106
}
107107
}
108108

109+
impl Foldable for Region {
110+
fn super_fold<V: Folder>(&self, _folder: &mut V) -> ControlFlow<V::Break, Self> {
111+
ControlFlow::Continue(self.clone())
112+
}
113+
}
114+
109115
impl Foldable for GenericArgKind {
110116
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
111117
let mut this = self.clone();

compiler/rustc_smir/src/stable_mir/ty.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ pub struct Const {
3434
}
3535

3636
type Ident = Opaque;
37-
pub(crate) struct Region {
37+
38+
#[derive(Debug, Clone)]
39+
pub struct Region {
3840
pub kind: RegionKind,
3941
}
4042

43+
#[derive(Debug, Clone)]
4144
pub enum RegionKind {
4245
ReEarlyBound(EarlyBoundRegion),
4346
ReLateBound(DebruijnIndex, BoundRegion),
@@ -51,6 +54,7 @@ pub enum RegionKind {
5154

5255
pub(crate) type DebruijnIndex = u32;
5356

57+
#[derive(Debug, Clone)]
5458
pub struct EarlyBoundRegion {
5559
pub def_id: RegionDef,
5660
pub index: u32,
@@ -59,11 +63,13 @@ pub struct EarlyBoundRegion {
5963

6064
pub(crate) type BoundVar = u32;
6165

66+
#[derive(Debug, Clone)]
6267
pub struct BoundRegion {
6368
pub var: BoundVar,
6469
pub kind: BoundRegionKind,
6570
}
6671

72+
#[derive(Debug, Clone)]
6773
pub struct FreeRegion {
6874
pub scope: RegionDef,
6975
pub bound_region: BoundRegionKind,
@@ -73,6 +79,7 @@ pub(crate) type RegionVid = u32;
7379

7480
pub(crate) type UniverseIndex = u32;
7581

82+
#[derive(Debug, Clone)]
7683
pub struct Placeholder<T> {
7784
pub universe: UniverseIndex,
7885
pub bound: T,

compiler/rustc_smir/src/stable_mir/visitor.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::rustc_internal::Opaque;
44

55
use super::ty::{
66
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
7-
Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
7+
Promoted, Region, RigidTy, TermKind, Ty, UnevaluatedConst,
88
};
99

1010
pub trait Visitor: Sized {
@@ -101,6 +101,12 @@ impl Visitable for GenericArgs {
101101
}
102102
}
103103

104+
impl Visitable for Region {
105+
fn super_visit<V: Visitor>(&self, _visitor: &mut V) -> ControlFlow<V::Break> {
106+
ControlFlow::Continue(())
107+
}
108+
}
109+
104110
impl Visitable for GenericArgKind {
105111
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
106112
match self {

0 commit comments

Comments
 (0)