mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +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
|
||||
//! until stable MIR is complete.
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::ops::{ControlFlow, Index};
|
||||
|
||||
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 = ()>
|
||||
where
|
||||
B: Send,
|
||||
|
@ -7,12 +7,11 @@
|
||||
//!
|
||||
//! 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::ty::{
|
||||
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 rustc_hir as hir;
|
||||
use rustc_middle::mir;
|
||||
|
@ -1,10 +1,11 @@
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use crate::rustc_internal::Opaque;
|
||||
|
||||
use super::ty::{
|
||||
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig, GenericArgKind,
|
||||
GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
||||
use super::{
|
||||
ty::{
|
||||
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig,
|
||||
GenericArgKind, GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
||||
},
|
||||
Opaque,
|
||||
};
|
||||
|
||||
pub trait Folder: Sized {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::rustc_internal::Opaque;
|
||||
use crate::stable_mir::ty::{
|
||||
AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region,
|
||||
};
|
||||
use crate::stable_mir::Opaque;
|
||||
use crate::stable_mir::{self, ty::Ty, Span};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -15,8 +15,6 @@ use std::cell::Cell;
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::rustc_internal::Opaque;
|
||||
|
||||
use self::ty::{
|
||||
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) })
|
||||
})
|
||||
}
|
||||
|
||||
/// 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::{
|
||||
mir::Safety,
|
||||
mir::{Body, Mutability},
|
||||
with, AllocId, DefId,
|
||||
with, AllocId, DefId, Opaque,
|
||||
};
|
||||
use crate::rustc_internal::Opaque;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -1,10 +1,11 @@
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use crate::rustc_internal::Opaque;
|
||||
|
||||
use super::ty::{
|
||||
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
|
||||
Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
||||
use super::{
|
||||
ty::{
|
||||
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind,
|
||||
GenericArgs, Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
||||
},
|
||||
Opaque,
|
||||
};
|
||||
|
||||
pub trait Visitor: Sized {
|
||||
|
Loading…
Reference in New Issue
Block a user