mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Move Opaque
to stable_mir
This commit is contained in:
parent
33998a9751
commit
19f1d782d5
@ -3,7 +3,6 @@
|
|||||||
//! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs
|
//! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs
|
||||||
//! until stable MIR is complete.
|
//! until stable MIR is complete.
|
||||||
|
|
||||||
use std::fmt::Debug;
|
|
||||||
use std::ops::{ControlFlow, Index};
|
use std::ops::{ControlFlow, Index};
|
||||||
|
|
||||||
use crate::rustc_internal;
|
use crate::rustc_internal;
|
||||||
@ -136,26 +135,6 @@ pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type that provides internal information but that can still be used for debug purpose.
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Opaque(String);
|
|
||||||
|
|
||||||
impl std::fmt::Display for Opaque {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "{}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Debug for Opaque {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "{:?}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn opaque<T: Debug>(value: &T) -> Opaque {
|
|
||||||
Opaque(format!("{value:?}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct StableMir<B = (), C = ()>
|
pub struct StableMir<B = (), C = ()>
|
||||||
where
|
where
|
||||||
B: Send,
|
B: Send,
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
//!
|
//!
|
||||||
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
||||||
|
|
||||||
use crate::rustc_internal::opaque;
|
|
||||||
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
||||||
use crate::stable_mir::ty::{
|
use crate::stable_mir::ty::{
|
||||||
FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy,
|
FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy,
|
||||||
};
|
};
|
||||||
use crate::stable_mir::{self, CompilerError, Context};
|
use crate::stable_mir::{self, opaque, CompilerError, Context};
|
||||||
use hir::def::DefKind;
|
use hir::def::DefKind;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use crate::rustc_internal::Opaque;
|
use super::{
|
||||||
|
ty::{
|
||||||
use super::ty::{
|
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig,
|
||||||
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig, GenericArgKind,
|
GenericArgKind, GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
||||||
GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
},
|
||||||
|
Opaque,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Folder: Sized {
|
pub trait Folder: Sized {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::rustc_internal::Opaque;
|
|
||||||
use crate::stable_mir::ty::{
|
use crate::stable_mir::ty::{
|
||||||
AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region,
|
AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region,
|
||||||
};
|
};
|
||||||
|
use crate::stable_mir::Opaque;
|
||||||
use crate::stable_mir::{self, ty::Ty, Span};
|
use crate::stable_mir::{self, ty::Ty, Span};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -15,8 +15,6 @@ use std::cell::Cell;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use crate::rustc_internal::Opaque;
|
|
||||||
|
|
||||||
use self::ty::{
|
use self::ty::{
|
||||||
GenericPredicates, Generics, ImplDef, ImplTrait, Span, TraitDecl, TraitDef, Ty, TyKind,
|
GenericPredicates, Generics, ImplDef, ImplTrait, Span, TraitDecl, TraitDef, Ty, TyKind,
|
||||||
};
|
};
|
||||||
@ -210,3 +208,23 @@ pub(crate) fn with<R>(f: impl FnOnce(&mut dyn Context) -> R) -> R {
|
|||||||
f(unsafe { *(ptr as *mut &mut dyn Context) })
|
f(unsafe { *(ptr as *mut &mut dyn Context) })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A type that provides internal information but that can still be used for debug purpose.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Opaque(String);
|
||||||
|
|
||||||
|
impl std::fmt::Display for Opaque {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Opaque {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{:?}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn opaque<T: Debug>(value: &T) -> Opaque {
|
||||||
|
Opaque(format!("{value:?}"))
|
||||||
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
use super::{
|
use super::{
|
||||||
mir::Safety,
|
mir::Safety,
|
||||||
mir::{Body, Mutability},
|
mir::{Body, Mutability},
|
||||||
with, AllocId, DefId,
|
with, AllocId, DefId, Opaque,
|
||||||
};
|
};
|
||||||
use crate::rustc_internal::Opaque;
|
|
||||||
use std::fmt::{self, Debug, Formatter};
|
use std::fmt::{self, Debug, Formatter};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use crate::rustc_internal::Opaque;
|
use super::{
|
||||||
|
ty::{
|
||||||
use super::ty::{
|
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind,
|
||||||
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
|
GenericArgs, Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
||||||
Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
},
|
||||||
|
Opaque,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Visitor: Sized {
|
pub trait Visitor: Sized {
|
||||||
|
Loading…
Reference in New Issue
Block a user