Make THIR building a stealable query
This commit is contained in:
parent
bd80018159
commit
6f64eb1fe6
20 changed files with 60 additions and 42 deletions
|
@ -14,6 +14,7 @@ macro_rules! arena_types {
|
|||
[] layouts: rustc_target::abi::Layout,
|
||||
// AdtDef are interned and compared by address
|
||||
[] adt_def: rustc_middle::ty::AdtDef,
|
||||
[] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<$tcx>>,
|
||||
[] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
|
||||
[decode] mir: rustc_middle::mir::Body<$tcx>,
|
||||
[] steal_promoted:
|
||||
|
|
|
@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
|
|||
// required that their size stay the same, but we don't want to change
|
||||
// it inadvertently. This assert just ensures we're aware of any change.
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
static_assert_size!(DepNode, 17);
|
||||
static_assert_size!(DepNode, 18);
|
||||
|
||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
|
||||
static_assert_size!(DepNode, 24);
|
||||
|
|
|
@ -220,6 +220,11 @@ rustc_queries! {
|
|||
desc { "checking if the crate is_panic_runtime" }
|
||||
}
|
||||
|
||||
/// Fetch the THIR for a given body.
|
||||
query thir_body(key: ty::WithOptConstParam<LocalDefId>) -> (&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId) {
|
||||
desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
|
||||
}
|
||||
|
||||
/// Set of all the `DefId`s in this crate that have MIR associated with
|
||||
/// them. This includes all the body owners, but also things like struct
|
||||
/// constructors.
|
||||
|
|
|
@ -24,18 +24,21 @@ use std::fmt;
|
|||
use std::ops::Index;
|
||||
|
||||
newtype_index! {
|
||||
#[derive(HashStable)]
|
||||
pub struct ArmId {
|
||||
DEBUG_FORMAT = "a{}"
|
||||
}
|
||||
}
|
||||
|
||||
newtype_index! {
|
||||
#[derive(HashStable)]
|
||||
pub struct ExprId {
|
||||
DEBUG_FORMAT = "e{}"
|
||||
}
|
||||
}
|
||||
|
||||
newtype_index! {
|
||||
#[derive(HashStable)]
|
||||
pub struct StmtId {
|
||||
DEBUG_FORMAT = "s{}"
|
||||
}
|
||||
|
@ -43,6 +46,7 @@ newtype_index! {
|
|||
|
||||
macro_rules! thir_with_elements {
|
||||
($($name:ident: $id:ty => $value:ty,)*) => {
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct Thir<'tcx> {
|
||||
$(
|
||||
pub $name: IndexVec<$id, $value>,
|
||||
|
@ -76,13 +80,13 @@ thir_with_elements! {
|
|||
stmts: StmtId => Stmt<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
pub enum LintLevel {
|
||||
Inherited,
|
||||
Explicit(hir::HirId),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct Block {
|
||||
pub targeted_by_break: bool,
|
||||
pub region_scope: region::Scope,
|
||||
|
@ -93,7 +97,7 @@ pub struct Block {
|
|||
pub safety_mode: BlockSafety,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
pub enum BlockSafety {
|
||||
Safe,
|
||||
ExplicitUnsafe(hir::HirId),
|
||||
|
@ -101,13 +105,13 @@ pub enum BlockSafety {
|
|||
PopUnsafe,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct Stmt<'tcx> {
|
||||
pub kind: StmtKind<'tcx>,
|
||||
pub opt_destruction_scope: Option<region::Scope>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub enum StmtKind<'tcx> {
|
||||
Expr {
|
||||
/// scope for this statement; may be used as lifetime of temporaries
|
||||
|
@ -157,7 +161,7 @@ rustc_data_structures::static_assert_size!(Expr<'_>, 144);
|
|||
/// MIR simplifications are already done in the impl of `Thir`. For
|
||||
/// example, method calls and overloaded operators are absent: they are
|
||||
/// expected to be converted into `Expr::Call` instances.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct Expr<'tcx> {
|
||||
/// type of this expression
|
||||
pub ty: Ty<'tcx>,
|
||||
|
@ -173,7 +177,7 @@ pub struct Expr<'tcx> {
|
|||
pub kind: ExprKind<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub enum ExprKind<'tcx> {
|
||||
Scope {
|
||||
region_scope: region::Scope,
|
||||
|
@ -363,19 +367,19 @@ pub enum ExprKind<'tcx> {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct FieldExpr {
|
||||
pub name: Field,
|
||||
pub expr: ExprId,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct FruInfo<'tcx> {
|
||||
pub base: ExprId,
|
||||
pub field_types: Box<[Ty<'tcx>]>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub struct Arm<'tcx> {
|
||||
pub pattern: Pat<'tcx>,
|
||||
pub guard: Option<Guard<'tcx>>,
|
||||
|
@ -385,19 +389,19 @@ pub struct Arm<'tcx> {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub enum Guard<'tcx> {
|
||||
If(ExprId),
|
||||
IfLet(Pat<'tcx>, ExprId),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
pub enum LogicalOp {
|
||||
And,
|
||||
Or,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, HashStable)]
|
||||
pub enum InlineAsmOperand<'tcx> {
|
||||
In {
|
||||
reg: InlineAsmRegOrRegClass,
|
||||
|
@ -431,19 +435,19 @@ pub enum InlineAsmOperand<'tcx> {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
|
||||
pub enum BindingMode {
|
||||
ByValue,
|
||||
ByRef(BorrowKind),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, HashStable)]
|
||||
pub struct FieldPat<'tcx> {
|
||||
pub field: Field,
|
||||
pub pattern: Pat<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, HashStable)]
|
||||
pub struct Pat<'tcx> {
|
||||
pub ty: Ty<'tcx>,
|
||||
pub span: Span,
|
||||
|
@ -456,7 +460,7 @@ impl<'tcx> Pat<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
|
||||
pub struct PatTyProj<'tcx> {
|
||||
pub user_ty: CanonicalUserType<'tcx>,
|
||||
}
|
||||
|
@ -483,7 +487,7 @@ impl<'tcx> PatTyProj<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
|
||||
pub struct Ascription<'tcx> {
|
||||
pub user_ty: PatTyProj<'tcx>,
|
||||
/// Variance to use when relating the type `user_ty` to the **type of the value being
|
||||
|
@ -508,7 +512,7 @@ pub struct Ascription<'tcx> {
|
|||
pub user_ty_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, HashStable)]
|
||||
pub enum PatKind<'tcx> {
|
||||
Wild,
|
||||
|
||||
|
@ -586,7 +590,7 @@ pub enum PatKind<'tcx> {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
|
||||
pub struct PatRange<'tcx> {
|
||||
pub lo: &'tcx ty::Const<'tcx>,
|
||||
pub hi: &'tcx ty::Const<'tcx>,
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetime
|
|||
use crate::middle::stability;
|
||||
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
|
||||
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
|
||||
use crate::thir::Thir;
|
||||
use crate::traits;
|
||||
use crate::ty::query::{self, OnDiskCache, TyCtxtAt};
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSubsts};
|
||||
|
@ -1041,6 +1042,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn alloc_steal_thir(self, thir: Thir<'tcx>) -> &'tcx Steal<Thir<'tcx>> {
|
||||
self.arena.alloc(Steal::new(thir))
|
||||
}
|
||||
|
||||
pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
|
||||
self.arena.alloc(Steal::new(mir))
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use crate::mir::interpret::GlobalId;
|
|||
use crate::mir::interpret::{ConstAlloc, LitToConstError, LitToConstInput};
|
||||
use crate::mir::interpret::{ConstValue, EvalToAllocationRawResult, EvalToConstValueResult};
|
||||
use crate::mir::mono::CodegenUnit;
|
||||
use crate::thir;
|
||||
use crate::traits::query::{
|
||||
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
|
||||
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
|
||||
|
|
|
@ -669,7 +669,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone, HashStable)]
|
||||
pub enum UpvarSubsts<'tcx> {
|
||||
Closure(SubstsRef<'tcx>),
|
||||
Generator(SubstsRef<'tcx>),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue