Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1181f458
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
1181f458
编写于
10月 25, 2017
作者:
M
Maik Klein
提交者:
Ariel Ben-Yehuda
12月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename TransItem to MonoItem
上级
e579b067
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
116 addition
and
111 deletion
+116
-111
src/librustc/middle/trans.rs
src/librustc/middle/trans.rs
+8
-8
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+5
-0
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/monomorphize/collector.rs
+33
-33
src/librustc_mir/monomorphize/mono_item.rs
src/librustc_mir/monomorphize/mono_item.rs
+16
-16
src/librustc_trans/back/symbol_names.rs
src/librustc_trans/back/symbol_names.rs
+2
-2
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+4
-4
src/librustc_trans/consts.rs
src/librustc_trans/consts.rs
+3
-3
src/librustc_trans/partitioning.rs
src/librustc_trans/partitioning.rs
+25
-25
src/librustc_trans/trans_item.rs
src/librustc_trans/trans_item.rs
+20
-20
未找到文件。
src/librustc/middle/trans.rs
浏览文件 @
1181f458
...
...
@@ -17,24 +17,24 @@
use
ich
::{
Fingerprint
,
StableHashingContext
,
NodeIdHashingMode
};
#[derive(PartialEq,
Eq,
Clone,
Copy,
Debug,
Hash)]
pub
enum
Trans
Item
<
'tcx
>
{
pub
enum
Mono
Item
<
'tcx
>
{
Fn
(
Instance
<
'tcx
>
),
Static
(
NodeId
),
GlobalAsm
(
NodeId
),
}
impl
<
'tcx
>
HashStable
<
StableHashingContext
<
'tcx
>>
for
Trans
Item
<
'tcx
>
{
impl
<
'tcx
>
HashStable
<
StableHashingContext
<
'tcx
>>
for
Mono
Item
<
'tcx
>
{
fn
hash_stable
<
W
:
StableHasherResult
>
(
&
self
,
hcx
:
&
mut
StableHashingContext
<
'tcx
>
,
hasher
:
&
mut
StableHasher
<
W
>
)
{
::
std
::
mem
::
discriminant
(
self
)
.hash_stable
(
hcx
,
hasher
);
match
*
self
{
Trans
Item
::
Fn
(
ref
instance
)
=>
{
Mono
Item
::
Fn
(
ref
instance
)
=>
{
instance
.hash_stable
(
hcx
,
hasher
);
}
Trans
Item
::
Static
(
node_id
)
|
Trans
Item
::
GlobalAsm
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
|
Mono
Item
::
GlobalAsm
(
node_id
)
=>
{
hcx
.with_node_id_hashing_mode
(
NodeIdHashingMode
::
HashDefPath
,
|
hcx
|
{
node_id
.hash_stable
(
hcx
,
hasher
);
})
...
...
@@ -49,7 +49,7 @@ pub struct CodegenUnit<'tcx> {
/// contain something unique to this crate (e.g., a module path)
/// as well as the crate name and disambiguator.
name
:
InternedString
,
items
:
FxHashMap
<
Trans
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
,
items
:
FxHashMap
<
Mono
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
,
}
#[derive(Copy,
Clone,
PartialEq,
Eq,
Hash,
Debug)]
...
...
@@ -110,12 +110,12 @@ pub fn set_name(&mut self, name: InternedString) {
self
.name
=
name
;
}
pub
fn
items
(
&
self
)
->
&
FxHashMap
<
Trans
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
{
pub
fn
items
(
&
self
)
->
&
FxHashMap
<
Mono
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
{
&
self
.items
}
pub
fn
items_mut
(
&
mut
self
)
->
&
mut
FxHashMap
<
Trans
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
->
&
mut
FxHashMap
<
Mono
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
{
&
mut
self
.items
}
...
...
src/librustc/ty/mod.rs
浏览文件 @
1181f458
...
...
@@ -2471,6 +2471,11 @@ pub fn adjust_ident(self, mut ident: Ident, scope: DefId, block: NodeId) -> (Ide
}
}
impl
<
'a
,
'tcx
>
TyCtxt
<
'a
,
'tcx
,
'tcx
>
{
pub
fn
is_sized
(
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
ty
.is_sized
(
self
,
ty
::
ParamEnv
::
empty
(
traits
::
Reveal
::
All
),
DUMMY_SP
)
}
}
impl
<
'a
,
'gcx
,
'tcx
>
TyCtxt
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
with_freevars
<
T
,
F
>
(
self
,
fid
:
NodeId
,
f
:
F
)
->
T
where
F
:
FnOnce
(
&
[
hir
::
Freevar
])
->
T
,
...
...
src/librustc_mir/monomorphize/collector.rs
浏览文件 @
1181f458
...
...
@@ -195,7 +195,7 @@
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
middle
::
const_val
::
ConstVal
;
use
rustc
::
middle
::
lang_items
::{
ExchangeMallocFnLangItem
};
use
rustc
::
middle
::
trans
::
Trans
Item
;
use
rustc
::
middle
::
trans
::
Mono
Item
;
use
rustc
::
traits
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
TypeFoldable
,
Ty
,
TyCtxt
};
...
...
@@ -226,8 +226,8 @@ pub struct InliningMap<'tcx> {
// accessed by it.
// The two numbers in the tuple are the start (inclusive) and
// end index (exclusive) within the `targets` vecs.
index
:
FxHashMap
<
Trans
Item
<
'tcx
>
,
(
usize
,
usize
)
>
,
targets
:
Vec
<
Trans
Item
<
'tcx
>>
,
index
:
FxHashMap
<
Mono
Item
<
'tcx
>
,
(
usize
,
usize
)
>
,
targets
:
Vec
<
Mono
Item
<
'tcx
>>
,
// Contains one bit per translation item in the `targets` field. That bit
// is true if that translation item needs to be inlined into every CGU.
...
...
@@ -245,9 +245,9 @@ fn new() -> InliningMap<'tcx> {
}
fn
record_accesses
<
I
>
(
&
mut
self
,
source
:
Trans
Item
<
'tcx
>
,
source
:
Mono
Item
<
'tcx
>
,
new_targets
:
I
)
where
I
:
Iterator
<
Item
=
(
Trans
Item
<
'tcx
>
,
bool
)
>
+
ExactSizeIterator
where
I
:
Iterator
<
Item
=
(
Mono
Item
<
'tcx
>
,
bool
)
>
+
ExactSizeIterator
{
assert
!
(
!
self
.index
.contains_key
(
&
source
));
...
...
@@ -271,8 +271,8 @@ fn record_accesses<I>(&mut self,
// Internally iterate over all items referenced by `source` which will be
// made available for inlining.
pub
fn
with_inlining_candidates
<
F
>
(
&
self
,
source
:
Trans
Item
<
'tcx
>
,
mut
f
:
F
)
where
F
:
FnMut
(
Trans
Item
<
'tcx
>
)
pub
fn
with_inlining_candidates
<
F
>
(
&
self
,
source
:
Mono
Item
<
'tcx
>
,
mut
f
:
F
)
where
F
:
FnMut
(
Mono
Item
<
'tcx
>
)
{
if
let
Some
(
&
(
start_index
,
end_index
))
=
self
.index
.get
(
&
source
)
{
for
(
i
,
candidate
)
in
self
.targets
[
start_index
..
end_index
]
...
...
@@ -287,7 +287,7 @@ pub fn with_inlining_candidates<F>(&self, source: TransItem<'tcx>, mut f: F)
// Internally iterate over all items and the things each accesses.
pub
fn
iter_accesses
<
F
>
(
&
self
,
mut
f
:
F
)
where
F
:
FnMut
(
TransItem
<
'tcx
>
,
&
[
Trans
Item
<
'tcx
>
])
where
F
:
FnMut
(
MonoItem
<
'tcx
>
,
&
[
Mono
Item
<
'tcx
>
])
{
for
(
&
accessor
,
&
(
start_index
,
end_index
))
in
&
self
.index
{
f
(
accessor
,
&
self
.targets
[
start_index
..
end_index
])
...
...
@@ -297,7 +297,7 @@ pub fn iter_accesses<F>(&self, mut f: F)
pub
fn
collect_crate_translation_items
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
mode
:
TransItemCollectionMode
)
->
(
FxHashSet
<
Trans
Item
<
'tcx
>>
,
->
(
FxHashSet
<
Mono
Item
<
'tcx
>>
,
InliningMap
<
'tcx
>
)
{
let
roots
=
collect_roots
(
tcx
,
mode
);
...
...
@@ -321,7 +321,7 @@ pub fn collect_crate_translation_items<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// start monomorphizing from.
fn
collect_roots
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
mode
:
TransItemCollectionMode
)
->
Vec
<
Trans
Item
<
'tcx
>>
{
->
Vec
<
Mono
Item
<
'tcx
>>
{
debug!
(
"Collecting roots"
);
let
mut
roots
=
Vec
::
new
();
...
...
@@ -350,8 +350,8 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Collect all monomorphized translation items reachable from `starting_point`
fn
collect_items_rec
<
'a
,
'tcx
:
'a
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
starting_point
:
Trans
Item
<
'tcx
>
,
visited
:
&
mut
FxHashSet
<
Trans
Item
<
'tcx
>>
,
starting_point
:
Mono
Item
<
'tcx
>
,
visited
:
&
mut
FxHashSet
<
Mono
Item
<
'tcx
>>
,
recursion_depths
:
&
mut
DefIdMap
<
usize
>
,
inlining_map
:
&
mut
InliningMap
<
'tcx
>
)
{
if
!
visited
.insert
(
starting_point
.clone
())
{
...
...
@@ -364,7 +364,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let
recursion_depth_reset
;
match
starting_point
{
Trans
Item
::
Static
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
=>
{
let
def_id
=
tcx
.hir
.local_def_id
(
node_id
);
let
instance
=
Instance
::
mono
(
tcx
,
def_id
);
...
...
@@ -378,7 +378,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
collect_neighbours
(
tcx
,
instance
,
true
,
&
mut
neighbors
);
}
Trans
Item
::
Fn
(
instance
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
{
// Sanity check whether this ended up being collected accidentally
debug_assert!
(
should_trans_locally
(
tcx
,
&
instance
));
...
...
@@ -390,7 +390,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
collect_neighbours
(
tcx
,
instance
,
false
,
&
mut
neighbors
);
}
Trans
Item
::
GlobalAsm
(
..
)
=>
{
Mono
Item
::
GlobalAsm
(
..
)
=>
{
recursion_depth_reset
=
None
;
}
}
...
...
@@ -409,10 +409,10 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
fn
record_accesses
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
caller
:
Trans
Item
<
'tcx
>
,
callees
:
&
[
Trans
Item
<
'tcx
>
],
caller
:
Mono
Item
<
'tcx
>
,
callees
:
&
[
Mono
Item
<
'tcx
>
],
inlining_map
:
&
mut
InliningMap
<
'tcx
>
)
{
let
is_inlining_candidate
=
|
trans_item
:
&
Trans
Item
<
'tcx
>
|
{
let
is_inlining_candidate
=
|
trans_item
:
&
Mono
Item
<
'tcx
>
|
{
trans_item
.instantiation_mode
(
tcx
)
==
InstantiationMode
::
LocalCopy
};
...
...
@@ -495,7 +495,7 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct
MirNeighborCollector
<
'a
,
'tcx
:
'a
>
{
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
mir
:
&
'a
mir
::
Mir
<
'tcx
>
,
output
:
&
'a
mut
Vec
<
Trans
Item
<
'tcx
>>
,
output
:
&
'a
mut
Vec
<
Mono
Item
<
'tcx
>>
,
param_substs
:
&
'tcx
Substs
<
'tcx
>
,
const_context
:
bool
,
}
...
...
@@ -647,7 +647,7 @@ fn visit_static(&mut self,
let
instance
=
Instance
::
mono
(
tcx
,
static_
.def_id
);
if
should_trans_locally
(
tcx
,
&
instance
)
{
let
node_id
=
tcx
.hir
.as_local_node_id
(
static_
.def_id
)
.unwrap
();
self
.output
.push
(
Trans
Item
::
Static
(
node_id
));
self
.output
.push
(
Mono
Item
::
Static
(
node_id
));
}
self
.super_static
(
static_
,
context
,
location
);
...
...
@@ -657,7 +657,7 @@ fn visit_static(&mut self,
fn
visit_drop_use
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
ty
:
Ty
<
'tcx
>
,
is_direct_call
:
bool
,
output
:
&
mut
Vec
<
Trans
Item
<
'tcx
>>
)
output
:
&
mut
Vec
<
Mono
Item
<
'tcx
>>
)
{
let
instance
=
monomorphize
::
resolve_drop_in_place
(
tcx
,
ty
);
visit_instance_use
(
tcx
,
instance
,
is_direct_call
,
output
);
...
...
@@ -666,7 +666,7 @@ fn visit_drop_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn
visit_fn_use
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
ty
:
Ty
<
'tcx
>
,
is_direct_call
:
bool
,
output
:
&
mut
Vec
<
Trans
Item
<
'tcx
>>
)
output
:
&
mut
Vec
<
Mono
Item
<
'tcx
>>
)
{
if
let
ty
::
TyFnDef
(
def_id
,
substs
)
=
ty
.sty
{
let
instance
=
ty
::
Instance
::
resolve
(
tcx
,
...
...
@@ -680,7 +680,7 @@ fn visit_fn_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn
visit_instance_use
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
instance
:
ty
::
Instance
<
'tcx
>
,
is_direct_call
:
bool
,
output
:
&
mut
Vec
<
Trans
Item
<
'tcx
>>
)
output
:
&
mut
Vec
<
Mono
Item
<
'tcx
>>
)
{
debug!
(
"visit_item_use({:?}, is_direct_call={:?})"
,
instance
,
is_direct_call
);
if
!
should_trans_locally
(
tcx
,
&
instance
)
{
...
...
@@ -838,9 +838,9 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
fn
create_fn_trans_item
<
'a
,
'tcx
>
(
instance
:
Instance
<
'tcx
>
)
->
Trans
Item
<
'tcx
>
{
fn
create_fn_trans_item
<
'a
,
'tcx
>
(
instance
:
Instance
<
'tcx
>
)
->
Mono
Item
<
'tcx
>
{
debug!
(
"create_fn_trans_item(instance={})"
,
instance
);
Trans
Item
::
Fn
(
instance
)
Mono
Item
::
Fn
(
instance
)
}
/// Creates a `TransItem` for each method that is referenced by the vtable for
...
...
@@ -848,7 +848,7 @@ fn create_fn_trans_item<'a, 'tcx>(instance: Instance<'tcx>) -> TransItem<'tcx> {
fn
create_trans_items_for_vtable_methods
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
trait_ty
:
Ty
<
'tcx
>
,
impl_ty
:
Ty
<
'tcx
>
,
output
:
&
mut
Vec
<
Trans
Item
<
'tcx
>>
)
{
output
:
&
mut
Vec
<
Mono
Item
<
'tcx
>>
)
{
assert
!
(
!
trait_ty
.needs_subst
()
&&
!
trait_ty
.has_escaping_regions
()
&&
!
impl_ty
.needs_subst
()
&&
!
impl_ty
.has_escaping_regions
());
...
...
@@ -881,7 +881,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct
RootCollector
<
'b
,
'a
:
'b
,
'tcx
:
'a
+
'b
>
{
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
mode
:
TransItemCollectionMode
,
output
:
&
'b
mut
Vec
<
Trans
Item
<
'tcx
>>
,
output
:
&
'b
mut
Vec
<
Mono
Item
<
'tcx
>>
,
entry_fn
:
Option
<
DefId
>
,
}
...
...
@@ -925,13 +925,13 @@ fn visit_item(&mut self, item: &'v hir::Item) {
debug!
(
"RootCollector: ItemGlobalAsm({})"
,
def_id_to_string
(
self
.tcx
,
self
.tcx.hir
.local_def_id
(
item
.id
)));
self
.output
.push
(
Trans
Item
::
GlobalAsm
(
item
.id
));
self
.output
.push
(
Mono
Item
::
GlobalAsm
(
item
.id
));
}
hir
::
ItemStatic
(
..
)
=>
{
debug!
(
"RootCollector: ItemStatic({})"
,
def_id_to_string
(
self
.tcx
,
self
.tcx.hir
.local_def_id
(
item
.id
)));
self
.output
.push
(
Trans
Item
::
Static
(
item
.id
));
self
.output
.push
(
Mono
Item
::
Static
(
item
.id
));
}
hir
::
ItemConst
(
..
)
=>
{
// const items only generate translation items if they are
...
...
@@ -946,7 +946,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
def_id_to_string
(
tcx
,
def_id
));
let
instance
=
Instance
::
mono
(
tcx
,
def_id
);
self
.output
.push
(
Trans
Item
::
Fn
(
instance
));
self
.output
.push
(
Mono
Item
::
Fn
(
instance
));
}
}
}
...
...
@@ -968,7 +968,7 @@ fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
def_id_to_string
(
tcx
,
def_id
));
let
instance
=
Instance
::
mono
(
tcx
,
def_id
);
self
.output
.push
(
Trans
Item
::
Fn
(
instance
));
self
.output
.push
(
Mono
Item
::
Fn
(
instance
));
}
}
_
=>
{
/* Nothing to do here */
}
...
...
@@ -999,7 +999,7 @@ fn item_has_type_parameters<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
fn
create_trans_items_for_default_impls
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
item
:
&
'tcx
hir
::
Item
,
output
:
&
mut
Vec
<
Trans
Item
<
'tcx
>>
)
{
output
:
&
mut
Vec
<
Mono
Item
<
'tcx
>>
)
{
match
item
.node
{
hir
::
ItemImpl
(
_
,
_
,
...
...
@@ -1053,7 +1053,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn
collect_neighbours
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
,
const_context
:
bool
,
output
:
&
mut
Vec
<
Trans
Item
<
'tcx
>>
)
output
:
&
mut
Vec
<
Mono
Item
<
'tcx
>>
)
{
let
mir
=
tcx
.instance_mir
(
instance
.def
);
...
...
src/librustc_mir/monomorphize/mono_item.rs
浏览文件 @
1181f458
...
...
@@ -28,7 +28,7 @@
use
std
::
fmt
::{
self
,
Write
};
use
std
::
iter
;
pub
use
rustc
::
middle
::
trans
::
Trans
Item
;
pub
use
rustc
::
middle
::
trans
::
Mono
Item
;
pub
fn
linkage_by_name
(
name
:
&
str
)
->
Option
<
Linkage
>
{
use
rustc
::
middle
::
trans
::
Linkage
::
*
;
...
...
@@ -83,7 +83,7 @@ pub enum InstantiationMode {
}
pub
trait
TransItemExt
<
'a
,
'tcx
>
:
fmt
::
Debug
{
fn
as_trans_item
(
&
self
)
->
&
Trans
Item
<
'tcx
>
;
fn
as_trans_item
(
&
self
)
->
&
Mono
Item
<
'tcx
>
;
fn
instantiation_mode
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
...
...
@@ -94,7 +94,7 @@ fn instantiation_mode(&self,
});
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
ref
instance
)
=>
{
Mono
Item
::
Fn
(
ref
instance
)
=>
{
// If this function isn't inlined or otherwise has explicit
// linkage, then we'll be creating a globally shared version.
if
self
.explicit_linkage
(
tcx
)
.is_some
()
||
...
...
@@ -123,10 +123,10 @@ fn instantiation_mode(&self,
}
}
}
Trans
Item
::
Static
(
..
)
=>
{
Mono
Item
::
Static
(
..
)
=>
{
InstantiationMode
::
GloballyShared
{
may_conflict
:
false
}
}
Trans
Item
::
GlobalAsm
(
..
)
=>
{
Mono
Item
::
GlobalAsm
(
..
)
=>
{
InstantiationMode
::
GloballyShared
{
may_conflict
:
false
}
}
}
...
...
@@ -134,9 +134,9 @@ fn instantiation_mode(&self,
fn
explicit_linkage
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
Option
<
Linkage
>
{
let
def_id
=
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
ref
instance
)
=>
instance
.def_id
(),
Trans
Item
::
Static
(
node_id
)
=>
tcx
.hir
.local_def_id
(
node_id
),
Trans
Item
::
GlobalAsm
(
..
)
=>
return
None
,
Mono
Item
::
Fn
(
ref
instance
)
=>
instance
.def_id
(),
Mono
Item
::
Static
(
node_id
)
=>
tcx
.hir
.local_def_id
(
node_id
),
Mono
Item
::
GlobalAsm
(
..
)
=>
return
None
,
};
let
attributes
=
tcx
.get_attrs
(
def_id
);
...
...
@@ -184,10 +184,10 @@ fn explicit_linkage(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Linkage> {
fn
is_instantiable
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
bool
{
debug!
(
"is_instantiable({:?})"
,
self
);
let
(
def_id
,
substs
)
=
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
ref
instance
)
=>
(
instance
.def_id
(),
instance
.substs
),
Trans
Item
::
Static
(
node_id
)
=>
(
tcx
.hir
.local_def_id
(
node_id
),
Substs
::
empty
()),
Mono
Item
::
Fn
(
ref
instance
)
=>
(
instance
.def_id
(),
instance
.substs
),
Mono
Item
::
Static
(
node_id
)
=>
(
tcx
.hir
.local_def_id
(
node_id
),
Substs
::
empty
()),
// global asm never has predicates
Trans
Item
::
GlobalAsm
(
..
)
=>
return
true
Mono
Item
::
GlobalAsm
(
..
)
=>
return
true
};
let
predicates
=
tcx
.predicates_of
(
def_id
)
.predicates
.subst
(
tcx
,
substs
);
...
...
@@ -198,15 +198,15 @@ fn to_string(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String {
let
hir_map
=
&
tcx
.hir
;
return
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
instance
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
{
to_string_internal
(
tcx
,
"fn "
,
instance
)
},
Trans
Item
::
Static
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
=>
{
let
def_id
=
hir_map
.local_def_id
(
node_id
);
let
instance
=
Instance
::
new
(
def_id
,
tcx
.intern_substs
(
&
[]));
to_string_internal
(
tcx
,
"static "
,
instance
)
},
Trans
Item
::
GlobalAsm
(
..
)
=>
{
Mono
Item
::
GlobalAsm
(
..
)
=>
{
"global_asm"
.to_string
()
}
};
...
...
@@ -224,8 +224,8 @@ fn to_string_internal<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
impl
<
'a
,
'tcx
>
TransItemExt
<
'a
,
'tcx
>
for
Trans
Item
<
'tcx
>
{
fn
as_trans_item
(
&
self
)
->
&
Trans
Item
<
'tcx
>
{
impl
<
'a
,
'tcx
>
TransItemExt
<
'a
,
'tcx
>
for
Mono
Item
<
'tcx
>
{
fn
as_trans_item
(
&
self
)
->
&
Mono
Item
<
'tcx
>
{
self
}
}
...
...
src/librustc_trans/back/symbol_names.rs
浏览文件 @
1181f458
...
...
@@ -101,7 +101,7 @@
use
trans_item
::{
BaseTransItemExt
,
InstantiationMode
};
use
rustc
::
middle
::
weak_lang_items
;
use
rustc
::
middle
::
trans
::
Trans
Item
;
use
rustc
::
middle
::
trans
::
Mono
Item
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
hir
::
map
as
hir_map
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
TypeFoldable
};
...
...
@@ -211,7 +211,7 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// codegen units) then this symbol may become an exported (but hidden
// visibility) symbol. This means that multiple crates may do the same
// and we want to be sure to avoid any symbol conflicts here.
match
Trans
Item
::
Fn
(
instance
)
.instantiation_mode
(
tcx
)
{
match
Mono
Item
::
Fn
(
instance
)
.instantiation_mode
(
tcx
)
{
InstantiationMode
::
GloballyShared
{
may_conflict
:
true
}
=>
{
avoid_cross_crate_conflicts
=
true
;
}
...
...
src/librustc_trans/base.rs
浏览文件 @
1181f458
...
...
@@ -67,7 +67,7 @@
use
partitioning
::{
self
,
PartitioningStrategy
,
CodegenUnit
,
CodegenUnitExt
};
use
symbol_names_test
;
use
time_graph
;
use
trans_item
::{
Trans
Item
,
BaseTransItemExt
,
TransItemExt
,
DefPathBasedNames
};
use
trans_item
::{
Mono
Item
,
BaseTransItemExt
,
TransItemExt
,
DefPathBasedNames
};
use
type_
::
Type
;
use
type_of
::
LayoutLlvmExt
;
use
rustc
::
util
::
nodemap
::{
NodeSet
,
FxHashMap
,
FxHashSet
,
DefIdSet
};
...
...
@@ -530,7 +530,7 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
let
instance
=
Instance
::
mono
(
ccx
.tcx
(),
main_def_id
);
if
!
ccx
.codegen_unit
()
.contains_item
(
&
Trans
Item
::
Fn
(
instance
))
{
if
!
ccx
.codegen_unit
()
.contains_item
(
&
Mono
Item
::
Fn
(
instance
))
{
// We want to create the wrapper in the same codegen unit as Rust's main
// function.
return
;
...
...
@@ -943,7 +943,7 @@ fn assert_and_save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
#[inline(never)]
// give this a place in the profiler
fn
assert_symbols_are_distinct
<
'a
,
'tcx
,
I
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
trans_items
:
I
)
where
I
:
Iterator
<
Item
=&
'a
Trans
Item
<
'tcx
>>
where
I
:
Iterator
<
Item
=&
'a
Mono
Item
<
'tcx
>>
{
let
mut
symbols
:
Vec
<
_
>
=
trans_items
.map
(|
trans_item
|
{
(
trans_item
,
trans_item
.symbol_name
(
tcx
))
...
...
@@ -1042,7 +1042,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
let
translation_items
:
DefIdSet
=
items
.iter
()
.filter_map
(|
trans_item
|
{
match
*
trans_item
{
Trans
Item
::
Fn
(
ref
instance
)
=>
Some
(
instance
.def_id
()),
Mono
Item
::
Fn
(
ref
instance
)
=>
Some
(
instance
.def_id
()),
_
=>
None
,
}
})
.collect
();
...
...
src/librustc_trans/consts.rs
浏览文件 @
1181f458
...
...
@@ -16,7 +16,7 @@
use
rustc
::
middle
::
const_val
::
ConstEvalErr
;
use
debuginfo
;
use
base
;
use
trans_item
::{
Trans
Item
,
TransItemExt
};
use
trans_item
::{
Mono
Item
,
TransItemExt
};
use
common
::{
self
,
CrateContext
,
val_ty
};
use
declare
;
use
monomorphize
::
Instance
;
...
...
@@ -118,11 +118,11 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef {
hir_map
::
NodeItem
(
&
hir
::
Item
{
ref
attrs
,
span
,
node
:
hir
::
ItemStatic
(
..
),
..
})
=>
{
let
sym
=
Trans
Item
::
Static
(
id
)
.symbol_name
(
ccx
.tcx
());
let
sym
=
Mono
Item
::
Static
(
id
)
.symbol_name
(
ccx
.tcx
());
let
defined_in_current_codegen_unit
=
ccx
.codegen_unit
()
.items
()
.contains_key
(
&
Trans
Item
::
Static
(
id
));
.contains_key
(
&
Mono
Item
::
Static
(
id
));
assert
!
(
!
defined_in_current_codegen_unit
);
if
declare
::
get_declared_value
(
ccx
,
&
sym
[
..
])
.is_some
()
{
...
...
src/librustc_trans/partitioning.rs
浏览文件 @
1181f458
...
...
@@ -114,7 +114,7 @@
use
std
::
collections
::
hash_map
::
Entry
;
use
syntax
::
ast
::
NodeId
;
use
syntax
::
symbol
::{
Symbol
,
InternedString
};
use
trans_item
::{
Trans
Item
,
BaseTransItemExt
,
TransItemExt
,
InstantiationMode
};
use
trans_item
::{
Mono
Item
,
BaseTransItemExt
,
TransItemExt
,
InstantiationMode
};
pub
use
rustc
::
middle
::
trans
::
CodegenUnit
;
...
...
@@ -129,7 +129,7 @@ pub enum PartitioningStrategy {
pub
trait
CodegenUnitExt
<
'tcx
>
{
fn
as_codegen_unit
(
&
self
)
->
&
CodegenUnit
<
'tcx
>
;
fn
contains_item
(
&
self
,
item
:
&
Trans
Item
<
'tcx
>
)
->
bool
{
fn
contains_item
(
&
self
,
item
:
&
Mono
Item
<
'tcx
>
)
->
bool
{
self
.items
()
.contains_key
(
item
)
}
...
...
@@ -139,7 +139,7 @@ fn name<'a>(&'a self) -> &'a InternedString
&
self
.as_codegen_unit
()
.name
()
}
fn
items
(
&
self
)
->
&
FxHashMap
<
Trans
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
{
fn
items
(
&
self
)
->
&
FxHashMap
<
Mono
Item
<
'tcx
>
,
(
Linkage
,
Visibility
)
>
{
&
self
.as_codegen_unit
()
.items
()
}
...
...
@@ -149,17 +149,17 @@ fn work_product_id(&self) -> WorkProductId {
fn
items_in_deterministic_order
<
'a
>
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
Vec
<
(
Trans
Item
<
'tcx
>
,
(
Linkage
,
Visibility
))
>
{
->
Vec
<
(
Mono
Item
<
'tcx
>
,
(
Linkage
,
Visibility
))
>
{
// The codegen tests rely on items being process in the same order as
// they appear in the file, so for local items, we sort by node_id first
#[derive(PartialEq,
Eq,
PartialOrd,
Ord)]
pub
struct
ItemSortKey
(
Option
<
NodeId
>
,
ty
::
SymbolName
);
fn
item_sort_key
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
item
:
Trans
Item
<
'tcx
>
)
->
ItemSortKey
{
item
:
Mono
Item
<
'tcx
>
)
->
ItemSortKey
{
ItemSortKey
(
match
item
{
Trans
Item
::
Fn
(
ref
instance
)
=>
{
Mono
Item
::
Fn
(
ref
instance
)
=>
{
match
instance
.def
{
// We only want to take NodeIds of user-defined
// instances into account. The others don't matter for
...
...
@@ -178,8 +178,8 @@ fn item_sort_key<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
}
Trans
Item
::
Static
(
node_id
)
|
Trans
Item
::
GlobalAsm
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
|
Mono
Item
::
GlobalAsm
(
node_id
)
=>
{
Some
(
node_id
)
}
},
item
.symbol_name
(
tcx
))
...
...
@@ -207,7 +207,7 @@ pub fn partition<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
strategy
:
PartitioningStrategy
,
inlining_map
:
&
InliningMap
<
'tcx
>
)
->
Vec
<
CodegenUnit
<
'tcx
>>
where
I
:
Iterator
<
Item
=
Trans
Item
<
'tcx
>>
where
I
:
Iterator
<
Item
=
Mono
Item
<
'tcx
>>
{
// In the first step, we place all regular translation items into their
// respective 'home' codegen unit. Regular translation items are all
...
...
@@ -254,8 +254,8 @@ pub fn partition<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct
PreInliningPartitioning
<
'tcx
>
{
codegen_units
:
Vec
<
CodegenUnit
<
'tcx
>>
,
roots
:
FxHashSet
<
Trans
Item
<
'tcx
>>
,
internalization_candidates
:
FxHashSet
<
Trans
Item
<
'tcx
>>
,
roots
:
FxHashSet
<
Mono
Item
<
'tcx
>>
,
internalization_candidates
:
FxHashSet
<
Mono
Item
<
'tcx
>>
,
}
/// For symbol internalization, we need to know whether a symbol/trans-item is
...
...
@@ -269,14 +269,14 @@ enum TransItemPlacement {
struct
PostInliningPartitioning
<
'tcx
>
{
codegen_units
:
Vec
<
CodegenUnit
<
'tcx
>>
,
trans_item_placements
:
FxHashMap
<
Trans
Item
<
'tcx
>
,
TransItemPlacement
>
,
internalization_candidates
:
FxHashSet
<
Trans
Item
<
'tcx
>>
,
trans_item_placements
:
FxHashMap
<
Mono
Item
<
'tcx
>
,
TransItemPlacement
>
,
internalization_candidates
:
FxHashSet
<
Mono
Item
<
'tcx
>>
,
}
fn
place_root_translation_items
<
'a
,
'tcx
,
I
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
trans_items
:
I
)
->
PreInliningPartitioning
<
'tcx
>
where
I
:
Iterator
<
Item
=
Trans
Item
<
'tcx
>>
where
I
:
Iterator
<
Item
=
Mono
Item
<
'tcx
>>
{
let
mut
roots
=
FxHashSet
();
let
mut
codegen_units
=
FxHashMap
();
...
...
@@ -309,7 +309,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Some
(
explicit_linkage
)
=>
(
explicit_linkage
,
Visibility
::
Default
),
None
=>
{
match
trans_item
{
Trans
Item
::
Fn
(
ref
instance
)
=>
{
Mono
Item
::
Fn
(
ref
instance
)
=>
{
let
visibility
=
match
instance
.def
{
InstanceDef
::
Item
(
def_id
)
=>
{
if
def_id
.is_local
()
{
...
...
@@ -333,8 +333,8 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
};
(
Linkage
::
External
,
visibility
)
}
Trans
Item
::
Static
(
node_id
)
|
Trans
Item
::
GlobalAsm
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
|
Mono
Item
::
GlobalAsm
(
node_id
)
=>
{
let
def_id
=
tcx
.hir
.local_def_id
(
node_id
);
let
visibility
=
if
tcx
.is_exported_symbol
(
def_id
)
{
Visibility
::
Default
...
...
@@ -469,9 +469,9 @@ fn place_inlined_translation_items<'tcx>(initial_partitioning: PreInliningPartit
internalization_candidates
,
};
fn
follow_inlining
<
'tcx
>
(
trans_item
:
Trans
Item
<
'tcx
>
,
fn
follow_inlining
<
'tcx
>
(
trans_item
:
Mono
Item
<
'tcx
>
,
inlining_map
:
&
InliningMap
<
'tcx
>
,
visited
:
&
mut
FxHashSet
<
Trans
Item
<
'tcx
>>
)
{
visited
:
&
mut
FxHashSet
<
Mono
Item
<
'tcx
>>
)
{
if
!
visited
.insert
(
trans_item
)
{
return
;
}
...
...
@@ -501,7 +501,7 @@ fn internalize_symbols<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Build a map from every translation item to all the translation items that
// reference it.
let
mut
accessor_map
:
FxHashMap
<
TransItem
<
'tcx
>
,
Vec
<
Trans
Item
<
'tcx
>>>
=
FxHashMap
();
let
mut
accessor_map
:
FxHashMap
<
MonoItem
<
'tcx
>
,
Vec
<
Mono
Item
<
'tcx
>>>
=
FxHashMap
();
inlining_map
.iter_accesses
(|
accessor
,
accessees
|
{
for
accessee
in
accessees
{
accessor_map
.entry
(
*
accessee
)
...
...
@@ -548,10 +548,10 @@ fn internalize_symbols<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
fn
characteristic_def_id_of_trans_item
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
trans_item
:
Trans
Item
<
'tcx
>
)
trans_item
:
Mono
Item
<
'tcx
>
)
->
Option
<
DefId
>
{
match
trans_item
{
Trans
Item
::
Fn
(
instance
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
{
let
def_id
=
match
instance
.def
{
ty
::
InstanceDef
::
Item
(
def_id
)
=>
def_id
,
ty
::
InstanceDef
::
FnPtrShim
(
..
)
|
...
...
@@ -583,8 +583,8 @@ fn characteristic_def_id_of_trans_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Some
(
def_id
)
}
Trans
Item
::
Static
(
node_id
)
|
Trans
Item
::
GlobalAsm
(
node_id
)
=>
Some
(
tcx
.hir
.local_def_id
(
node_id
)),
Mono
Item
::
Static
(
node_id
)
|
Mono
Item
::
GlobalAsm
(
node_id
)
=>
Some
(
tcx
.hir
.local_def_id
(
node_id
)),
}
}
...
...
src/librustc_trans/trans_item.rs
浏览文件 @
1181f458
...
...
@@ -34,7 +34,7 @@
use
syntax_pos
::
symbol
::
Symbol
;
use
std
::
fmt
;
pub
use
rustc
::
middle
::
trans
::
Trans
Item
;
pub
use
rustc
::
middle
::
trans
::
Mono
Item
;
pub
use
rustc_mir
::
monomorphize
::
mono_item
::
*
;
pub
use
rustc_mir
::
monomorphize
::
mono_item
::
TransItemExt
as
BaseTransItemExt
;
...
...
@@ -47,7 +47,7 @@ fn define(&self, ccx: &CrateContext<'a, 'tcx>) {
ccx
.codegen_unit
()
.name
());
match
*
self
.as_trans_item
()
{
Trans
Item
::
Static
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
=>
{
let
tcx
=
ccx
.tcx
();
let
item
=
tcx
.hir
.expect_item
(
node_id
);
if
let
hir
::
ItemStatic
(
_
,
m
,
_
)
=
item
.node
{
...
...
@@ -61,7 +61,7 @@ fn define(&self, ccx: &CrateContext<'a, 'tcx>) {
span_bug!
(
item
.span
,
"Mismatch between hir::Item type and TransItem type"
)
}
}
Trans
Item
::
GlobalAsm
(
node_id
)
=>
{
Mono
Item
::
GlobalAsm
(
node_id
)
=>
{
let
item
=
ccx
.tcx
()
.hir
.expect_item
(
node_id
);
if
let
hir
::
ItemGlobalAsm
(
ref
ga
)
=
item
.node
{
asm
::
trans_global_asm
(
ccx
,
ga
);
...
...
@@ -69,7 +69,7 @@ fn define(&self, ccx: &CrateContext<'a, 'tcx>) {
span_bug!
(
item
.span
,
"Mismatch between hir::Item type and TransItem type"
)
}
}
Trans
Item
::
Fn
(
instance
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
{
base
::
trans_instance
(
&
ccx
,
instance
);
}
}
...
...
@@ -94,13 +94,13 @@ fn predefine(&self,
debug!
(
"symbol {}"
,
&
symbol_name
);
match
*
self
.as_trans_item
()
{
Trans
Item
::
Static
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
=>
{
predefine_static
(
ccx
,
node_id
,
linkage
,
visibility
,
&
symbol_name
);
}
Trans
Item
::
Fn
(
instance
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
{
predefine_fn
(
ccx
,
instance
,
linkage
,
visibility
,
&
symbol_name
);
}
Trans
Item
::
GlobalAsm
(
..
)
=>
{}
Mono
Item
::
GlobalAsm
(
..
)
=>
{}
}
debug!
(
"END PREDEFINING '{} ({})' in cgu {}"
,
...
...
@@ -111,12 +111,12 @@ fn predefine(&self,
fn
symbol_name
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
ty
::
SymbolName
{
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
instance
)
=>
tcx
.symbol_name
(
instance
),
Trans
Item
::
Static
(
node_id
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
tcx
.symbol_name
(
instance
),
Mono
Item
::
Static
(
node_id
)
=>
{
let
def_id
=
tcx
.hir
.local_def_id
(
node_id
);
tcx
.symbol_name
(
Instance
::
mono
(
tcx
,
def_id
))
}
Trans
Item
::
GlobalAsm
(
node_id
)
=>
{
Mono
Item
::
GlobalAsm
(
node_id
)
=>
{
let
def_id
=
tcx
.hir
.local_def_id
(
node_id
);
ty
::
SymbolName
{
name
:
Symbol
::
intern
(
&
format!
(
"global_asm_{:?}"
,
def_id
))
.as_str
()
...
...
@@ -127,11 +127,11 @@ fn symbol_name(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::SymbolName {
fn
local_span
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
Option
<
Span
>
{
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
Instance
{
def
,
..
})
=>
{
Mono
Item
::
Fn
(
Instance
{
def
,
..
})
=>
{
tcx
.hir
.as_local_node_id
(
def
.def_id
())
}
Trans
Item
::
Static
(
node_id
)
|
Trans
Item
::
GlobalAsm
(
node_id
)
=>
{
Mono
Item
::
Static
(
node_id
)
|
Mono
Item
::
GlobalAsm
(
node_id
)
=>
{
Some
(
node_id
)
}
}
.map
(|
node_id
|
tcx
.hir
.span
(
node_id
))
...
...
@@ -139,32 +139,32 @@ fn local_span(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Span> {
fn
is_generic_fn
(
&
self
)
->
bool
{
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
ref
instance
)
=>
{
Mono
Item
::
Fn
(
ref
instance
)
=>
{
instance
.substs
.types
()
.next
()
.is_some
()
}
Trans
Item
::
Static
(
..
)
|
Trans
Item
::
GlobalAsm
(
..
)
=>
false
,
Mono
Item
::
Static
(
..
)
|
Mono
Item
::
GlobalAsm
(
..
)
=>
false
,
}
}
fn
to_raw_string
(
&
self
)
->
String
{
match
*
self
.as_trans_item
()
{
Trans
Item
::
Fn
(
instance
)
=>
{
Mono
Item
::
Fn
(
instance
)
=>
{
format!
(
"Fn({:?}, {})"
,
instance
.def
,
instance
.substs
.as_ptr
()
as
usize
)
}
Trans
Item
::
Static
(
id
)
=>
{
Mono
Item
::
Static
(
id
)
=>
{
format!
(
"Static({:?})"
,
id
)
}
Trans
Item
::
GlobalAsm
(
id
)
=>
{
Mono
Item
::
GlobalAsm
(
id
)
=>
{
format!
(
"GlobalAsm({:?})"
,
id
)
}
}
}
}
impl
<
'a
,
'tcx
>
TransItemExt
<
'a
,
'tcx
>
for
Trans
Item
<
'tcx
>
{}
impl
<
'a
,
'tcx
>
TransItemExt
<
'a
,
'tcx
>
for
Mono
Item
<
'tcx
>
{}
fn
predefine_static
<
'a
,
'tcx
>
(
ccx
:
&
CrateContext
<
'a
,
'tcx
>
,
node_id
:
ast
::
NodeId
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录