Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
11dbb69b
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,发现更多精彩内容 >>
提交
11dbb69b
编写于
11月 21, 2015
作者:
A
Ariel Ben-Yehuda
提交者:
Ariel Ben-Yehuda
11月 26, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove csearch from the rest of rustc
上级
f5fbefa3
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
242 addition
and
122 deletion
+242
-122
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+2
-2
src/librustc/metadata/cstore.rs
src/librustc/metadata/cstore.rs
+7
-5
src/librustc/metadata/util.rs
src/librustc/metadata/util.rs
+143
-6
src/librustc/middle/dependency_format.rs
src/librustc/middle/dependency_format.rs
+15
-16
src/librustc/middle/infer/error_reporting.rs
src/librustc/middle/infer/error_reporting.rs
+2
-2
src/librustc_trans/back/archive.rs
src/librustc_trans/back/archive.rs
+5
-2
src/librustc_trans/back/link.rs
src/librustc_trans/back/link.rs
+31
-29
src/librustc_trans/back/linker.rs
src/librustc_trans/back/linker.rs
+3
-3
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/base.rs
+20
-38
src/librustc_trans/trans/inline.rs
src/librustc_trans/trans/inline.rs
+10
-16
src/librustc_typeck/coherence/overlap.rs
src/librustc_typeck/coherence/overlap.rs
+3
-3
src/test/run-make/execution-engine/test.rs
src/test/run-make/execution-engine/test.rs
+1
-0
未找到文件。
src/librustc/metadata/creader.rs
浏览文件 @
11dbb69b
...
...
@@ -242,7 +242,7 @@ fn existing_match(&self, name: &str, hash: Option<&Svh>, kind: PathKind)
// We're also sure to compare *paths*, not actual byte slices. The
// `source` stores paths which are normalized which may be different
// from the strings on the command line.
let
source
=
self
.sess.cstore
.get_used_crate_source
(
cnum
)
.unwrap
();
let
source
=
self
.sess.cstore
.
do_
get_used_crate_source
(
cnum
)
.unwrap
();
if
let
Some
(
locs
)
=
self
.sess.opts.externs
.get
(
name
)
{
let
found
=
locs
.iter
()
.any
(|
l
|
{
let
l
=
fs
::
canonicalize
(
l
)
.ok
();
...
...
@@ -414,7 +414,7 @@ enum LookupResult {
if
explicitly_linked
&&
!
data
.explicitly_linked
.get
()
{
data
.explicitly_linked
.set
(
explicitly_linked
);
}
(
cnum
,
data
,
self
.sess.cstore
.get_used_crate_source
(
cnum
)
.unwrap
())
(
cnum
,
data
,
self
.sess.cstore
.
do_
get_used_crate_source
(
cnum
)
.unwrap
())
}
LookupResult
::
Loaded
(
library
)
=>
{
self
.register_crate
(
root
,
ident
,
name
,
span
,
library
,
...
...
src/librustc/metadata/cstore.rs
浏览文件 @
11dbb69b
...
...
@@ -159,7 +159,7 @@ pub fn iter_crate_data_origins<I>(&self, mut i: I) where
I
:
FnMut
(
ast
::
CrateNum
,
&
crate_metadata
,
Option
<
CrateSource
>
),
{
for
(
&
k
,
v
)
in
self
.metas
.borrow
()
.iter
()
{
let
origin
=
self
.get_used_crate_source
(
k
);
let
origin
=
self
.
do_
get_used_crate_source
(
k
);
origin
.as_ref
()
.map
(|
cs
|
{
assert
!
(
k
==
cs
.cnum
);
});
i
(
k
,
&**
v
,
origin
);
}
...
...
@@ -172,8 +172,9 @@ pub fn add_used_crate_source(&self, src: CrateSource) {
}
}
pub
fn
get_used_crate_source
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Option
<
CrateSource
>
{
// TODO: killdo
pub
fn
do_get_used_crate_source
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Option
<
CrateSource
>
{
self
.used_crate_sources
.borrow_mut
()
.iter
()
.find
(|
source
|
source
.cnum
==
cnum
)
.cloned
()
}
...
...
@@ -196,8 +197,9 @@ pub fn reset(&self) {
// In order to get this left-to-right dependency ordering, we perform a
// topological sort of all crates putting the leaves at the right-most
// positions.
pub
fn
get_used_crates
(
&
self
,
prefer
:
LinkagePreference
)
->
Vec
<
(
ast
::
CrateNum
,
Option
<
PathBuf
>
)
>
{
// TODO: killdo
pub
fn
do_get_used_crates
(
&
self
,
prefer
:
LinkagePreference
)
->
Vec
<
(
ast
::
CrateNum
,
Option
<
PathBuf
>
)
>
{
let
mut
ordering
=
Vec
::
new
();
fn
visit
(
cstore
:
&
CStore
,
cnum
:
ast
::
CrateNum
,
ordering
:
&
mut
Vec
<
ast
::
CrateNum
>
)
{
...
...
src/librustc/metadata/util.rs
浏览文件 @
11dbb69b
...
...
@@ -11,24 +11,36 @@
use
front
::
map
as
ast_map
;
use
metadata
::
cstore
;
use
metadata
::
decoder
;
use
metadata
::
encoder
;
use
metadata
::
loader
;
use
middle
::
astencode
;
use
middle
::
def
;
use
middle
::
lang_items
;
use
middle
::
ty
;
use
middle
::
ty
::{
self
,
Ty
}
;
use
middle
::
def_id
::{
DefId
,
DefIndex
};
use
util
::
nodemap
::{
NodeMap
,
NodeSet
};
use
std
::
any
::
Any
;
use
std
::
cell
::
RefCell
;
use
std
::
rc
::
Rc
;
use
std
::
path
::
PathBuf
;
use
syntax
::
ast
;
use
syntax
::
attr
;
use
rustc_back
::
target
::
Target
;
use
rustc_front
::
hir
;
pub
use
metadata
::
common
::
LinkMeta
;
pub
use
metadata
::
creader
::
validate_crate_name
;
pub
use
metadata
::
csearch
::
FoundAst
;
pub
use
metadata
::
cstore
::
CrateSource
;
pub
use
metadata
::
cstore
::
LinkagePreference
;
pub
use
metadata
::
cstore
::
NativeLibraryKind
;
pub
use
metadata
::
decoder
::
DecodeInlinedItem
;
pub
use
metadata
::
decoder
::
DefLike
;
pub
use
metadata
::
inline
::
InlinedItem
;
pub
use
self
::
DefLike
::{
DlDef
,
DlField
,
DlImpl
};
pub
use
self
::
NativeLibraryKind
::{
NativeStatic
,
NativeFramework
,
NativeUnknown
};
pub
struct
ChildItem
{
pub
def
:
DefLike
,
...
...
@@ -54,6 +66,7 @@ fn item_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId)
fn
item_super_predicates
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
def
:
DefId
)
->
ty
::
GenericPredicates
<
'tcx
>
;
fn
item_attrs
(
&
self
,
def_id
:
DefId
)
->
Vec
<
ast
::
Attribute
>
;
fn
item_symbol
(
&
self
,
def
:
DefId
)
->
String
;
fn
trait_def
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
def
:
DefId
)
->
ty
::
TraitDef
<
'tcx
>
;
fn
adt_def
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
def
:
DefId
)
->
ty
::
AdtDefMaster
<
'tcx
>
;
fn
inherent_implementations_for_type
(
&
self
,
def_id
:
DefId
)
->
Vec
<
DefId
>
;
...
...
@@ -86,14 +99,21 @@ fn impl_or_trait_item(&self, tcx: &ty::ctxt<'tcx>, def: DefId)
fn
is_defaulted_trait
(
&
self
,
did
:
DefId
)
->
bool
;
fn
is_impl
(
&
self
,
did
:
DefId
)
->
bool
;
fn
is_static_method
(
&
self
,
did
:
DefId
)
->
bool
;
fn
is_extern_fn
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
did
:
DefId
)
->
bool
;
fn
is_static
(
&
self
,
did
:
DefId
)
->
bool
;
// metadata
//
crate
metadata
fn
dylib_dependency_formats
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
(
ast
::
CrateNum
,
LinkagePreference
)
>
;
fn
lang_items
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
(
DefIndex
,
usize
)
>
;
fn
missing_lang_items
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
lang_items
::
LangItem
>
;
fn
is_staged_api
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
bool
;
fn
is_explicitly_linked
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
bool
;
fn
is_allocator
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
bool
;
fn
crate_name
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
String
;
fn
plugin_registrar_fn
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Option
<
DefId
>
;
fn
native_libraries
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
(
NativeLibraryKind
,
String
)
>
;
fn
reachable_ids
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
DefId
>
;
// resolve
fn
def_path
(
&
self
,
def
:
DefId
)
->
ast_map
::
DefPath
;
...
...
@@ -102,9 +122,24 @@ fn dylib_dependency_formats(&self, cnum: ast::CrateNum)
fn
item_children
(
&
self
,
did
:
DefId
)
->
Vec
<
ChildItem
>
;
fn
crate_top_level_items
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
ChildItem
>
;
// misc.
// misc.
metadata
fn
maybe_get_item_ast
(
&
'tcx
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
def
:
DefId
)
->
FoundAst
<
'tcx
>
;
// utility functions
fn
metadata_filename
(
&
self
)
->
&
str
;
fn
metadata_section_name
(
&
self
,
target
:
&
Target
)
->
&
str
;
fn
encode_type
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
Vec
<
u8
>
;
fn
used_crates
(
&
self
,
prefer
:
LinkagePreference
)
->
Vec
<
(
ast
::
CrateNum
,
Option
<
PathBuf
>
)
>
;
fn
used_crate_source
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
CrateSource
;
fn
encode_metadata
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
reexports
:
&
def
::
ExportMap
,
item_symbols
:
&
RefCell
<
NodeMap
<
String
>>
,
link_meta
:
&
LinkMeta
,
reachable
:
&
NodeSet
,
krate
:
&
hir
::
Crate
)
->
Vec
<
u8
>
;
fn
metadata_encoding_version
(
&
self
)
->
&
[
u8
];
}
impl
<
'tcx
>
CrateStore
<
'tcx
>
for
cstore
::
CStore
{
...
...
@@ -165,6 +200,12 @@ fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>
decoder
::
get_item_attrs
(
&*
cdata
,
def_id
.index
)
}
fn
item_symbol
(
&
self
,
def
:
DefId
)
->
String
{
let
cdata
=
self
.get_crate_data
(
def
.krate
);
decoder
::
get_symbol
(
&
cdata
,
def
.index
)
}
fn
trait_def
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
def
:
DefId
)
->
ty
::
TraitDef
<
'tcx
>
{
let
cdata
=
self
.get_crate_data
(
def
.krate
);
...
...
@@ -285,21 +326,36 @@ fn is_const_fn(&self, did: DefId) -> bool
decoder
::
is_const_fn
(
&
cdata
,
did
.index
)
}
fn
is_defaulted_trait
(
&
self
,
trait_def_id
:
DefId
)
->
bool
{
fn
is_defaulted_trait
(
&
self
,
trait_def_id
:
DefId
)
->
bool
{
let
cdata
=
self
.get_crate_data
(
trait_def_id
.krate
);
decoder
::
is_defaulted_trait
(
&*
cdata
,
trait_def_id
.index
)
}
fn
is_impl
(
&
self
,
did
:
DefId
)
->
bool
{
fn
is_impl
(
&
self
,
did
:
DefId
)
->
bool
{
let
cdata
=
self
.get_crate_data
(
did
.krate
);
decoder
::
is_impl
(
&*
cdata
,
did
.index
)
}
fn
is_static_method
(
&
self
,
def
:
DefId
)
->
bool
{
fn
is_static_method
(
&
self
,
def
:
DefId
)
->
bool
{
let
cdata
=
self
.get_crate_data
(
def
.krate
);
decoder
::
is_static_method
(
&*
cdata
,
def
.index
)
}
fn
is_extern_fn
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
did
:
DefId
)
->
bool
{
let
cdata
=
self
.get_crate_data
(
did
.krate
);
decoder
::
is_extern_fn
(
&*
cdata
,
did
.index
,
tcx
)
}
fn
is_static
(
&
self
,
did
:
DefId
)
->
bool
{
let
cdata
=
self
.get_crate_data
(
did
.krate
);
decoder
::
is_static
(
&*
cdata
,
did
.index
)
}
fn
dylib_dependency_formats
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
(
ast
::
CrateNum
,
LinkagePreference
)
>
{
...
...
@@ -329,6 +385,21 @@ fn is_staged_api(&self, cnum: ast::CrateNum) -> bool
self
.get_crate_data
(
cnum
)
.staged_api
}
fn
is_explicitly_linked
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
bool
{
self
.get_crate_data
(
cnum
)
.explicitly_linked
.get
()
}
fn
is_allocator
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
bool
{
self
.get_crate_data
(
cnum
)
.is_allocator
()
}
fn
crate_name
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
String
{
self
.get_crate_data
(
cnum
)
.name
.clone
()
}
fn
plugin_registrar_fn
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Option
<
DefId
>
{
let
cdata
=
self
.get_crate_data
(
cnum
);
...
...
@@ -338,6 +409,18 @@ fn plugin_registrar_fn(&self, cnum: ast::CrateNum) -> Option<DefId>
})
}
fn
native_libraries
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
(
NativeLibraryKind
,
String
)
>
{
let
cdata
=
self
.get_crate_data
(
cnum
);
decoder
::
get_native_libraries
(
&*
cdata
)
}
fn
reachable_ids
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
Vec
<
DefId
>
{
let
cdata
=
self
.get_crate_data
(
cnum
);
decoder
::
get_reachable_ids
(
&*
cdata
)
}
fn
def_path
(
&
self
,
def
:
DefId
)
->
ast_map
::
DefPath
{
let
cdata
=
self
.get_crate_data
(
def
.krate
);
...
...
@@ -396,4 +479,58 @@ fn maybe_get_item_ast(&'tcx self, tcx: &ty::ctxt<'tcx>, def: DefId)
let
decode_inlined_item
=
Box
::
new
(
astencode
::
decode_inlined_item
);
decoder
::
maybe_get_item_ast
(
&*
cdata
,
tcx
,
def
.index
,
decode_inlined_item
)
}
fn
metadata_filename
(
&
self
)
->
&
str
{
loader
::
METADATA_FILENAME
}
fn
metadata_section_name
(
&
self
,
target
:
&
Target
)
->
&
str
{
loader
::
meta_section_name
(
target
)
}
fn
encode_type
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
Vec
<
u8
>
{
encoder
::
encoded_ty
(
tcx
,
ty
)
}
fn
used_crates
(
&
self
,
prefer
:
LinkagePreference
)
->
Vec
<
(
ast
::
CrateNum
,
Option
<
PathBuf
>
)
>
{
self
.do_get_used_crates
(
prefer
)
}
fn
used_crate_source
(
&
self
,
cnum
:
ast
::
CrateNum
)
->
CrateSource
{
self
.do_get_used_crate_source
(
cnum
)
.unwrap
()
}
fn
encode_metadata
(
&
self
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
reexports
:
&
def
::
ExportMap
,
item_symbols
:
&
RefCell
<
NodeMap
<
String
>>
,
link_meta
:
&
LinkMeta
,
reachable
:
&
NodeSet
,
krate
:
&
hir
::
Crate
)
->
Vec
<
u8
>
{
let
encode_inlined_item
:
encoder
::
EncodeInlinedItem
=
Box
::
new
(|
ecx
,
rbml_w
,
ii
|
astencode
::
encode_inlined_item
(
ecx
,
rbml_w
,
ii
));
let
encode_params
=
encoder
::
EncodeParams
{
diag
:
tcx
.sess
.diagnostic
(),
tcx
:
tcx
,
reexports
:
reexports
,
item_symbols
:
item_symbols
,
link_meta
:
link_meta
,
cstore
:
self
,
encode_inlined_item
:
encode_inlined_item
,
reachable
:
reachable
};
encoder
::
encode_metadata
(
encode_params
,
krate
)
}
fn
metadata_encoding_version
(
&
self
)
->
&
[
u8
]
{
encoder
::
metadata_encoding_version
}
}
src/librustc/middle/dependency_format.rs
浏览文件 @
11dbb69b
...
...
@@ -124,7 +124,7 @@ fn calculate_type(sess: &session::Session,
None
=>
{}
}
sess
.cstore
.iter_crate_data
(|
cnum
,
data
|
{
let
src
=
sess
.cstore
.
get_used_crate_source
(
cnum
)
.unwrap
(
);
let
src
=
sess
.cstore
.
used_crate_source
(
cnum
);
if
src
.rlib
.is_some
()
{
return
}
sess
.err
(
&
format!
(
"dependency `{}` not found in rlib format"
,
data
.name
));
...
...
@@ -152,14 +152,14 @@ fn calculate_type(sess: &session::Session,
// dependencies, ensuring there are no conflicts. The only valid case for a
// dependency to be relied upon twice is for both cases to rely on a dylib.
sess
.cstore
.iter_crate_data
(|
cnum
,
data
|
{
let
src
=
sess
.cstore
.
get_used_crate_source
(
cnum
)
.unwrap
(
);
let
src
=
sess
.cstore
.
used_crate_source
(
cnum
);
if
src
.dylib
.is_some
()
{
info!
(
"adding dylib: {}"
,
data
.name
);
add_library
(
sess
,
cnum
,
RequireDynamic
,
&
mut
formats
);
let
deps
=
sess
.cstore
.dylib_dependency_formats
(
cnum
);
for
&
(
depnum
,
style
)
in
&
deps
{
info!
(
"adding {:?}: {}"
,
style
,
sess
.cstore
.
get_crate_data
(
depnum
)
.name
.clone
(
));
sess
.cstore
.
crate_name
(
depnum
));
add_library
(
sess
,
depnum
,
style
,
&
mut
formats
);
}
}
...
...
@@ -180,7 +180,7 @@ fn calculate_type(sess: &session::Session,
// If the crate hasn't been included yet and it's not actually required
// (e.g. it's an allocator) then we skip it here as well.
sess
.cstore
.iter_crate_data
(|
cnum
,
data
|
{
let
src
=
sess
.cstore
.
get_used_crate_source
(
cnum
)
.unwrap
(
);
let
src
=
sess
.cstore
.
used_crate_source
(
cnum
);
if
src
.dylib
.is_none
()
&&
!
formats
.contains_key
(
&
cnum
)
&&
data
.explicitly_linked
.get
()
{
...
...
@@ -205,7 +205,7 @@ fn calculate_type(sess: &session::Session,
// making sure that everything is available in the requested format.
for
(
cnum
,
kind
)
in
ret
.iter
()
.enumerate
()
{
let
cnum
=
(
cnum
+
1
)
as
ast
::
CrateNum
;
let
src
=
sess
.cstore
.
get_used_crate_source
(
cnum
)
.unwrap
(
);
let
src
=
sess
.cstore
.
used_crate_source
(
cnum
);
match
*
kind
{
Linkage
::
NotLinked
|
Linkage
::
IncludedFromDylib
=>
{}
...
...
@@ -216,10 +216,10 @@ fn calculate_type(sess: &session::Session,
Linkage
::
Static
=>
"rlib"
,
_
=>
"dylib"
,
};
let
data
=
sess
.cstore
.get_crate_data
(
cnum
);
let
name
=
sess
.cstore
.crate_name
(
cnum
);
sess
.err
(
&
format!
(
"crate `{}` required to be available in {},
\
but it was not available in this form"
,
data
.
name
,
kind
));
name
,
kind
));
}
}
}
...
...
@@ -241,9 +241,8 @@ fn add_library(sess: &session::Session,
// This error is probably a little obscure, but I imagine that it
// can be refined over time.
if
link2
!=
link
||
link
==
RequireStatic
{
let
data
=
sess
.cstore
.get_crate_data
(
cnum
);
sess
.err
(
&
format!
(
"cannot satisfy dependencies so `{}` only
\
shows up once"
,
data
.name
));
shows up once"
,
sess
.cstore
.crate_name
(
cnum
)
));
sess
.help
(
"having upstream crates all available in one format
\
will likely make this go away"
);
}
...
...
@@ -253,7 +252,7 @@ fn add_library(sess: &session::Session,
}
fn
attempt_static
(
sess
:
&
session
::
Session
)
->
Option
<
DependencyList
>
{
let
crates
=
sess
.cstore
.
get_
used_crates
(
RequireStatic
);
let
crates
=
sess
.cstore
.used_crates
(
RequireStatic
);
if
!
crates
.iter
()
.by_ref
()
.all
(|
&
(
_
,
ref
p
)|
p
.is_some
())
{
return
None
}
...
...
@@ -261,7 +260,7 @@ fn attempt_static(sess: &session::Session) -> Option<DependencyList> {
// All crates are available in an rlib format, so we're just going to link
// everything in explicitly so long as it's actually required.
let
mut
ret
=
(
1
..
sess
.cstore
.next_crate_num
())
.map
(|
cnum
|
{
if
sess
.cstore
.
get_crate_data
(
cnum
)
.explicitly_linked
.get
(
)
{
if
sess
.cstore
.
is_explicitly_linked
(
cnum
)
{
Linkage
::
Static
}
else
{
Linkage
::
NotLinked
...
...
@@ -288,7 +287,7 @@ fn activate_allocator(sess: &session::Session, list: &mut DependencyList) {
let
mut
allocator_found
=
false
;
for
(
i
,
slot
)
in
list
.iter
()
.enumerate
()
{
let
cnum
=
(
i
+
1
)
as
ast
::
CrateNum
;
if
!
sess
.cstore
.
get_crate_data
(
cnum
)
.is_allocator
(
)
{
if
!
sess
.cstore
.
is_allocator
(
cnum
)
{
continue
}
if
let
Linkage
::
NotLinked
=
*
slot
{
...
...
@@ -314,18 +313,18 @@ fn verify_ok(sess: &session::Session, list: &[Linkage]) {
let
mut
allocator
=
None
;
for
(
i
,
linkage
)
in
list
.iter
()
.enumerate
()
{
let
cnum
=
(
i
+
1
)
as
ast
::
CrateNum
;
let
data
=
sess
.cstore
.get_crate_data
(
cnum
);
if
!
data
.is_allocator
()
{
if
!
sess
.cstore
.is_allocator
(
cnum
)
{
continue
}
if
let
Linkage
::
NotLinked
=
*
linkage
{
continue
}
if
let
Some
(
prev_alloc
)
=
allocator
{
let
prev
=
sess
.cstore
.get_crate_data
(
prev_alloc
);
let
prev_name
=
sess
.cstore
.crate_name
(
prev_alloc
);
let
cur_name
=
sess
.cstore
.crate_name
(
cnum
);
sess
.err
(
&
format!
(
"cannot link together two
\
allocators: {} and {}"
,
prev
.name
(),
data
.name
()
));
prev
_name
,
cur_name
));
}
allocator
=
Some
(
cnum
);
}
...
...
src/librustc/middle/infer/error_reporting.rs
浏览文件 @
11dbb69b
...
...
@@ -76,6 +76,7 @@
use
rustc_front
::
hir
;
use
rustc_front
::
print
::
pprust
;
use
metadata
::
util
::
CrateStore
;
use
middle
::
def
;
use
middle
::
def_id
::
DefId
;
use
middle
::
infer
::{
self
,
TypeOrigin
};
...
...
@@ -498,8 +499,7 @@ fn check_and_note_conflicting_crates(&self, terr: &TypeError<'tcx>, sp: Span) {
// We compare strings because PathMod and PathName can be different
// for imported and non-imported crates
if
exp_path
==
found_path
{
let
crate_name
=
self
.tcx.sess.cstore
.get_crate_data
(
did1
.krate
)
.name
();
let
crate_name
=
self
.tcx.sess.cstore
.crate_name
(
did1
.krate
);
self
.tcx.sess
.span_note
(
sp
,
&
format!
(
"Perhaps two different versions
\
of crate `{}` are being used?"
,
crate_name
));
...
...
src/librustc_trans/back/archive.rs
浏览文件 @
11dbb69b
...
...
@@ -21,10 +21,11 @@
use
std
::
ptr
;
use
std
::
str
;
use
metadata
::
util
::
CrateStore
;
use
libc
;
use
llvm
::
archive_ro
::{
ArchiveRO
,
Child
};
use
llvm
::{
self
,
ArchiveKind
};
use
rustc
::
metadata
::
loader
::
METADATA_FILENAME
;
use
rustc
::
session
::
Session
;
use
rustc_back
::
tempdir
::
TempDir
;
...
...
@@ -169,11 +170,13 @@ pub fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool)
// Ignoring all bytecode files, no matter of
// name
let
bc_ext
=
".bytecode.deflate"
;
let
metadata_filename
=
self
.config.sess.cstore
.metadata_filename
()
.to_owned
();
self
.add_archive
(
rlib
,
&
name
[
..
],
move
|
fname
:
&
str
|
{
let
skip_obj
=
lto
&&
fname
.starts_with
(
&
obj_start
)
&&
fname
.ends_with
(
".o"
);
skip_obj
||
fname
.ends_with
(
bc_ext
)
||
fname
==
METADATA_FILENAME
skip_obj
||
fname
.ends_with
(
bc_ext
)
||
fname
==
metadata_filename
})
}
...
...
src/librustc_trans/back/link.rs
浏览文件 @
11dbb69b
...
...
@@ -19,9 +19,10 @@
use
session
::
config
::{
OutputFilenames
,
Input
,
OutputType
};
use
session
::
search_paths
::
PathKind
;
use
session
::
Session
;
use
metadata
::
common
::
LinkMeta
;
use
metadata
::
loader
::
METADATA_FILENAME
;
use
metadata
::{
encoder
,
cstore
,
filesearch
,
csearch
,
creader
};
use
metadata
::{
util
as
mdutil
};
use
metadata
::
filesearch
;
use
metadata
::
util
::{
CrateStore
,
LinkMeta
};
use
metadata
::
util
::{
LinkagePreference
,
NativeLibraryKind
};
use
middle
::
dependency_format
::
Linkage
;
use
middle
::
ty
::{
self
,
Ty
};
use
rustc
::
front
::
map
::
DefPath
;
...
...
@@ -137,7 +138,7 @@ pub fn find_crate_name(sess: Option<&Session>,
attrs
:
&
[
ast
::
Attribute
],
input
:
&
Input
)
->
String
{
let
validate
=
|
s
:
String
,
span
:
Option
<
Span
>
|
{
creader
::
validate_crate_name
(
sess
,
&
s
[
..
],
span
);
mdutil
::
validate_crate_name
(
sess
,
&
s
[
..
],
span
);
s
};
...
...
@@ -216,7 +217,7 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
symbol_hasher
.input_str
(
&
meta
[
..
]);
}
symbol_hasher
.input_str
(
"-"
);
symbol_hasher
.input
(
&
encoder
::
encoded_ty
(
tcx
,
t
));
symbol_hasher
.input
(
&
tcx
.sess.cstore
.encode_type
(
tcx
,
t
));
// Prefix with 'h' so that it never blends into adjacent digits
let
mut
hash
=
String
::
from
(
"h"
);
hash
.push_str
(
&
truncated_hash_result
(
symbol_hasher
));
...
...
@@ -504,7 +505,7 @@ pub fn filename_for_input(sess: &Session,
pub
fn
each_linked_rlib
(
sess
:
&
Session
,
f
:
&
mut
FnMut
(
ast
::
CrateNum
,
&
Path
))
{
let
crates
=
sess
.cstore
.
get_used_crates
(
cstor
e
::
RequireStatic
)
.into_iter
();
let
crates
=
sess
.cstore
.
used_crates
(
LinkagePreferenc
e
::
RequireStatic
)
.into_iter
();
let
fmts
=
sess
.dependency_formats
.borrow
();
let
fmts
=
fmts
.get
(
&
config
::
CrateTypeExecutable
)
.or_else
(||
{
fmts
.get
(
&
config
::
CrateTypeStaticlib
)
...
...
@@ -516,7 +517,7 @@ pub fn each_linked_rlib(sess: &Session,
Linkage
::
NotLinked
|
Linkage
::
IncludedFromDylib
=>
continue
,
_
=>
{}
}
let
name
=
sess
.cstore
.
get_crate_data
(
cnum
)
.name
.clone
();
let
name
=
sess
.cstore
.
crate_name
(
cnum
)
.clone
();
let
path
=
match
path
{
Some
(
p
)
=>
p
,
None
=>
{
...
...
@@ -623,8 +624,9 @@ fn link_rlib<'a>(sess: &'a Session,
for
&
(
ref
l
,
kind
)
in
sess
.cstore
.get_used_libraries
()
.borrow
()
.iter
()
{
match
kind
{
cstore
::
NativeStatic
=>
ab
.add_native_library
(
&
l
),
cstore
::
NativeFramework
|
cstore
::
NativeUnknown
=>
{}
NativeLibraryKind
::
NativeStatic
=>
ab
.add_native_library
(
&
l
),
NativeLibraryKind
::
NativeFramework
|
NativeLibraryKind
::
NativeUnknown
=>
{}
}
}
...
...
@@ -666,7 +668,7 @@ fn link_rlib<'a>(sess: &'a Session,
// contain the metadata in a separate file. We use a temp directory
// here so concurrent builds in the same directory don't try to use
// the same filename for metadata (stomping over one another)
let
metadata
=
tmpdir
.join
(
METADATA_FILENAME
);
let
metadata
=
tmpdir
.join
(
sess
.cstore
.metadata_filename
()
);
match
fs
::
File
::
create
(
&
metadata
)
.and_then
(|
mut
f
|
{
f
.write_all
(
&
trans
.metadata
)
})
{
...
...
@@ -805,10 +807,10 @@ fn link_staticlib(sess: &Session, objects: &[PathBuf], out_filename: &Path,
let
mut
all_native_libs
=
vec!
[];
each_linked_rlib
(
sess
,
&
mut
|
cnum
,
path
|
{
let
name
=
sess
.cstore
.
get_crate_data
(
cnum
)
.name
(
);
let
name
=
sess
.cstore
.
crate_name
(
cnum
);
ab
.add_rlib
(
path
,
&
name
,
sess
.lto
())
.unwrap
();
let
native_libs
=
csearch
::
get_native_libraries
(
&
sess
.cstore
,
cnum
);
let
native_libs
=
sess
.cstore
.native_libraries
(
cnum
);
all_native_libs
.extend
(
native_libs
);
});
...
...
@@ -824,9 +826,9 @@ fn link_staticlib(sess: &Session, objects: &[PathBuf], out_filename: &Path,
for
&
(
kind
,
ref
lib
)
in
&
all_native_libs
{
let
name
=
match
kind
{
cstore
::
NativeStatic
=>
"static library"
,
cstore
::
NativeUnknown
=>
"library"
,
cstore
::
NativeFramework
=>
"framework"
,
NativeLibraryKind
::
NativeStatic
=>
"static library"
,
NativeLibraryKind
::
NativeUnknown
=>
"library"
,
NativeLibraryKind
::
NativeFramework
=>
"framework"
,
};
sess
.note
(
&
format!
(
"{}: {}"
,
name
,
*
lib
));
}
...
...
@@ -1049,7 +1051,7 @@ fn link_args(cmd: &mut Linker,
path
};
let
mut
rpath_config
=
RPathConfig
{
used_crates
:
sess
.cstore
.
get_used_crates
(
cstor
e
::
RequireDynamic
),
used_crates
:
sess
.cstore
.
used_crates
(
LinkagePreferenc
e
::
RequireDynamic
),
out_filename
:
out_filename
.to_path_buf
(),
has_rpath
:
sess
.target.target.options.has_rpath
,
is_like_osx
:
sess
.target.target.options.is_like_osx
,
...
...
@@ -1089,10 +1091,10 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
let
libs
=
libs
.borrow
();
let
staticlibs
=
libs
.iter
()
.filter_map
(|
&
(
ref
l
,
kind
)|
{
if
kind
==
cstore
::
NativeStatic
{
Some
(
l
)}
else
{
None
}
if
kind
==
NativeLibraryKind
::
NativeStatic
{
Some
(
l
)}
else
{
None
}
});
let
others
=
libs
.iter
()
.filter
(|
&&
(
_
,
kind
)|
{
kind
!=
cstore
::
NativeStatic
kind
!=
NativeLibraryKind
::
NativeStatic
});
// Some platforms take hints about whether a library is static or dynamic.
...
...
@@ -1116,9 +1118,9 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
for
&
(
ref
l
,
kind
)
in
others
{
match
kind
{
cstore
::
NativeUnknown
=>
cmd
.link_dylib
(
l
),
cstore
::
NativeFramework
=>
cmd
.link_framework
(
l
),
cstore
::
NativeStatic
=>
unreachable!
(),
NativeLibraryKind
::
NativeUnknown
=>
cmd
.link_dylib
(
l
),
NativeLibraryKind
::
NativeFramework
=>
cmd
.link_framework
(
l
),
NativeLibraryKind
::
NativeStatic
=>
unreachable!
(),
}
}
}
...
...
@@ -1147,13 +1149,13 @@ fn add_upstream_rust_crates(cmd: &mut Linker, sess: &Session,
// Invoke get_used_crates to ensure that we get a topological sorting of
// crates.
let
deps
=
sess
.cstore
.
get_used_crates
(
cstor
e
::
RequireDynamic
);
let
deps
=
sess
.cstore
.
used_crates
(
LinkagePreferenc
e
::
RequireDynamic
);
for
&
(
cnum
,
_
)
in
&
deps
{
// We may not pass all crates through to the linker. Some crates may
// appear statically in an existing dylib, meaning we'll pick up all the
// symbols from the dylib.
let
src
=
sess
.cstore
.
get_used_crate_source
(
cnum
)
.unwrap
(
);
let
src
=
sess
.cstore
.
used_crate_source
(
cnum
);
match
data
[
cnum
as
usize
-
1
]
{
Linkage
::
NotLinked
|
Linkage
::
IncludedFromDylib
=>
{}
...
...
@@ -1217,7 +1219,7 @@ fn add_static_crate(cmd: &mut Linker, sess: &Session, tmpdir: &Path,
time
(
sess
.time_passes
(),
&
format!
(
"altering {}.rlib"
,
name
),
||
{
let
cfg
=
archive_config
(
sess
,
&
dst
,
Some
(
cratepath
));
let
mut
archive
=
ArchiveBuilder
::
new
(
cfg
);
archive
.remove_file
(
METADATA_FILENAME
);
archive
.remove_file
(
sess
.cstore
.metadata_filename
()
);
archive
.update_symbols
();
let
mut
any_objects
=
false
;
...
...
@@ -1292,14 +1294,14 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session) {
// This passes RequireStatic, but the actual requirement doesn't matter,
// we're just getting an ordering of crate numbers, we're not worried about
// the paths.
let
crates
=
sess
.cstore
.
get_used_crates
(
cstor
e
::
RequireStatic
);
let
crates
=
sess
.cstore
.
used_crates
(
LinkagePreferenc
e
::
RequireStatic
);
for
(
cnum
,
_
)
in
crates
{
let
libs
=
csearch
::
get_native_libraries
(
&
sess
.cstore
,
cnum
);
let
libs
=
sess
.cstore
.native_libraries
(
cnum
);
for
&
(
kind
,
ref
lib
)
in
&
libs
{
match
kind
{
cstore
::
NativeUnknown
=>
cmd
.link_dylib
(
lib
),
cstore
::
NativeFramework
=>
cmd
.link_framework
(
lib
),
cstore
::
NativeStatic
=>
{
NativeLibraryKind
::
NativeUnknown
=>
cmd
.link_dylib
(
lib
),
NativeLibraryKind
::
NativeFramework
=>
cmd
.link_framework
(
lib
),
NativeLibraryKind
::
NativeStatic
=>
{
sess
.bug
(
"statics shouldn't be propagated"
);
}
}
...
...
src/librustc_trans/back/linker.rs
浏览文件 @
11dbb69b
...
...
@@ -16,7 +16,7 @@
use
std
::
process
::
Command
;
use
back
::
archive
;
use
metadata
::
csearch
;
use
metadata
::
util
::
CrateStore
;
use
middle
::
dependency_format
::
Linkage
;
use
session
::
Session
;
use
session
::
config
::
CrateTypeDylib
;
...
...
@@ -342,9 +342,9 @@ fn export_symbols(&mut self, sess: &Session, trans: &CrateTranslation,
None
}
})
.flat_map
(|
cnum
|
{
cs
earch
::
get_reachable_ids
(
cstore
,
cnum
)
cs
tore
.reachable_ids
(
cnum
)
})
.map
(|
did
|
{
cs
earch
::
get_symbol
(
cstore
,
did
)
cs
tore
.item_symbol
(
did
)
});
for
symbol
in
symbols
{
try!
(
writeln!
(
f
,
" {}"
,
symbol
));
...
...
src/librustc_trans/trans/base.rs
浏览文件 @
11dbb69b
...
...
@@ -34,8 +34,6 @@
use
lint
;
use
llvm
::{
BasicBlockRef
,
Linkage
,
ValueRef
,
Vector
,
get_param
};
use
llvm
;
use
metadata
::{
csearch
,
encoder
,
loader
};
use
middle
::
astencode
;
use
middle
::
cfg
;
use
middle
::
def_id
::
DefId
;
use
middle
::
infer
;
...
...
@@ -44,6 +42,7 @@
use
middle
::
pat_util
::
simple_name
;
use
middle
::
subst
::
Substs
;
use
middle
::
ty
::{
self
,
Ty
,
HasTypeFlags
};
use
metadata
::
util
::
CrateStore
;
use
rustc
::
front
::
map
as
hir_map
;
use
rustc_mir
::
mir_map
::
MirMap
;
use
session
::
config
::{
self
,
NoDebugInfo
,
FullDebugInfo
};
...
...
@@ -199,7 +198,7 @@ fn get_extern_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let
f
=
declare
::
declare_rust_fn
(
ccx
,
name
,
fn_ty
);
let
attrs
=
c
search
::
get_item_attrs
(
&
ccx
.sess
()
.cstore
,
did
);
let
attrs
=
c
cx
.sess
()
.cstore
.item_attrs
(
did
);
attributes
::
from_fn_attrs
(
ccx
,
&
attrs
[
..
],
f
);
ccx
.externs
()
.borrow_mut
()
.insert
(
name
.to_string
(),
f
);
...
...
@@ -230,7 +229,7 @@ pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
did
:
DefId
,
t
:
Ty
<
'tcx
>
)
->
ValueRef
{
let
name
=
c
search
::
get_symbol
(
&
ccx
.sess
()
.cstore
,
did
);
let
name
=
c
cx
.sess
()
.cstore
.item_symbol
(
did
);
let
ty
=
type_of
(
ccx
,
t
);
match
ccx
.externs
()
.borrow_mut
()
.get
(
&
name
)
{
Some
(
n
)
=>
return
*
n
,
...
...
@@ -874,7 +873,7 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
did
:
DefId
,
t
:
Ty
<
'tcx
>
)
->
ValueRef
{
let
name
=
c
search
::
get_symbol
(
&
ccx
.sess
()
.cstore
,
did
);
let
name
=
c
cx
.sess
()
.cstore
.item_symbol
(
did
);
match
t
.sty
{
ty
::
TyBareFn
(
_
,
ref
fn_ty
)
=>
{
match
ccx
.sess
()
.target.target
.adjust_abi
(
fn_ty
.abi
)
{
...
...
@@ -885,7 +884,7 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ccx
.sess
()
.bug
(
"unexpected intrinsic in trans_external_path"
)
}
_
=>
{
let
attrs
=
c
search
::
get_item_attrs
(
&
ccx
.sess
()
.cstore
,
did
);
let
attrs
=
c
cx
.sess
()
.cstore
.item_attrs
(
did
);
foreign
::
register_foreign_item_fn
(
ccx
,
fn_ty
.abi
,
t
,
&
name
,
&
attrs
)
}
}
...
...
@@ -2513,10 +2512,9 @@ fn create_entry_fn(ccx: &CrateContext,
.as_local_node_id
(
start_def_id
)
{
get_item_val
(
ccx
,
start_node_id
)
}
else
{
let
start_fn_type
=
c
search
::
get_type
(
ccx
.tcx
(),
start_def_id
)
.ty
;
let
start_fn_type
=
c
cx
.tcx
()
.lookup_item_type
(
start_def_id
)
.ty
;
trans_external_path
(
ccx
,
start_def_id
,
start_fn_type
)
};
let
args
=
{
let
opaque_rust_main
=
llvm
::
LLVMBuildPointerCast
(
bld
,
...
...
@@ -2552,7 +2550,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
->
String
{
match
ccx
.external_srcs
()
.borrow
()
.get
(
&
id
)
{
Some
(
&
did
)
=>
{
let
sym
=
c
search
::
get_symbol
(
&
ccx
.sess
()
.cstore
,
did
);
let
sym
=
c
cx
.sess
()
.cstore
.item_symbol
(
did
);
debug!
(
"found item {} in other crate..."
,
sym
);
return
sym
;
}
...
...
@@ -2602,7 +2600,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
let
v
=
match
i
.node
{
hir
::
ItemStatic
(
..
)
=>
{
// If this static came from an external crate, then
// we need to get the symbol from
csearch
instead of
// we need to get the symbol from
metadata
instead of
// using the current crate's name/version
// information in the hash of the symbol
let
sym
=
sym
();
...
...
@@ -2757,22 +2755,6 @@ fn register_method(ccx: &CrateContext,
}
}
pub
fn
crate_ctxt_to_encode_parms
<
'a
,
'tcx
>
(
cx
:
&
'a
SharedCrateContext
<
'a
,
'tcx
>
,
ie
:
encoder
::
EncodeInlinedItem
<
'a
>
,
reachable
:
&
'a
NodeSet
)
->
encoder
::
EncodeParams
<
'a
,
'tcx
>
{
encoder
::
EncodeParams
{
diag
:
cx
.sess
()
.diagnostic
(),
tcx
:
cx
.tcx
(),
reexports
:
cx
.export_map
(),
item_symbols
:
cx
.item_symbols
(),
link_meta
:
cx
.link_meta
(),
cstore
:
&
cx
.sess
()
.cstore
,
encode_inlined_item
:
ie
,
reachable
:
reachable
,
}
}
pub
fn
write_metadata
(
cx
:
&
SharedCrateContext
,
krate
:
&
hir
::
Crate
,
reachable
:
&
NodeSet
)
->
Vec
<
u8
>
{
use
flate
;
...
...
@@ -2785,14 +2767,13 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &hir::Crate, reachable: &N
return
Vec
::
new
();
}
let
encode_inlined_item
:
encoder
::
EncodeInlinedItem
=
Box
::
new
(|
ecx
,
rbml_w
,
ii
|
{
astencode
::
encode_inlined_item
(
ecx
,
rbml_w
,
ii
)
});
let
encode_parms
=
crate_ctxt_to_encode_parms
(
cx
,
encode_inlined_item
,
reachable
);
let
metadata
=
encoder
::
encode_metadata
(
encode_parms
,
krate
);
let
mut
compressed
=
encoder
::
metadata_encoding_version
.to_vec
();
let
cstore
=
&
cx
.tcx
()
.sess.cstore
;
let
metadata
=
cstore
.encode_metadata
(
cx
.tcx
(),
cx
.export_map
(),
cx
.item_symbols
(),
cx
.link_meta
(),
reachable
,
krate
);
let
mut
compressed
=
cstore
.metadata_encoding_version
()
.to_vec
();
compressed
.push_all
(
&
flate
::
deflate_bytes
(
&
metadata
));
let
llmeta
=
C_bytes_in_context
(
cx
.metadata_llcx
(),
&
compressed
[
..
]);
let
llconst
=
C_struct_in_context
(
cx
.metadata_llcx
(),
&
[
llmeta
],
false
);
let
name
=
format!
(
"rust_metadata_{}_{}"
,
...
...
@@ -2804,7 +2785,8 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &hir::Crate, reachable: &N
};
unsafe
{
llvm
::
LLVMSetInitializer
(
llglobal
,
llconst
);
let
name
=
loader
::
meta_section_name
(
&
cx
.sess
()
.target.target
);
let
name
=
cx
.tcx
()
.sess.cstore
.metadata_section_name
(
&
cx
.sess
()
.target.target
);
let
name
=
CString
::
new
(
name
)
.unwrap
();
llvm
::
LLVMSetSection
(
llglobal
,
name
.as_ptr
())
}
...
...
@@ -3106,12 +3088,12 @@ pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
// the final product, so LTO needs to preserve them.
if
sess
.lto
()
{
sess
.cstore
.iter_crate_data
(|
cnum
,
_
|
{
let
syms
=
csearch
::
get_reachable_ids
(
&
sess
.cstore
,
cnum
);
let
syms
=
sess
.cstore
.reachable_ids
(
cnum
);
reachable_symbols
.extend
(
syms
.into_iter
()
.filter
(|
did
|
{
csearch
::
is_extern_fn
(
&
sess
.cstore
,
*
did
,
shared_ccx
.tcx
()
)
||
csearch
::
is_static
(
&
sess
.cstore
,
*
did
)
sess
.cstore
.is_extern_fn
(
shared_ccx
.tcx
(),
*
did
)
||
sess
.cstore
.is_static
(
*
did
)
})
.map
(|
did
|
{
csearch
::
get_symbol
(
&
sess
.cstore
,
did
)
sess
.cstore
.item_symbol
(
did
)
}));
});
}
...
...
src/librustc_trans/trans/inline.rs
浏览文件 @
11dbb69b
...
...
@@ -9,9 +9,7 @@
// except according to those terms.
use
llvm
::{
AvailableExternallyLinkage
,
InternalLinkage
,
SetLinkage
};
use
metadata
::
csearch
;
use
metadata
::
inline
::
InlinedItem
;
use
middle
::
astencode
;
use
metadata
::
util
::{
CrateStore
,
FoundAst
,
InlinedItem
};
use
middle
::
def_id
::
DefId
;
use
middle
::
subst
::
Substs
;
use
trans
::
base
::{
push_ctxt
,
trans_item
,
get_item_val
,
trans_fn
};
...
...
@@ -41,17 +39,13 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
}
}
let
csearch_result
=
csearch
::
maybe_get_item_ast
(
ccx
.tcx
(),
fn_id
,
Box
::
new
(
astencode
::
decode_inlined_item
));
let
inline_id
=
match
csearch_result
{
csearch
::
FoundAst
::
NotFound
=>
{
let
inlined
=
ccx
.tcx
()
.sess.cstore
.maybe_get_item_ast
(
ccx
.tcx
(),
fn_id
);
let
inline_id
=
match
inlined
{
FoundAst
::
NotFound
=>
{
ccx
.external
()
.borrow_mut
()
.insert
(
fn_id
,
None
);
return
None
;
}
csearch
::
FoundAst
::
Found
(
&
InlinedItem
::
Item
(
ref
item
))
=>
{
FoundAst
::
Found
(
&
InlinedItem
::
Item
(
ref
item
))
=>
{
ccx
.external
()
.borrow_mut
()
.insert
(
fn_id
,
Some
(
item
.id
));
ccx
.external_srcs
()
.borrow_mut
()
.insert
(
item
.id
,
fn_id
);
...
...
@@ -94,12 +88,12 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
item
.id
}
csearch
::
FoundAst
::
Found
(
&
InlinedItem
::
Foreign
(
ref
item
))
=>
{
FoundAst
::
Found
(
&
InlinedItem
::
Foreign
(
ref
item
))
=>
{
ccx
.external
()
.borrow_mut
()
.insert
(
fn_id
,
Some
(
item
.id
));
ccx
.external_srcs
()
.borrow_mut
()
.insert
(
item
.id
,
fn_id
);
item
.id
}
csearch
::
FoundAst
::
FoundParent
(
parent_id
,
&
InlinedItem
::
Item
(
ref
item
))
=>
{
FoundAst
::
FoundParent
(
parent_id
,
&
InlinedItem
::
Item
(
ref
item
))
=>
{
ccx
.external
()
.borrow_mut
()
.insert
(
parent_id
,
Some
(
item
.id
));
ccx
.external_srcs
()
.borrow_mut
()
.insert
(
item
.id
,
parent_id
);
...
...
@@ -129,11 +123,11 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
trans_item
(
ccx
,
&**
item
);
my_id
}
csearch
::
FoundAst
::
FoundParent
(
_
,
_
)
=>
{
FoundAst
::
FoundParent
(
_
,
_
)
=>
{
ccx
.sess
()
.bug
(
"maybe_get_item_ast returned a FoundParent
\
with a non-item parent"
);
}
csearch
::
FoundAst
::
Found
(
&
InlinedItem
::
TraitItem
(
_
,
ref
trait_item
))
=>
{
FoundAst
::
Found
(
&
InlinedItem
::
TraitItem
(
_
,
ref
trait_item
))
=>
{
ccx
.external
()
.borrow_mut
()
.insert
(
fn_id
,
Some
(
trait_item
.id
));
ccx
.external_srcs
()
.borrow_mut
()
.insert
(
trait_item
.id
,
fn_id
);
...
...
@@ -153,7 +147,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
// don't.
trait_item
.id
}
csearch
::
FoundAst
::
Found
(
&
InlinedItem
::
ImplItem
(
impl_did
,
ref
impl_item
))
=>
{
FoundAst
::
Found
(
&
InlinedItem
::
ImplItem
(
impl_did
,
ref
impl_item
))
=>
{
ccx
.external
()
.borrow_mut
()
.insert
(
fn_id
,
Some
(
impl_item
.id
));
ccx
.external_srcs
()
.borrow_mut
()
.insert
(
impl_item
.id
,
fn_id
);
...
...
src/librustc_typeck/coherence/overlap.rs
浏览文件 @
11dbb69b
...
...
@@ -12,6 +12,7 @@
//! same type.
use
metadata
::
cstore
::
LOCAL_CRATE
;
use
metadata
::
util
::
CrateStore
;
use
middle
::
def_id
::
DefId
;
use
middle
::
traits
;
use
middle
::
ty
;
...
...
@@ -156,9 +157,8 @@ fn report_overlap_note(&self, impl2: DefId) {
span_note!
(
self
.tcx.sess
,
self
.span_of_impl
(
impl2
),
"note conflicting implementation here"
);
}
else
{
let
crate_store
=
&
self
.tcx.sess.cstore
;
let
cdata
=
crate_store
.get_crate_data
(
impl2
.krate
);
self
.tcx.sess
.note
(
&
format!
(
"conflicting implementation in crate `{}`"
,
cdata
.name
));
let
cname
=
self
.tcx.sess.cstore
.crate_name
(
impl2
.krate
);
self
.tcx.sess
.note
(
&
format!
(
"conflicting implementation in crate `{}`"
,
cname
));
}
}
...
...
src/test/run-make/execution-engine/test.rs
浏览文件 @
11dbb69b
...
...
@@ -27,6 +27,7 @@
use
rustc
::
front
::
map
as
ast_map
;
use
rustc
::
llvm
;
use
rustc
::
metadata
::
cstore
::
RequireDynamic
;
use
rustc
::
metadata
::
util
::
CrateStore
;
use
rustc
::
middle
::
ty
;
use
rustc
::
session
::
config
::{
self
,
basic_options
,
build_configuration
,
Input
,
Options
};
use
rustc
::
session
::
build_session
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录