Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6f64eb1f
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f64eb1f
编写于
4月 04, 2021
作者:
L
LeSeulArtichaut
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make THIR building a stealable query
上级
bd800181
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
60 addition
and
42 deletion
+60
-42
compiler/rustc_middle/src/arena.rs
compiler/rustc_middle/src/arena.rs
+1
-0
compiler/rustc_middle/src/dep_graph/dep_node.rs
compiler/rustc_middle/src/dep_graph/dep_node.rs
+1
-1
compiler/rustc_middle/src/query/mod.rs
compiler/rustc_middle/src/query/mod.rs
+5
-0
compiler/rustc_middle/src/thir.rs
compiler/rustc_middle/src/thir.rs
+24
-20
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/context.rs
+5
-0
compiler/rustc_middle/src/ty/query/mod.rs
compiler/rustc_middle/src/ty/query/mod.rs
+1
-0
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/sty.rs
+1
-1
compiler/rustc_mir_build/src/build/block.rs
compiler/rustc_mir_build/src/build/block.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/as_constant.rs
compiler/rustc_mir_build/src/build/expr/as_constant.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/as_operand.rs
compiler/rustc_mir_build/src/build/expr/as_operand.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/as_place.rs
compiler/rustc_mir_build/src/build/expr/as_place.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/as_temp.rs
compiler/rustc_mir_build/src/build/expr/as_temp.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/into.rs
compiler/rustc_mir_build/src/build/expr/into.rs
+1
-1
compiler/rustc_mir_build/src/build/expr/stmt.rs
compiler/rustc_mir_build/src/build/expr/stmt.rs
+1
-1
compiler/rustc_mir_build/src/build/mod.rs
compiler/rustc_mir_build/src/build/mod.rs
+4
-4
compiler/rustc_mir_build/src/lib.rs
compiler/rustc_mir_build/src/lib.rs
+1
-0
compiler/rustc_mir_build/src/thir/cx/mod.rs
compiler/rustc_mir_build/src/thir/cx/mod.rs
+8
-6
compiler/rustc_mir_build/src/thir/mod.rs
compiler/rustc_mir_build/src/thir/mod.rs
+0
-1
compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
+1
-1
未找到文件。
compiler/rustc_middle/src/arena.rs
浏览文件 @
6f64eb1f
...
...
@@ -14,6 +14,7 @@
[]
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
:
...
...
compiler/rustc_middle/src/dep_graph/dep_node.rs
浏览文件 @
6f64eb1f
...
...
@@ -285,7 +285,7 @@ pub mod label_strs {
// 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
,
1
7
);
static_assert_size!
(
DepNode
,
1
8
);
#[cfg(not(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
)))]
static_assert_size!
(
DepNode
,
24
);
...
...
compiler/rustc_middle/src/query/mod.rs
浏览文件 @
6f64eb1f
...
...
@@ -220,6 +220,11 @@
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.
...
...
compiler/rustc_middle/src/thir.rs
浏览文件 @
6f64eb1f
...
...
@@ -24,18 +24,21 @@
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 @@ pub struct StmtId {
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 @@ fn index(&self, index: $id) -> &Self::Output {
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 @@ pub enum StmtKind<'tcx> {
/// 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 @@ pub fn wildcard_from_ty(ty: Ty<'tcx>) -> Self {
}
}
#[derive(Copy,
Clone,
Debug,
PartialEq)]
#[derive(Copy,
Clone,
Debug,
PartialEq
,
HashStable
)]
pub
struct
PatTyProj
<
'tcx
>
{
pub
user_ty
:
CanonicalUserType
<
'tcx
>
,
}
...
...
@@ -483,7 +487,7 @@ pub fn user_ty(
}
}
#[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
>
,
...
...
compiler/rustc_middle/src/ty/context.rs
浏览文件 @
6f64eb1f
...
...
@@ -13,6 +13,7 @@
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 @@ pub fn typeck_opt_const_arg(
}
}
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
))
}
...
...
compiler/rustc_middle/src/ty/query/mod.rs
浏览文件 @
6f64eb1f
...
...
@@ -18,6 +18,7 @@
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
,
...
...
compiler/rustc_middle/src/ty/sty.rs
浏览文件 @
6f64eb1f
...
...
@@ -669,7 +669,7 @@ pub fn prefix_tys(self) -> impl Iterator<Item = Ty<'tcx>> {
}
}
#[derive(Debug,
Copy,
Clone)]
#[derive(Debug,
Copy,
Clone
,
HashStable
)]
pub
enum
UpvarSubsts
<
'tcx
>
{
Closure
(
SubstsRef
<
'tcx
>
),
Generator
(
SubstsRef
<
'tcx
>
),
...
...
compiler/rustc_mir_build/src/build/block.rs
浏览文件 @
6f64eb1f
use
crate
::
build
::
matches
::
ArmHasGuard
;
use
crate
::
build
::
ForGuard
::
OutsideGuard
;
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
BlockFrame
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
use
rustc_session
::
lint
::
builtin
::
UNSAFE_OP_IN_UNSAFE_FN
;
use
rustc_session
::
lint
::
Level
;
use
rustc_span
::
Span
;
...
...
compiler/rustc_mir_build/src/build/expr/as_constant.rs
浏览文件 @
6f64eb1f
//! See docs in build/expr/mod.rs
use
crate
::
build
::
Builder
;
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
ty
::
CanonicalUserTypeAnnotation
;
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
...
...
compiler/rustc_mir_build/src/build/expr/as_operand.rs
浏览文件 @
6f64eb1f
...
...
@@ -2,9 +2,9 @@
use
crate
::
build
::
expr
::
category
::
Category
;
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
middle
::
region
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
/// Returns an operand suitable for use until the end of the current
...
...
compiler/rustc_mir_build/src/build/expr/as_place.rs
浏览文件 @
6f64eb1f
...
...
@@ -3,13 +3,13 @@
use
crate
::
build
::
expr
::
category
::
Category
;
use
crate
::
build
::
ForGuard
::{
OutsideGuard
,
RefWithinGuard
};
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_hir
::
def_id
::
DefId
;
use
rustc_hir
::
HirId
;
use
rustc_middle
::
hir
::
place
::
ProjectionKind
as
HirProjectionKind
;
use
rustc_middle
::
middle
::
region
;
use
rustc_middle
::
mir
::
AssertKind
::
BoundsCheck
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
ty
::
AdtDef
;
use
rustc_middle
::
ty
::{
self
,
CanonicalUserTypeAnnotation
,
Ty
,
TyCtxt
,
Variance
};
use
rustc_span
::
Span
;
...
...
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
浏览文件 @
6f64eb1f
...
...
@@ -5,11 +5,11 @@
use
crate
::
build
::
expr
::
as_place
::
PlaceBase
;
use
crate
::
build
::
expr
::
category
::{
Category
,
RvalueFunc
};
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
middle
::
region
;
use
rustc_middle
::
mir
::
AssertKind
;
use
rustc_middle
::
mir
::
Place
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
ty
::{
self
,
Ty
,
UpvarSubsts
};
use
rustc_span
::
Span
;
...
...
compiler/rustc_mir_build/src/build/expr/as_temp.rs
浏览文件 @
6f64eb1f
...
...
@@ -2,10 +2,10 @@
use
crate
::
build
::
scope
::
DropKind
;
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_data_structures
::
stack
::
ensure_sufficient_stack
;
use
rustc_middle
::
middle
::
region
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
/// Compile `expr` into a fresh temporary. This is used when building
...
...
compiler/rustc_mir_build/src/build/expr/into.rs
浏览文件 @
6f64eb1f
...
...
@@ -2,13 +2,13 @@
use
crate
::
build
::
expr
::
category
::{
Category
,
RvalueFunc
};
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
BlockFrame
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_ast
::
InlineAsmOptions
;
use
rustc_data_structures
::
fx
::
FxHashMap
;
use
rustc_data_structures
::
stack
::
ensure_sufficient_stack
;
use
rustc_hir
as
hir
;
use
rustc_index
::
vec
::
Idx
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
ty
::{
self
,
CanonicalUserTypeAnnotation
};
use
std
::
iter
;
...
...
compiler/rustc_mir_build/src/build/expr/stmt.rs
浏览文件 @
6f64eb1f
use
crate
::
build
::
scope
::
BreakableTarget
;
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
BlockFrame
,
Builder
};
use
rustc_middle
::
thir
::
*
;
use
rustc_middle
::
middle
::
region
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
thir
::
*
;
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
/// Builds a block of MIR statements to evaluate the THIR `expr`.
...
...
compiler/rustc_mir_build/src/build/mod.rs
浏览文件 @
6f64eb1f
use
crate
::
build
;
use
crate
::
build
::
expr
::
as_place
::
PlaceBuilder
;
use
crate
::
build
::
scope
::
DropKind
;
use
crate
::
thir
::
build_thir
;
use
crate
::
thir
::
pattern
::
pat_from_hir
;
use
rustc_attr
::{
self
as
attr
,
UnwindAttr
};
use
rustc_errors
::
ErrorReported
;
...
...
@@ -106,7 +105,8 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
};
let
body
=
tcx
.hir
()
.body
(
body_id
);
let
(
thir
,
expr
)
=
build_thir
(
tcx
,
def
,
&
body
.value
);
let
(
thir
,
expr
)
=
tcx
.thir_body
(
def
);
let
thir
=
thir
.steal
();
let
ty
=
tcx
.type_of
(
fn_def_id
);
let
mut
abi
=
fn_sig
.abi
;
let
implicit_argument
=
match
ty
.kind
()
{
...
...
@@ -214,8 +214,8 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
let
return_ty
=
typeck_results
.node_type
(
id
);
let
ast_expr
=
&
tcx
.hir
()
.body
(
body_id
)
.value
;
let
(
thir
,
expr
)
=
build_thir
(
tcx
,
def
,
ast_expr
);
let
(
thir
,
expr
)
=
tcx
.thir_body
(
def
)
;
let
thir
=
thir
.steal
(
);
build
::
construct_const
(
&
thir
,
&
infcx
,
expr
,
def
,
id
,
return_ty
,
return_ty_span
)
};
...
...
compiler/rustc_mir_build/src/lib.rs
浏览文件 @
6f64eb1f
...
...
@@ -31,4 +31,5 @@ pub fn provide(providers: &mut Providers) {
providers
.mir_built
=
build
::
mir_built
;
providers
.thir_check_unsafety
=
check_unsafety
::
thir_check_unsafety
;
providers
.thir_check_unsafety_for_const_arg
=
check_unsafety
::
thir_check_unsafety_for_const_arg
;
providers
.thir_body
=
thir
::
cx
::
thir_body
;
}
compiler/rustc_mir_build/src/thir/cx/mod.rs
浏览文件 @
6f64eb1f
...
...
@@ -2,10 +2,11 @@
//! structures into the THIR. The `builder` is generally ignorant of the tcx,
//! etc., and instead goes through the `Cx` for most of its work.
use
crate
::
thir
::
util
::
UserAnnotatedTyHelpers
;
use
crate
::
thir
::
pattern
::
pat_from_hir
;
use
crate
::
thir
::
util
::
UserAnnotatedTyHelpers
;
use
rustc_ast
as
ast
;
use
rustc_data_structures
::
steal
::
Steal
;
use
rustc_hir
as
hir
;
use
rustc_hir
::
def_id
::{
DefId
,
LocalDefId
};
use
rustc_hir
::
Node
;
...
...
@@ -15,14 +16,15 @@
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_span
::
Span
;
pub
fn
build_thir
<
'tcx
>
(
crate
fn
thir_body
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
owner_def
:
ty
::
WithOptConstParam
<
LocalDefId
>
,
expr
:
&
'tcx
hir
::
Expr
<
'tcx
>
,
)
->
(
Thir
<
'tcx
>
,
ExprId
)
{
)
->
(
&
'tcx
Steal
<
Thir
<
'tcx
>>
,
ExprId
)
{
let
hir
=
tcx
.hir
();
let
body
=
hir
.body
(
hir
.body_owned_by
(
hir
.local_def_id_to_hir_id
(
owner_def
.did
)));
let
mut
cx
=
Cx
::
new
(
tcx
,
owner_def
);
let
expr
=
cx
.mirror_expr
(
expr
);
(
cx
.thir
,
expr
)
let
expr
=
cx
.mirror_expr
(
&
body
.value
);
(
tcx
.alloc_steal_thir
(
cx
.thir
)
,
expr
)
}
struct
Cx
<
'tcx
>
{
...
...
compiler/rustc_mir_build/src/thir/mod.rs
浏览文件 @
6f64eb1f
...
...
@@ -7,7 +7,6 @@
crate
mod
constant
;
crate
mod
cx
;
pub
use
cx
::
build_thir
;
crate
mod
pattern
;
...
...
compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
浏览文件 @
6f64eb1f
...
...
@@ -292,8 +292,8 @@
use
rustc_arena
::
TypedArena
;
use
rustc_hir
::
def_id
::
DefId
;
use
rustc_hir
::
HirId
;
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_middle
::
thir
::{
Pat
,
PatKind
};
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_span
::
Span
;
use
smallvec
::{
smallvec
,
SmallVec
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录