Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
406d2ab9
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,发现更多精彩内容 >>
提交
406d2ab9
编写于
9月 07, 2021
作者:
E
Ellen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename mir -> thir around abstract consts
上级
15101c8e
变更
22
显示空白变更内容
内联
并排
Showing
22 changed file
with
287 addition
and
284 deletion
+287
-284
compiler/rustc_metadata/src/rmeta/decoder.rs
compiler/rustc_metadata/src/rmeta/decoder.rs
+5
-4
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+1
-1
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
+5
-3
compiler/rustc_metadata/src/rmeta/mod.rs
compiler/rustc_metadata/src/rmeta/mod.rs
+2
-1
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mod.rs
+0
-1
compiler/rustc_middle/src/mir/query.rs
compiler/rustc_middle/src/mir/query.rs
+5
-4
compiler/rustc_middle/src/query/mod.rs
compiler/rustc_middle/src/query/mod.rs
+4
-4
compiler/rustc_middle/src/thir.rs
compiler/rustc_middle/src/thir.rs
+3
-243
compiler/rustc_middle/src/thir/abstract_const.rs
compiler/rustc_middle/src/thir/abstract_const.rs
+0
-0
compiler/rustc_middle/src/thir/visit.rs
compiler/rustc_middle/src/thir/visit.rs
+238
-0
compiler/rustc_middle/src/traits/mod.rs
compiler/rustc_middle/src/traits/mod.rs
+1
-1
compiler/rustc_middle/src/ty/codec.rs
compiler/rustc_middle/src/ty/codec.rs
+3
-2
compiler/rustc_mir_build/src/build/mod.rs
compiler/rustc_mir_build/src/build/mod.rs
+2
-2
compiler/rustc_mir_transform/src/lib.rs
compiler/rustc_mir_transform/src/lib.rs
+0
-1
compiler/rustc_privacy/src/lib.rs
compiler/rustc_privacy/src/lib.rs
+1
-1
compiler/rustc_query_impl/src/on_disk_cache.rs
compiler/rustc_query_impl/src/on_disk_cache.rs
+2
-1
compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
...ler/rustc_trait_selection/src/traits/const_evaluatable.rs
+6
-6
compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
...r/rustc_trait_selection/src/traits/error_reporting/mod.rs
+1
-1
compiler/rustc_trait_selection/src/traits/fulfill.rs
compiler/rustc_trait_selection/src/traits/fulfill.rs
+1
-1
compiler/rustc_trait_selection/src/traits/mod.rs
compiler/rustc_trait_selection/src/traits/mod.rs
+5
-5
compiler/rustc_trait_selection/src/traits/object_safety.rs
compiler/rustc_trait_selection/src/traits/object_safety.rs
+1
-1
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
+1
-1
未找到文件。
compiler/rustc_metadata/src/rmeta/decoder.rs
浏览文件 @
406d2ab9
...
...
@@ -26,6 +26,7 @@
use
rustc_middle
::
middle
::
exported_symbols
::{
ExportedSymbol
,
SymbolExportLevel
};
use
rustc_middle
::
mir
::
interpret
::{
AllocDecodingSession
,
AllocDecodingState
};
use
rustc_middle
::
mir
::{
self
,
Body
,
Promoted
};
use
rustc_middle
::
thir
;
use
rustc_middle
::
ty
::
codec
::
TyDecoder
;
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyCtxt
,
Visibility
};
use
rustc_serialize
::{
opaque
,
Decodable
,
Decoder
};
...
...
@@ -540,7 +541,7 @@ fn decode(decoder: &mut DecodeContext<'a, 'tcx>) -> Result<Span, String> {
}
}
impl
<
'a
,
'tcx
>
Decodable
<
DecodeContext
<
'a
,
'tcx
>>
for
&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
impl
<
'a
,
'tcx
>
Decodable
<
DecodeContext
<
'a
,
'tcx
>>
for
&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
fn
decode
(
d
:
&
mut
DecodeContext
<
'a
,
'tcx
>
)
->
Result
<
Self
,
String
>
{
ty
::
codec
::
RefDecodable
::
decode
(
d
)
}
...
...
@@ -1198,14 +1199,14 @@ fn get_mir_for_ctfe(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
.decode
((
self
,
tcx
))
}
fn
get_
m
ir_abstract_const
(
fn
get_
th
ir_abstract_const
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
,
id
:
DefIndex
,
)
->
Result
<
Option
<&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
)
->
Result
<
Option
<&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
self
.root
.tables
.
m
ir_abstract_consts
.
th
ir_abstract_consts
.get
(
self
,
id
)
.map_or
(
Ok
(
None
),
|
v
|
Ok
(
Some
(
v
.decode
((
self
,
tcx
)))))
}
...
...
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
浏览文件 @
406d2ab9
...
...
@@ -117,7 +117,7 @@ fn into_args(self) -> (DefId, DefId) {
optimized_mir
=>
{
tcx
.arena
.alloc
(
cdata
.get_optimized_mir
(
tcx
,
def_id
.index
))
}
mir_for_ctfe
=>
{
tcx
.arena
.alloc
(
cdata
.get_mir_for_ctfe
(
tcx
,
def_id
.index
))
}
promoted_mir
=>
{
tcx
.arena
.alloc
(
cdata
.get_promoted_mir
(
tcx
,
def_id
.index
))
}
mir_abstract_const
=>
{
cdata
.get_m
ir_abstract_const
(
tcx
,
def_id
.index
)
}
thir_abstract_const
=>
{
cdata
.get_th
ir_abstract_const
(
tcx
,
def_id
.index
)
}
unused_generic_params
=>
{
cdata
.get_unused_generic_params
(
def_id
.index
)
}
const_param_default
=>
{
tcx
.mk_const
(
cdata
.get_const_param_default
(
tcx
,
def_id
.index
))
}
mir_const_qualif
=>
{
cdata
.mir_const_qualif
(
def_id
.index
)
}
...
...
compiler/rustc_metadata/src/rmeta/encoder.rs
浏览文件 @
406d2ab9
...
...
@@ -23,6 +23,7 @@
metadata_symbol_name
,
ExportedSymbol
,
SymbolExportLevel
,
};
use
rustc_middle
::
mir
::
interpret
;
use
rustc_middle
::
thir
;
use
rustc_middle
::
traits
::
specialization_graph
;
use
rustc_middle
::
ty
::
codec
::
TyEncoder
;
use
rustc_middle
::
ty
::{
self
,
SymbolName
,
Ty
,
TyCtxt
};
...
...
@@ -344,7 +345,7 @@ fn encode_alloc_id(
}
}
impl
<
'a
,
'tcx
>
Encodable
<
EncodeContext
<
'a
,
'tcx
>>
for
&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
impl
<
'a
,
'tcx
>
Encodable
<
EncodeContext
<
'a
,
'tcx
>>
for
&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
fn
encode
(
&
self
,
s
:
&
mut
EncodeContext
<
'a
,
'tcx
>
)
->
opaque
::
EncodeResult
{
(
**
self
)
.encode
(
s
)
}
...
...
@@ -1304,9 +1305,10 @@ fn encode_mir(&mut self) {
if
encode_const
{
record!
(
self
.tables.mir_for_ctfe
[
def_id
.to_def_id
()]
<-
self
.tcx
.mir_for_ctfe
(
def_id
));
let
abstract_const
=
self
.tcx
.mir_abstract_const
(
def_id
);
// FIXME this feels wrong to have in `encode_mir`
let
abstract_const
=
self
.tcx
.thir_abstract_const
(
def_id
);
if
let
Ok
(
Some
(
abstract_const
))
=
abstract_const
{
record!
(
self
.tables.
m
ir_abstract_consts
[
def_id
.to_def_id
()]
<-
abstract_const
);
record!
(
self
.tables.
th
ir_abstract_consts
[
def_id
.to_def_id
()]
<-
abstract_const
);
}
}
record!
(
self
.tables.promoted_mir
[
def_id
.to_def_id
()]
<-
self
.tcx
.promoted_mir
(
def_id
));
...
...
compiler/rustc_metadata/src/rmeta/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -15,6 +15,7 @@
use
rustc_middle
::
middle
::
cstore
::{
CrateDepKind
,
ForeignModule
,
LinkagePreference
,
NativeLib
};
use
rustc_middle
::
middle
::
exported_symbols
::{
ExportedSymbol
,
SymbolExportLevel
};
use
rustc_middle
::
mir
;
use
rustc_middle
::
thir
;
use
rustc_middle
::
ty
::{
self
,
ReprOptions
,
Ty
};
use
rustc_serialize
::
opaque
::
Encoder
;
use
rustc_session
::
config
::
SymbolManglingVersion
;
...
...
@@ -305,7 +306,7 @@ fn encode(&self, buf: &mut Encoder) -> LazyTables<'tcx> {
mir
:
Table
<
DefIndex
,
Lazy!
(
mir
::
Body
<
'tcx
>
)
>
,
mir_for_ctfe
:
Table
<
DefIndex
,
Lazy!
(
mir
::
Body
<
'tcx
>
)
>
,
promoted_mir
:
Table
<
DefIndex
,
Lazy!
(
IndexVec
<
mir
::
Promoted
,
mir
::
Body
<
'tcx
>>
)
>
,
mir_abstract_consts
:
Table
<
DefIndex
,
Lazy!
(
&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
])
>
,
thir_abstract_consts
:
Table
<
DefIndex
,
Lazy!
(
&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
])
>
,
const_defaults
:
Table
<
DefIndex
,
Lazy
<
rustc_middle
::
ty
::
Const
<
'tcx
>>>
,
unused_generic_params
:
Table
<
DefIndex
,
Lazy
<
FiniteBitSet
<
u32
>>>
,
// `def_keys` and `def_path_hashes` represent a lazy version of a
...
...
compiler/rustc_middle/src/mir/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -40,7 +40,6 @@
use
self
::
predecessors
::{
PredecessorCache
,
Predecessors
};
pub
use
self
::
query
::
*
;
pub
mod
abstract_const
;
pub
mod
coverage
;
mod
generic_graph
;
pub
mod
generic_graphviz
;
...
...
compiler/rustc_middle/src/mir/query.rs
浏览文件 @
406d2ab9
//! Values computed by queries that use MIR.
use
crate
::
mir
::{
abstract_const
,
Body
,
Promoted
};
use
crate
::
mir
::{
Body
,
Promoted
};
use
crate
::
thir
::
abstract_const
;
use
crate
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_data_structures
::
vec_map
::
VecMap
;
...
...
@@ -433,14 +434,14 @@ pub fn mir_for_ctfe_opt_const_arg(self, def: ty::WithOptConstParam<DefId>) -> &'
}
#[inline]
pub
fn
m
ir_abstract_const_opt_const_arg
(
pub
fn
th
ir_abstract_const_opt_const_arg
(
self
,
def
:
ty
::
WithOptConstParam
<
DefId
>
,
)
->
Result
<
Option
<&
'tcx
[
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
if
let
Some
((
did
,
param_did
))
=
def
.as_const_arg
()
{
self
.
m
ir_abstract_const_of_const_arg
((
did
,
param_did
))
self
.
th
ir_abstract_const_of_const_arg
((
did
,
param_did
))
}
else
{
self
.
m
ir_abstract_const
(
def
.did
)
self
.
th
ir_abstract_const
(
def
.did
)
}
}
}
compiler/rustc_middle/src/query/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -295,17 +295,17 @@
}
/// Try to build an abstract representation of the given constant.
query
m
ir_abstract_const
(
query
th
ir_abstract_const
(
key
:
DefId
)
->
Result
<
Option
<&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
)
->
Result
<
Option
<&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
desc
{
|
tcx
|
"building an abstract representation for {}"
,
tcx
.def_path_str
(
key
),
}
}
/// Try to build an abstract representation of the given constant.
query
m
ir_abstract_const_of_const_arg
(
query
th
ir_abstract_const_of_const_arg
(
key
:
(
LocalDefId
,
DefId
)
)
->
Result
<
Option
<&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
)
->
Result
<
Option
<&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
desc
{
|
tcx
|
"building an abstract representation for the const argument {}"
,
...
...
compiler/rustc_middle/src/thir.rs
浏览文件 @
406d2ab9
...
...
@@ -33,6 +33,9 @@
use
std
::
fmt
;
use
std
::
ops
::
Index
;
pub
mod
abstract_const
;
pub
mod
visit
;
newtype_index!
{
/// An index to an [`Arm`] stored in [`Thir::arms`]
#[derive(HashStable)]
...
...
@@ -818,246 +821,3 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
}
pub
mod
visit
{
use
super
::
*
;
pub
trait
Visitor
<
'a
,
'tcx
:
'a
>
:
Sized
{
fn
thir
(
&
self
)
->
&
'a
Thir
<
'tcx
>
;
fn
visit_expr
(
&
mut
self
,
expr
:
&
Expr
<
'tcx
>
)
{
walk_expr
(
self
,
expr
);
}
fn
visit_stmt
(
&
mut
self
,
stmt
:
&
Stmt
<
'tcx
>
)
{
walk_stmt
(
self
,
stmt
);
}
fn
visit_block
(
&
mut
self
,
block
:
&
Block
)
{
walk_block
(
self
,
block
);
}
fn
visit_arm
(
&
mut
self
,
arm
:
&
Arm
<
'tcx
>
)
{
walk_arm
(
self
,
arm
);
}
fn
visit_pat
(
&
mut
self
,
pat
:
&
Pat
<
'tcx
>
)
{
walk_pat
(
self
,
pat
);
}
fn
visit_const
(
&
mut
self
,
_
cnst
:
&
'tcx
Const
<
'tcx
>
)
{}
}
pub
fn
walk_expr
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
expr
:
&
Expr
<
'tcx
>
)
{
use
ExprKind
::
*
;
match
expr
.kind
{
Scope
{
value
,
region_scope
:
_
,
lint_level
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
Box
{
value
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]),
If
{
cond
,
then
,
else_opt
,
if_then_scope
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
cond
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
then
]);
if
let
Some
(
else_expr
)
=
else_opt
{
visitor
.visit_expr
(
&
visitor
.thir
()[
else_expr
]);
}
}
Call
{
fun
,
ref
args
,
ty
:
_
,
from_hir_call
:
_
,
fn_span
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
fun
]);
for
&
arg
in
&**
args
{
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]);
}
}
Deref
{
arg
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
Binary
{
lhs
,
rhs
,
op
:
_
}
|
LogicalOp
{
lhs
,
rhs
,
op
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
rhs
]);
}
Unary
{
arg
,
op
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
Cast
{
source
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
Use
{
source
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
NeverToAny
{
source
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
Pointer
{
source
,
cast
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
Let
{
expr
,
..
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]);
}
Loop
{
body
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
body
]),
Match
{
scrutinee
,
ref
arms
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
scrutinee
]);
for
&
arm
in
&**
arms
{
visitor
.visit_arm
(
&
visitor
.thir
()[
arm
]);
}
}
Block
{
ref
body
}
=>
visitor
.visit_block
(
body
),
Assign
{
lhs
,
rhs
}
|
AssignOp
{
lhs
,
rhs
,
op
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
rhs
]);
}
Field
{
lhs
,
name
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]),
Index
{
lhs
,
index
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
index
]);
}
VarRef
{
id
:
_
}
|
UpvarRef
{
closure_def_id
:
_
,
var_hir_id
:
_
}
=>
{}
Borrow
{
arg
,
borrow_kind
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
AddressOf
{
arg
,
mutability
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
Break
{
value
,
label
:
_
}
=>
{
if
let
Some
(
value
)
=
value
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
}
Continue
{
label
:
_
}
=>
{}
Return
{
value
}
=>
{
if
let
Some
(
value
)
=
value
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
}
ConstBlock
{
value
}
=>
visitor
.visit_const
(
value
),
Repeat
{
value
,
count
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]);
visitor
.visit_const
(
count
);
}
Array
{
ref
fields
}
|
Tuple
{
ref
fields
}
=>
{
for
&
field
in
&**
fields
{
visitor
.visit_expr
(
&
visitor
.thir
()[
field
]);
}
}
Adt
(
box
crate
::
thir
::
Adt
{
ref
fields
,
ref
base
,
adt_def
:
_
,
variant_index
:
_
,
substs
:
_
,
user_ty
:
_
,
})
=>
{
for
field
in
&**
fields
{
visitor
.visit_expr
(
&
visitor
.thir
()[
field
.expr
]);
}
if
let
Some
(
base
)
=
base
{
visitor
.visit_expr
(
&
visitor
.thir
()[
base
.base
]);
}
}
PlaceTypeAscription
{
source
,
user_ty
:
_
}
|
ValueTypeAscription
{
source
,
user_ty
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
source
])
}
Closure
{
closure_id
:
_
,
substs
:
_
,
upvars
:
_
,
movability
:
_
,
fake_reads
:
_
}
=>
{}
Literal
{
literal
,
user_ty
:
_
,
const_id
:
_
}
=>
visitor
.visit_const
(
literal
),
StaticRef
{
literal
,
def_id
:
_
}
=>
visitor
.visit_const
(
literal
),
InlineAsm
{
ref
operands
,
template
:
_
,
options
:
_
,
line_spans
:
_
}
=>
{
for
op
in
&**
operands
{
use
InlineAsmOperand
::
*
;
match
op
{
In
{
expr
,
reg
:
_
}
|
Out
{
expr
:
Some
(
expr
),
reg
:
_
,
late
:
_
}
|
InOut
{
expr
,
reg
:
_
,
late
:
_
}
|
SymFn
{
expr
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
*
expr
]),
SplitInOut
{
in_expr
,
out_expr
,
reg
:
_
,
late
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
*
in_expr
]);
if
let
Some
(
out_expr
)
=
out_expr
{
visitor
.visit_expr
(
&
visitor
.thir
()[
*
out_expr
]);
}
}
Out
{
expr
:
None
,
reg
:
_
,
late
:
_
}
|
Const
{
value
:
_
,
span
:
_
}
|
SymStatic
{
def_id
:
_
}
=>
{}
}
}
}
ThreadLocalRef
(
_
)
=>
{}
LlvmInlineAsm
{
ref
outputs
,
ref
inputs
,
asm
:
_
}
=>
{
for
&
out_expr
in
&**
outputs
{
visitor
.visit_expr
(
&
visitor
.thir
()[
out_expr
]);
}
for
&
in_expr
in
&**
inputs
{
visitor
.visit_expr
(
&
visitor
.thir
()[
in_expr
]);
}
}
Yield
{
value
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]),
}
}
pub
fn
walk_stmt
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
stmt
:
&
Stmt
<
'tcx
>
)
{
match
&
stmt
.kind
{
StmtKind
::
Expr
{
expr
,
scope
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
*
expr
]),
StmtKind
::
Let
{
initializer
,
remainder_scope
:
_
,
init_scope
:
_
,
ref
pattern
,
lint_level
:
_
,
}
=>
{
if
let
Some
(
init
)
=
initializer
{
visitor
.visit_expr
(
&
visitor
.thir
()[
*
init
]);
}
visitor
.visit_pat
(
pattern
);
}
}
}
pub
fn
walk_block
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
block
:
&
Block
)
{
for
&
stmt
in
&*
block
.stmts
{
visitor
.visit_stmt
(
&
visitor
.thir
()[
stmt
]);
}
if
let
Some
(
expr
)
=
block
.expr
{
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]);
}
}
pub
fn
walk_arm
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
arm
:
&
Arm
<
'tcx
>
)
{
match
arm
.guard
{
Some
(
Guard
::
If
(
expr
))
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]),
Some
(
Guard
::
IfLet
(
ref
pat
,
expr
))
=>
{
visitor
.visit_pat
(
pat
);
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]);
}
None
=>
{}
}
visitor
.visit_pat
(
&
arm
.pattern
);
visitor
.visit_expr
(
&
visitor
.thir
()[
arm
.body
]);
}
pub
fn
walk_pat
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
pat
:
&
Pat
<
'tcx
>
)
{
use
PatKind
::
*
;
match
pat
.kind
.as_ref
()
{
AscribeUserType
{
subpattern
,
ascription
:
_
}
|
Deref
{
subpattern
}
|
Binding
{
subpattern
:
Some
(
subpattern
),
mutability
:
_
,
mode
:
_
,
var
:
_
,
ty
:
_
,
is_primary
:
_
,
name
:
_
,
}
=>
visitor
.visit_pat
(
&
subpattern
),
Binding
{
..
}
|
Wild
=>
{}
Variant
{
subpatterns
,
adt_def
:
_
,
substs
:
_
,
variant_index
:
_
}
|
Leaf
{
subpatterns
}
=>
{
for
subpattern
in
subpatterns
{
visitor
.visit_pat
(
&
subpattern
.pattern
);
}
}
Constant
{
value
}
=>
visitor
.visit_const
(
value
),
Range
(
range
)
=>
{
visitor
.visit_const
(
range
.lo
);
visitor
.visit_const
(
range
.hi
);
}
Slice
{
prefix
,
slice
,
suffix
}
|
Array
{
prefix
,
slice
,
suffix
}
=>
{
for
subpattern
in
prefix
{
visitor
.visit_pat
(
&
subpattern
);
}
if
let
Some
(
pat
)
=
slice
{
visitor
.visit_pat
(
pat
);
}
for
subpattern
in
suffix
{
visitor
.visit_pat
(
&
subpattern
);
}
}
Or
{
pats
}
=>
{
for
pat
in
pats
{
visitor
.visit_pat
(
&
pat
);
}
}
};
}
}
compiler/rustc_middle/src/
m
ir/abstract_const.rs
→
compiler/rustc_middle/src/
th
ir/abstract_const.rs
浏览文件 @
406d2ab9
文件已移动
compiler/rustc_middle/src/thir/visit.rs
0 → 100644
浏览文件 @
406d2ab9
use
super
::
*
;
pub
trait
Visitor
<
'a
,
'tcx
:
'a
>
:
Sized
{
fn
thir
(
&
self
)
->
&
'a
Thir
<
'tcx
>
;
fn
visit_expr
(
&
mut
self
,
expr
:
&
Expr
<
'tcx
>
)
{
walk_expr
(
self
,
expr
);
}
fn
visit_stmt
(
&
mut
self
,
stmt
:
&
Stmt
<
'tcx
>
)
{
walk_stmt
(
self
,
stmt
);
}
fn
visit_block
(
&
mut
self
,
block
:
&
Block
)
{
walk_block
(
self
,
block
);
}
fn
visit_arm
(
&
mut
self
,
arm
:
&
Arm
<
'tcx
>
)
{
walk_arm
(
self
,
arm
);
}
fn
visit_pat
(
&
mut
self
,
pat
:
&
Pat
<
'tcx
>
)
{
walk_pat
(
self
,
pat
);
}
fn
visit_const
(
&
mut
self
,
_
cnst
:
&
'tcx
Const
<
'tcx
>
)
{}
}
pub
fn
walk_expr
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
expr
:
&
Expr
<
'tcx
>
)
{
use
ExprKind
::
*
;
match
expr
.kind
{
Scope
{
value
,
region_scope
:
_
,
lint_level
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
Box
{
value
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]),
If
{
cond
,
then
,
else_opt
,
if_then_scope
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
cond
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
then
]);
if
let
Some
(
else_expr
)
=
else_opt
{
visitor
.visit_expr
(
&
visitor
.thir
()[
else_expr
]);
}
}
Call
{
fun
,
ref
args
,
ty
:
_
,
from_hir_call
:
_
,
fn_span
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
fun
]);
for
&
arg
in
&**
args
{
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]);
}
}
Deref
{
arg
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
Binary
{
lhs
,
rhs
,
op
:
_
}
|
LogicalOp
{
lhs
,
rhs
,
op
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
rhs
]);
}
Unary
{
arg
,
op
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
Cast
{
source
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
Use
{
source
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
NeverToAny
{
source
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
Pointer
{
source
,
cast
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
source
]),
Let
{
expr
,
..
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]);
}
Loop
{
body
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
body
]),
Match
{
scrutinee
,
ref
arms
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
scrutinee
]);
for
&
arm
in
&**
arms
{
visitor
.visit_arm
(
&
visitor
.thir
()[
arm
]);
}
}
Block
{
ref
body
}
=>
visitor
.visit_block
(
body
),
Assign
{
lhs
,
rhs
}
|
AssignOp
{
lhs
,
rhs
,
op
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
rhs
]);
}
Field
{
lhs
,
name
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]),
Index
{
lhs
,
index
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
lhs
]);
visitor
.visit_expr
(
&
visitor
.thir
()[
index
]);
}
VarRef
{
id
:
_
}
|
UpvarRef
{
closure_def_id
:
_
,
var_hir_id
:
_
}
=>
{}
Borrow
{
arg
,
borrow_kind
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
AddressOf
{
arg
,
mutability
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
arg
]),
Break
{
value
,
label
:
_
}
=>
{
if
let
Some
(
value
)
=
value
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
}
Continue
{
label
:
_
}
=>
{}
Return
{
value
}
=>
{
if
let
Some
(
value
)
=
value
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
}
ConstBlock
{
value
}
=>
visitor
.visit_const
(
value
),
Repeat
{
value
,
count
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]);
visitor
.visit_const
(
count
);
}
Array
{
ref
fields
}
|
Tuple
{
ref
fields
}
=>
{
for
&
field
in
&**
fields
{
visitor
.visit_expr
(
&
visitor
.thir
()[
field
]);
}
}
Adt
(
box
crate
::
thir
::
Adt
{
ref
fields
,
ref
base
,
adt_def
:
_
,
variant_index
:
_
,
substs
:
_
,
user_ty
:
_
,
})
=>
{
for
field
in
&**
fields
{
visitor
.visit_expr
(
&
visitor
.thir
()[
field
.expr
]);
}
if
let
Some
(
base
)
=
base
{
visitor
.visit_expr
(
&
visitor
.thir
()[
base
.base
]);
}
}
PlaceTypeAscription
{
source
,
user_ty
:
_
}
|
ValueTypeAscription
{
source
,
user_ty
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
source
])
}
Closure
{
closure_id
:
_
,
substs
:
_
,
upvars
:
_
,
movability
:
_
,
fake_reads
:
_
}
=>
{}
Literal
{
literal
,
user_ty
:
_
,
const_id
:
_
}
=>
visitor
.visit_const
(
literal
),
StaticRef
{
literal
,
def_id
:
_
}
=>
visitor
.visit_const
(
literal
),
InlineAsm
{
ref
operands
,
template
:
_
,
options
:
_
,
line_spans
:
_
}
=>
{
for
op
in
&**
operands
{
use
InlineAsmOperand
::
*
;
match
op
{
In
{
expr
,
reg
:
_
}
|
Out
{
expr
:
Some
(
expr
),
reg
:
_
,
late
:
_
}
|
InOut
{
expr
,
reg
:
_
,
late
:
_
}
|
SymFn
{
expr
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
*
expr
]),
SplitInOut
{
in_expr
,
out_expr
,
reg
:
_
,
late
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
*
in_expr
]);
if
let
Some
(
out_expr
)
=
out_expr
{
visitor
.visit_expr
(
&
visitor
.thir
()[
*
out_expr
]);
}
}
Out
{
expr
:
None
,
reg
:
_
,
late
:
_
}
|
Const
{
value
:
_
,
span
:
_
}
|
SymStatic
{
def_id
:
_
}
=>
{}
}
}
}
ThreadLocalRef
(
_
)
=>
{}
LlvmInlineAsm
{
ref
outputs
,
ref
inputs
,
asm
:
_
}
=>
{
for
&
out_expr
in
&**
outputs
{
visitor
.visit_expr
(
&
visitor
.thir
()[
out_expr
]);
}
for
&
in_expr
in
&**
inputs
{
visitor
.visit_expr
(
&
visitor
.thir
()[
in_expr
]);
}
}
Yield
{
value
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]),
}
}
pub
fn
walk_stmt
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
stmt
:
&
Stmt
<
'tcx
>
)
{
match
&
stmt
.kind
{
StmtKind
::
Expr
{
expr
,
scope
:
_
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
*
expr
]),
StmtKind
::
Let
{
initializer
,
remainder_scope
:
_
,
init_scope
:
_
,
ref
pattern
,
lint_level
:
_
,
}
=>
{
if
let
Some
(
init
)
=
initializer
{
visitor
.visit_expr
(
&
visitor
.thir
()[
*
init
]);
}
visitor
.visit_pat
(
pattern
);
}
}
}
pub
fn
walk_block
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
block
:
&
Block
)
{
for
&
stmt
in
&*
block
.stmts
{
visitor
.visit_stmt
(
&
visitor
.thir
()[
stmt
]);
}
if
let
Some
(
expr
)
=
block
.expr
{
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]);
}
}
pub
fn
walk_arm
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
arm
:
&
Arm
<
'tcx
>
)
{
match
arm
.guard
{
Some
(
Guard
::
If
(
expr
))
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]),
Some
(
Guard
::
IfLet
(
ref
pat
,
expr
))
=>
{
visitor
.visit_pat
(
pat
);
visitor
.visit_expr
(
&
visitor
.thir
()[
expr
]);
}
None
=>
{}
}
visitor
.visit_pat
(
&
arm
.pattern
);
visitor
.visit_expr
(
&
visitor
.thir
()[
arm
.body
]);
}
pub
fn
walk_pat
<
'a
,
'tcx
:
'a
,
V
:
Visitor
<
'a
,
'tcx
>>
(
visitor
:
&
mut
V
,
pat
:
&
Pat
<
'tcx
>
)
{
use
PatKind
::
*
;
match
pat
.kind
.as_ref
()
{
AscribeUserType
{
subpattern
,
ascription
:
_
}
|
Deref
{
subpattern
}
|
Binding
{
subpattern
:
Some
(
subpattern
),
mutability
:
_
,
mode
:
_
,
var
:
_
,
ty
:
_
,
is_primary
:
_
,
name
:
_
,
}
=>
visitor
.visit_pat
(
&
subpattern
),
Binding
{
..
}
|
Wild
=>
{}
Variant
{
subpatterns
,
adt_def
:
_
,
substs
:
_
,
variant_index
:
_
}
|
Leaf
{
subpatterns
}
=>
{
for
subpattern
in
subpatterns
{
visitor
.visit_pat
(
&
subpattern
.pattern
);
}
}
Constant
{
value
}
=>
visitor
.visit_const
(
value
),
Range
(
range
)
=>
{
visitor
.visit_const
(
range
.lo
);
visitor
.visit_const
(
range
.hi
);
}
Slice
{
prefix
,
slice
,
suffix
}
|
Array
{
prefix
,
slice
,
suffix
}
=>
{
for
subpattern
in
prefix
{
visitor
.visit_pat
(
&
subpattern
);
}
if
let
Some
(
pat
)
=
slice
{
visitor
.visit_pat
(
pat
);
}
for
subpattern
in
suffix
{
visitor
.visit_pat
(
&
subpattern
);
}
}
Or
{
pats
}
=>
{
for
pat
in
pats
{
visitor
.visit_pat
(
&
pat
);
}
}
};
}
compiler/rustc_middle/src/traits/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -9,7 +9,7 @@
mod
structural_impls
;
use
crate
::
infer
::
canonical
::
Canonical
;
use
crate
::
m
ir
::
abstract_const
::
NotConstEvaluatable
;
use
crate
::
th
ir
::
abstract_const
::
NotConstEvaluatable
;
use
crate
::
ty
::
subst
::
SubstsRef
;
use
crate
::
ty
::{
self
,
AdtKind
,
Ty
,
TyCtxt
};
...
...
compiler/rustc_middle/src/ty/codec.rs
浏览文件 @
406d2ab9
...
...
@@ -12,6 +12,7 @@
self
,
interpret
::{
AllocId
,
Allocation
},
};
use
crate
::
thir
;
use
crate
::
ty
::
subst
::
SubstsRef
;
use
crate
::
ty
::{
self
,
List
,
Ty
,
TyCtxt
};
use
rustc_data_structures
::
fx
::
FxHashMap
;
...
...
@@ -362,7 +363,7 @@ fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
}
}
impl
<
'tcx
,
D
:
TyDecoder
<
'tcx
>>
RefDecodable
<
'tcx
,
D
>
for
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
impl
<
'tcx
,
D
:
TyDecoder
<
'tcx
>>
RefDecodable
<
'tcx
,
D
>
for
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
fn
decode
(
decoder
:
&
mut
D
)
->
Result
<&
'tcx
Self
,
D
::
Error
>
{
Ok
(
decoder
.tcx
()
.arena
.alloc_from_iter
(
(
0
..
decoder
.read_usize
()
?
)
...
...
@@ -372,7 +373,7 @@ fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
}
}
impl
<
'tcx
,
D
:
TyDecoder
<
'tcx
>>
RefDecodable
<
'tcx
,
D
>
for
[
m
ir
::
abstract_const
::
NodeId
]
{
impl
<
'tcx
,
D
:
TyDecoder
<
'tcx
>>
RefDecodable
<
'tcx
,
D
>
for
[
th
ir
::
abstract_const
::
NodeId
]
{
fn
decode
(
decoder
:
&
mut
D
)
->
Result
<&
'tcx
Self
,
D
::
Error
>
{
Ok
(
decoder
.tcx
()
.arena
.alloc_from_iter
(
(
0
..
decoder
.read_usize
()
?
)
...
...
compiler/rustc_mir_build/src/build/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -48,11 +48,11 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
match
def
{
ty
::
WithOptConstParam
{
did
,
const_param_did
:
Some
(
const_param_did
)
}
=>
{
tcx
.ensure
()
.thir_check_unsafety_for_const_arg
((
did
,
const_param_did
));
tcx
.ensure
()
.
m
ir_abstract_const_of_const_arg
((
did
,
const_param_did
));
tcx
.ensure
()
.
th
ir_abstract_const_of_const_arg
((
did
,
const_param_did
));
}
ty
::
WithOptConstParam
{
did
,
const_param_did
:
None
}
=>
{
tcx
.ensure
()
.thir_check_unsafety
(
did
);
tcx
.ensure
()
.
m
ir_abstract_const
(
did
);
tcx
.ensure
()
.
th
ir_abstract_const
(
did
);
}
}
...
...
compiler/rustc_mir_transform/src/lib.rs
浏览文件 @
406d2ab9
...
...
@@ -307,7 +307,6 @@ fn mir_promoted(
// this point, before we steal the mir-const result.
// Also this means promotion can rely on all const checks having been done.
let
_
=
tcx
.mir_const_qualif_opt_const_arg
(
def
);
let
_
=
tcx
.mir_abstract_const_opt_const_arg
(
def
.to_global
());
let
mut
body
=
tcx
.mir_const
(
def
)
.steal
();
let
mut
required_consts
=
Vec
::
new
();
...
...
compiler/rustc_privacy/src/lib.rs
浏览文件 @
406d2ab9
...
...
@@ -19,8 +19,8 @@
use
rustc_middle
::
bug
;
use
rustc_middle
::
hir
::
map
::
Map
;
use
rustc_middle
::
middle
::
privacy
::{
AccessLevel
,
AccessLevels
};
use
rustc_middle
::
mir
::
abstract_const
::
Node
as
ACNode
;
use
rustc_middle
::
span_bug
;
use
rustc_middle
::
thir
::
abstract_const
::
Node
as
ACNode
;
use
rustc_middle
::
ty
::
fold
::
TypeVisitor
;
use
rustc_middle
::
ty
::
query
::
Providers
;
use
rustc_middle
::
ty
::
subst
::{
InternalSubsts
,
Subst
};
...
...
compiler/rustc_query_impl/src/on_disk_cache.rs
浏览文件 @
406d2ab9
...
...
@@ -9,6 +9,7 @@
use
rustc_middle
::
dep_graph
::{
DepNode
,
DepNodeIndex
,
SerializedDepNodeIndex
};
use
rustc_middle
::
mir
::
interpret
::{
AllocDecodingSession
,
AllocDecodingState
};
use
rustc_middle
::
mir
::{
self
,
interpret
};
use
rustc_middle
::
thir
;
use
rustc_middle
::
ty
::
codec
::{
RefDecodable
,
TyDecoder
,
TyEncoder
};
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_query_system
::
dep_graph
::
DepContext
;
...
...
@@ -906,7 +907,7 @@ fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Result<Self, String> {
}
}
impl
<
'a
,
'tcx
>
Decodable
<
CacheDecoder
<
'a
,
'tcx
>>
for
&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
impl
<
'a
,
'tcx
>
Decodable
<
CacheDecoder
<
'a
,
'tcx
>>
for
&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
{
fn
decode
(
d
:
&
mut
CacheDecoder
<
'a
,
'tcx
>
)
->
Result
<
Self
,
String
>
{
RefDecodable
::
decode
(
d
)
}
...
...
compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
浏览文件 @
406d2ab9
...
...
@@ -6,7 +6,7 @@
//! this is not as easy.
//!
//! In this case we try to build an abstract representation of this constant using
//! `
m
ir_abstract_const` which can then be checked for structural equality with other
//! `
th
ir_abstract_const` which can then be checked for structural equality with other
//! generic constants mentioned in the `caller_bounds` of the current environment.
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_errors
::
ErrorReported
;
...
...
@@ -14,9 +14,9 @@
use
rustc_index
::
vec
::
IndexVec
;
use
rustc_infer
::
infer
::
InferCtxt
;
use
rustc_middle
::
mir
;
use
rustc_middle
::
mir
::
abstract_const
::{
Node
,
NodeId
,
NotConstEvaluatable
};
use
rustc_middle
::
mir
::
interpret
::
ErrorHandled
;
use
rustc_middle
::
thir
;
use
rustc_middle
::
thir
::
abstract_const
::{
Node
,
NodeId
,
NotConstEvaluatable
};
use
rustc_middle
::
ty
::
subst
::{
Subst
,
SubstsRef
};
use
rustc_middle
::
ty
::{
self
,
TyCtxt
,
TypeFoldable
};
use
rustc_session
::
lint
;
...
...
@@ -197,7 +197,7 @@ pub fn new(
tcx
:
TyCtxt
<
'tcx
>
,
uv
:
ty
::
Unevaluated
<
'tcx
,
()
>
,
)
->
Result
<
Option
<
AbstractConst
<
'tcx
>>
,
ErrorReported
>
{
let
inner
=
tcx
.
m
ir_abstract_const_opt_const_arg
(
uv
.def
)
?
;
let
inner
=
tcx
.
th
ir_abstract_const_opt_const_arg
(
uv
.def
)
?
;
debug!
(
"AbstractConst::new({:?}) = {:?}"
,
uv
,
inner
);
Ok
(
inner
.map
(|
inner
|
AbstractConst
{
inner
,
substs
:
uv
.substs
(
tcx
)
}))
}
...
...
@@ -421,10 +421,10 @@ fn recurse_build(&mut self, node: thir::ExprId) -> Result<NodeId, ErrorReported>
}
/// Builds an abstract const, do not use this directly, but use `AbstractConst::new` instead.
pub
(
super
)
fn
m
ir_abstract_const
<
'tcx
>
(
pub
(
super
)
fn
th
ir_abstract_const
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
def
:
ty
::
WithOptConstParam
<
LocalDefId
>
,
)
->
Result
<
Option
<&
'tcx
[
m
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
)
->
Result
<
Option
<&
'tcx
[
th
ir
::
abstract_const
::
Node
<
'tcx
>
]
>
,
ErrorReported
>
{
if
tcx
.features
()
.generic_const_exprs
{
match
tcx
.def_kind
(
def
.did
)
{
// FIXME(generic_const_exprs): We currently only do this for anonymous constants,
...
...
compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -19,7 +19,7 @@
use
rustc_hir
::
GenericParam
;
use
rustc_hir
::
Item
;
use
rustc_hir
::
Node
;
use
rustc_middle
::
m
ir
::
abstract_const
::
NotConstEvaluatable
;
use
rustc_middle
::
th
ir
::
abstract_const
::
NotConstEvaluatable
;
use
rustc_middle
::
ty
::
error
::
ExpectedFound
;
use
rustc_middle
::
ty
::
fold
::
TypeFolder
;
use
rustc_middle
::
ty
::{
...
...
compiler/rustc_trait_selection/src/traits/fulfill.rs
浏览文件 @
406d2ab9
...
...
@@ -5,8 +5,8 @@
use
rustc_errors
::
ErrorReported
;
use
rustc_hir
as
hir
;
use
rustc_infer
::
traits
::{
SelectionError
,
TraitEngine
,
TraitEngineExt
as
_
,
TraitObligation
};
use
rustc_middle
::
mir
::
abstract_const
::
NotConstEvaluatable
;
use
rustc_middle
::
mir
::
interpret
::
ErrorHandled
;
use
rustc_middle
::
thir
::
abstract_const
::
NotConstEvaluatable
;
use
rustc_middle
::
ty
::
error
::{
ExpectedFound
,
TypeError
};
use
rustc_middle
::
ty
::
subst
::
SubstsRef
;
use
rustc_middle
::
ty
::
ToPredicate
;
...
...
compiler/rustc_trait_selection/src/traits/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -827,16 +827,16 @@ pub fn provide(providers: &mut ty::query::Providers) {
vtable_entries
,
vtable_trait_upcasting_coercion_new_vptr_slot
,
subst_and_check_impossible_predicates
,
m
ir_abstract_const
:
|
tcx
,
def_id
|
{
th
ir_abstract_const
:
|
tcx
,
def_id
|
{
let
def_id
=
def_id
.expect_local
();
if
let
Some
(
def
)
=
ty
::
WithOptConstParam
::
try_lookup
(
def_id
,
tcx
)
{
tcx
.
m
ir_abstract_const_of_const_arg
(
def
)
tcx
.
th
ir_abstract_const_of_const_arg
(
def
)
}
else
{
const_evaluatable
::
m
ir_abstract_const
(
tcx
,
ty
::
WithOptConstParam
::
unknown
(
def_id
))
const_evaluatable
::
th
ir_abstract_const
(
tcx
,
ty
::
WithOptConstParam
::
unknown
(
def_id
))
}
},
m
ir_abstract_const_of_const_arg
:
|
tcx
,
(
did
,
param_did
)|
{
const_evaluatable
::
m
ir_abstract_const
(
th
ir_abstract_const_of_const_arg
:
|
tcx
,
(
did
,
param_did
)|
{
const_evaluatable
::
th
ir_abstract_const
(
tcx
,
ty
::
WithOptConstParam
{
did
,
const_param_did
:
Some
(
param_did
)
},
)
...
...
compiler/rustc_trait_selection/src/traits/object_safety.rs
浏览文件 @
406d2ab9
...
...
@@ -836,7 +836,7 @@ fn visit_unevaluated_const(
//
// This shouldn't really matter though as we can't really use any
// constants which are not considered const evaluatable.
use
rustc_middle
::
m
ir
::
abstract_const
::
Node
;
use
rustc_middle
::
th
ir
::
abstract_const
::
Node
;
if
let
Ok
(
Some
(
ct
))
=
AbstractConst
::
new
(
self
.tcx
,
uv
.shrink
())
{
const_evaluatable
::
walk_abstract_const
(
self
.tcx
,
ct
,
|
node
|
match
node
.root
()
{
Node
::
Leaf
(
leaf
)
=>
{
...
...
compiler/rustc_trait_selection/src/traits/select/mod.rs
浏览文件 @
406d2ab9
...
...
@@ -34,8 +34,8 @@
use
rustc_hir
::
def_id
::
DefId
;
use
rustc_infer
::
infer
::
LateBoundRegionConversionTime
;
use
rustc_middle
::
dep_graph
::{
DepKind
,
DepNodeIndex
};
use
rustc_middle
::
mir
::
abstract_const
::
NotConstEvaluatable
;
use
rustc_middle
::
mir
::
interpret
::
ErrorHandled
;
use
rustc_middle
::
thir
::
abstract_const
::
NotConstEvaluatable
;
use
rustc_middle
::
ty
::
fast_reject
;
use
rustc_middle
::
ty
::
print
::
with_no_trimmed_paths
;
use
rustc_middle
::
ty
::
relate
::
TypeRelation
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录