Move MirSource
to rustc_middle
This commit is contained in:
parent
141a977edf
commit
938d8fd805
2 changed files with 35 additions and 28 deletions
|
@ -111,6 +111,38 @@ impl MirPhase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Where a specific `mir::Body` comes from.
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
#[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable)]
|
||||||
|
pub struct MirSource<'tcx> {
|
||||||
|
pub instance: InstanceDef<'tcx>,
|
||||||
|
|
||||||
|
/// If `Some`, this is a promoted rvalue within the parent function.
|
||||||
|
pub promoted: Option<Promoted>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> MirSource<'tcx> {
|
||||||
|
pub fn item(def_id: DefId) -> Self {
|
||||||
|
MirSource {
|
||||||
|
instance: InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)),
|
||||||
|
promoted: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_instance(instance: InstanceDef<'tcx>) -> Self {
|
||||||
|
MirSource { instance, promoted: None }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_opt_param(self) -> ty::WithOptConstParam<DefId> {
|
||||||
|
self.instance.with_opt_param()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn def_id(&self) -> DefId {
|
||||||
|
self.instance.def_id()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The lowered representation of a single function.
|
/// The lowered representation of a single function.
|
||||||
#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable)]
|
#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable)]
|
||||||
pub struct Body<'tcx> {
|
pub struct Body<'tcx> {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_middle::mir::visit::Visitor as _;
|
||||||
use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted};
|
use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted};
|
||||||
use rustc_middle::ty::query::Providers;
|
use rustc_middle::ty::query::Providers;
|
||||||
use rustc_middle::ty::steal::Steal;
|
use rustc_middle::ty::steal::Steal;
|
||||||
use rustc_middle::ty::{self, InstanceDef, TyCtxt, TypeFoldable};
|
use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ pub mod uninhabited_enum_branching;
|
||||||
pub mod unreachable_prop;
|
pub mod unreachable_prop;
|
||||||
pub mod validate;
|
pub mod validate;
|
||||||
|
|
||||||
|
pub use rustc_middle::mir::MirSource;
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
self::check_unsafety::provide(providers);
|
self::check_unsafety::provide(providers);
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
|
@ -132,33 +134,6 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> FxHashSet<LocalDefId> {
|
||||||
set
|
set
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Where a specific `mir::Body` comes from.
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
pub struct MirSource<'tcx> {
|
|
||||||
pub instance: InstanceDef<'tcx>,
|
|
||||||
|
|
||||||
/// If `Some`, this is a promoted rvalue within the parent function.
|
|
||||||
pub promoted: Option<Promoted>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> MirSource<'tcx> {
|
|
||||||
pub fn item(def_id: DefId) -> Self {
|
|
||||||
MirSource {
|
|
||||||
instance: InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)),
|
|
||||||
promoted: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_opt_param(self) -> ty::WithOptConstParam<DefId> {
|
|
||||||
self.instance.with_opt_param()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn def_id(&self) -> DefId {
|
|
||||||
self.instance.def_id()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generates a default name for the pass based on the name of the
|
/// Generates a default name for the pass based on the name of the
|
||||||
/// type `T`.
|
/// type `T`.
|
||||||
pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue