mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-04 05:57:36 +00:00
make reg public and add visit, fold
This commit is contained in:
parent
5dc2214884
commit
d83559939c
@ -4,7 +4,7 @@ use crate::Opaque;
|
|||||||
|
|
||||||
use super::ty::{
|
use super::ty::{
|
||||||
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig, GenericArgKind,
|
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig, GenericArgKind,
|
||||||
GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
GenericArgs, Promoted, Region, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Folder: Sized {
|
pub trait Folder: Sized {
|
||||||
@ -106,6 +106,12 @@ impl Foldable for GenericArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Foldable for Region {
|
||||||
|
fn super_fold<V: Folder>(&self, _folder: &mut V) -> ControlFlow<V::Break, Self> {
|
||||||
|
ControlFlow::Continue(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Foldable for GenericArgKind {
|
impl Foldable for GenericArgKind {
|
||||||
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
|
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
|
||||||
let mut this = self.clone();
|
let mut this = self.clone();
|
||||||
|
@ -34,10 +34,13 @@ pub struct Const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Ident = Opaque;
|
type Ident = Opaque;
|
||||||
pub(crate) struct Region {
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Region {
|
||||||
pub kind: RegionKind,
|
pub kind: RegionKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub enum RegionKind {
|
pub enum RegionKind {
|
||||||
ReEarlyBound(EarlyBoundRegion),
|
ReEarlyBound(EarlyBoundRegion),
|
||||||
ReLateBound(DebruijnIndex, BoundRegion),
|
ReLateBound(DebruijnIndex, BoundRegion),
|
||||||
@ -51,6 +54,7 @@ pub enum RegionKind {
|
|||||||
|
|
||||||
pub(crate) type DebruijnIndex = u32;
|
pub(crate) type DebruijnIndex = u32;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct EarlyBoundRegion {
|
pub struct EarlyBoundRegion {
|
||||||
pub def_id: RegionDef,
|
pub def_id: RegionDef,
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
@ -59,11 +63,13 @@ pub struct EarlyBoundRegion {
|
|||||||
|
|
||||||
pub(crate) type BoundVar = u32;
|
pub(crate) type BoundVar = u32;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct BoundRegion {
|
pub struct BoundRegion {
|
||||||
pub var: BoundVar,
|
pub var: BoundVar,
|
||||||
pub kind: BoundRegionKind,
|
pub kind: BoundRegionKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct FreeRegion {
|
pub struct FreeRegion {
|
||||||
pub scope: RegionDef,
|
pub scope: RegionDef,
|
||||||
pub bound_region: BoundRegionKind,
|
pub bound_region: BoundRegionKind,
|
||||||
@ -73,6 +79,7 @@ pub(crate) type RegionVid = u32;
|
|||||||
|
|
||||||
pub(crate) type UniverseIndex = u32;
|
pub(crate) type UniverseIndex = u32;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Placeholder<T> {
|
pub struct Placeholder<T> {
|
||||||
pub universe: UniverseIndex,
|
pub universe: UniverseIndex,
|
||||||
pub bound: T,
|
pub bound: T,
|
||||||
|
@ -4,7 +4,7 @@ use crate::Opaque;
|
|||||||
|
|
||||||
use super::ty::{
|
use super::ty::{
|
||||||
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
|
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
|
||||||
Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
Promoted, Region, RigidTy, TermKind, Ty, UnevaluatedConst,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Visitor: Sized {
|
pub trait Visitor: Sized {
|
||||||
@ -101,6 +101,12 @@ impl Visitable for GenericArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Visitable for Region {
|
||||||
|
fn super_visit<V: Visitor>(&self, _visitor: &mut V) -> ControlFlow<V::Break> {
|
||||||
|
ControlFlow::Continue(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Visitable for GenericArgKind {
|
impl Visitable for GenericArgKind {
|
||||||
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
||||||
match self {
|
match self {
|
||||||
|
Loading…
Reference in New Issue
Block a user