Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c6bcf601
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,发现更多精彩内容 >>
提交
c6bcf601
编写于
11月 17, 2019
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_metadata: `locator::Context` -> `CrateLocator`
上级
68985c76
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
26 addition
and
26 deletion
+26
-26
src/librustc_metadata/creader.rs
src/librustc_metadata/creader.rs
+17
-17
src/librustc_metadata/locator.rs
src/librustc_metadata/locator.rs
+9
-9
未找到文件。
src/librustc_metadata/creader.rs
浏览文件 @
c6bcf601
//! Validates all used crates and extern libraries and loads their metadata
//! Validates all used crates and extern libraries and loads their metadata
use
crate
::
cstore
::{
self
,
CStore
};
use
crate
::
cstore
::{
self
,
CStore
};
use
crate
::
locator
::{
self
,
CratePaths
};
use
crate
::
locator
::{
CrateLocator
,
CratePaths
};
use
crate
::
rmeta
::{
CrateRoot
,
CrateDep
,
MetadataBlob
};
use
crate
::
rmeta
::{
CrateRoot
,
CrateDep
,
MetadataBlob
};
use
rustc_data_structures
::
sync
::{
Lock
,
Once
,
AtomicCell
};
use
rustc_data_structures
::
sync
::{
Lock
,
Once
,
AtomicCell
};
...
@@ -68,13 +68,13 @@ enum LoadResult {
...
@@ -68,13 +68,13 @@ enum LoadResult {
}
}
enum
LoadError
<
'a
>
{
enum
LoadError
<
'a
>
{
LocatorError
(
locator
::
Context
<
'a
>
),
LocatorError
(
CrateLocator
<
'a
>
),
}
}
impl
<
'a
>
LoadError
<
'a
>
{
impl
<
'a
>
LoadError
<
'a
>
{
fn
report
(
self
)
->
!
{
fn
report
(
self
)
->
!
{
match
self
{
match
self
{
LoadError
::
LocatorError
(
locat
e_ctxt
)
=>
locate_ctxt
.report_errs
(),
LoadError
::
LocatorError
(
locat
or
)
=>
locator
.report_errs
(),
}
}
}
}
}
}
...
@@ -267,15 +267,15 @@ fn register_crate(
...
@@ -267,15 +267,15 @@ fn register_crate(
fn
load_proc_macro
<
'b
>
(
fn
load_proc_macro
<
'b
>
(
&
self
,
&
self
,
locat
e_ctxt
:
&
mut
locator
::
Context
<
'b
>
,
locat
or
:
&
mut
CrateLocator
<
'b
>
,
path_kind
:
PathKind
,
path_kind
:
PathKind
,
)
->
Option
<
(
LoadResult
,
Option
<
Library
>
)
>
)
->
Option
<
(
LoadResult
,
Option
<
Library
>
)
>
where
where
'a
:
'b
,
'a
:
'b
,
{
{
// Use a new
locator Context
so trying to load a proc macro doesn't affect the error
// Use a new
crate locator
so trying to load a proc macro doesn't affect the error
// message we emit
// message we emit
let
mut
proc_macro_locator
=
locat
e_ctxt
.clone
();
let
mut
proc_macro_locator
=
locat
or
.clone
();
// Try to load a proc macro
// Try to load a proc macro
proc_macro_locator
.is_proc_macro
=
Some
(
true
);
proc_macro_locator
.is_proc_macro
=
Some
(
true
);
...
@@ -287,10 +287,10 @@ fn load_proc_macro<'b>(
...
@@ -287,10 +287,10 @@ fn load_proc_macro<'b>(
LoadResult
::
Previous
(
cnum
)
=>
return
Some
((
LoadResult
::
Previous
(
cnum
),
None
)),
LoadResult
::
Previous
(
cnum
)
=>
return
Some
((
LoadResult
::
Previous
(
cnum
),
None
)),
LoadResult
::
Loaded
(
library
)
=>
Some
(
LoadResult
::
Loaded
(
library
))
LoadResult
::
Loaded
(
library
)
=>
Some
(
LoadResult
::
Loaded
(
library
))
};
};
locat
e_ctxt
.hash
=
locate_ctxt
.host_hash
;
locat
or
.hash
=
locator
.host_hash
;
// Use the locat
e_ctxt
when looking for the host proc macro crate, as that is required
// Use the locat
or
when looking for the host proc macro crate, as that is required
// so we want it to affect the error message
// so we want it to affect the error message
(
locat
e_ctxt
,
result
)
(
locat
or
,
result
)
}
else
{
}
else
{
(
&
mut
proc_macro_locator
,
None
)
(
&
mut
proc_macro_locator
,
None
)
};
};
...
@@ -350,7 +350,7 @@ fn maybe_resolve_crate<'b>(
...
@@ -350,7 +350,7 @@ fn maybe_resolve_crate<'b>(
(
LoadResult
::
Previous
(
cnum
),
None
)
(
LoadResult
::
Previous
(
cnum
),
None
)
}
else
{
}
else
{
info!
(
"falling back to a load"
);
info!
(
"falling back to a load"
);
let
mut
locat
e_ctxt
=
locator
::
Context
{
let
mut
locat
or
=
CrateLocator
{
sess
:
self
.sess
,
sess
:
self
.sess
,
span
,
span
,
crate_name
:
name
,
crate_name
:
name
,
...
@@ -371,10 +371,10 @@ fn maybe_resolve_crate<'b>(
...
@@ -371,10 +371,10 @@ fn maybe_resolve_crate<'b>(
metadata_loader
:
self
.metadata_loader
,
metadata_loader
:
self
.metadata_loader
,
};
};
self
.load
(
&
mut
locat
e_ctxt
)
.map
(|
r
|
(
r
,
None
))
.or_else
(||
{
self
.load
(
&
mut
locat
or
)
.map
(|
r
|
(
r
,
None
))
.or_else
(||
{
dep_kind
=
DepKind
::
UnexportedMacrosOnly
;
dep_kind
=
DepKind
::
UnexportedMacrosOnly
;
self
.load_proc_macro
(
&
mut
locat
e_ctxt
,
path_kind
)
self
.load_proc_macro
(
&
mut
locat
or
,
path_kind
)
})
.ok_or_else
(
move
||
LoadError
::
LocatorError
(
locat
e_ctxt
))
?
})
.ok_or_else
(
move
||
LoadError
::
LocatorError
(
locat
or
))
?
};
};
match
result
{
match
result
{
...
@@ -395,8 +395,8 @@ fn maybe_resolve_crate<'b>(
...
@@ -395,8 +395,8 @@ fn maybe_resolve_crate<'b>(
}
}
}
}
fn
load
(
&
self
,
locat
e_ctxt
:
&
mut
locator
::
Context
<
'_
>
)
->
Option
<
LoadResult
>
{
fn
load
(
&
self
,
locat
or
:
&
mut
CrateLocator
<
'_
>
)
->
Option
<
LoadResult
>
{
let
library
=
locat
e_ctxt
.maybe_load_library_crate
()
?
;
let
library
=
locat
or
.maybe_load_library_crate
()
?
;
// In the case that we're loading a crate, but not matching
// In the case that we're loading a crate, but not matching
// against a hash, we could load a crate which has the same hash
// against a hash, we could load a crate which has the same hash
...
@@ -407,11 +407,11 @@ fn load(&self, locate_ctxt: &mut locator::Context<'_>) -> Option<LoadResult> {
...
@@ -407,11 +407,11 @@ fn load(&self, locate_ctxt: &mut locator::Context<'_>) -> Option<LoadResult> {
// don't want to match a host crate against an equivalent target one
// don't want to match a host crate against an equivalent target one
// already loaded.
// already loaded.
let
root
=
library
.metadata
.get_root
();
let
root
=
library
.metadata
.get_root
();
if
locat
e_ctxt
.triple
==
self
.sess.opts.target_triple
{
if
locat
or
.triple
==
self
.sess.opts.target_triple
{
let
mut
result
=
LoadResult
::
Loaded
(
library
);
let
mut
result
=
LoadResult
::
Loaded
(
library
);
self
.cstore
.iter_crate_data
(|
cnum
,
data
|
{
self
.cstore
.iter_crate_data
(|
cnum
,
data
|
{
if
data
.root.name
==
root
.name
&&
root
.hash
==
data
.root.hash
{
if
data
.root.name
==
root
.name
&&
root
.hash
==
data
.root.hash
{
assert
!
(
locat
e_ctxt
.hash
.is_none
());
assert
!
(
locat
or
.hash
.is_none
());
info!
(
"load success, going to previous cnum: {}"
,
cnum
);
info!
(
"load success, going to previous cnum: {}"
,
cnum
);
result
=
LoadResult
::
Previous
(
cnum
);
result
=
LoadResult
::
Previous
(
cnum
);
}
}
...
...
src/librustc_metadata/locator.rs
浏览文件 @
c6bcf601
...
@@ -254,7 +254,7 @@
...
@@ -254,7 +254,7 @@
}
}
#[derive(Clone)]
#[derive(Clone)]
crate
struct
C
ontext
<
'a
>
{
crate
struct
C
rateLocator
<
'a
>
{
pub
sess
:
&
'a
Session
,
pub
sess
:
&
'a
Session
,
pub
span
:
Span
,
pub
span
:
Span
,
pub
crate_name
:
Symbol
,
pub
crate_name
:
Symbol
,
...
@@ -298,7 +298,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
...
@@ -298,7 +298,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
}
}
impl
<
'a
>
C
ontext
<
'a
>
{
impl
<
'a
>
C
rateLocator
<
'a
>
{
crate
fn
reset
(
&
mut
self
)
{
crate
fn
reset
(
&
mut
self
)
{
self
.rejected_via_hash
.clear
();
self
.rejected_via_hash
.clear
();
self
.rejected_via_triple
.clear
();
self
.rejected_via_triple
.clear
();
...
@@ -926,7 +926,7 @@ pub fn find_plugin_registrar(
...
@@ -926,7 +926,7 @@ pub fn find_plugin_registrar(
let
host_triple
=
TargetTriple
::
from_triple
(
config
::
host_triple
());
let
host_triple
=
TargetTriple
::
from_triple
(
config
::
host_triple
());
let
is_cross
=
target_triple
!=
host_triple
;
let
is_cross
=
target_triple
!=
host_triple
;
let
mut
target_only
=
false
;
let
mut
target_only
=
false
;
let
mut
locat
e_ctxt
=
Context
{
let
mut
locat
or
=
CrateLocator
{
sess
,
sess
,
span
,
span
,
crate_name
:
name
,
crate_name
:
name
,
...
@@ -947,7 +947,7 @@ pub fn find_plugin_registrar(
...
@@ -947,7 +947,7 @@ pub fn find_plugin_registrar(
metadata_loader
,
metadata_loader
,
};
};
let
library
=
locat
e_ctxt
.maybe_load_library_crate
()
.or_else
(||
{
let
library
=
locat
or
.maybe_load_library_crate
()
.or_else
(||
{
if
!
is_cross
{
if
!
is_cross
{
return
None
return
None
}
}
...
@@ -955,15 +955,15 @@ pub fn find_plugin_registrar(
...
@@ -955,15 +955,15 @@ pub fn find_plugin_registrar(
// try to load a plugin registrar function,
// try to load a plugin registrar function,
target_only
=
true
;
target_only
=
true
;
locat
e_ctxt
.target
=
&
sess
.target.target
;
locat
or
.target
=
&
sess
.target.target
;
locat
e_ctxt
.triple
=
target_triple
;
locat
or
.triple
=
target_triple
;
locat
e_ctxt
.filesearch
=
sess
.target_filesearch
(
PathKind
::
Crate
);
locat
or
.filesearch
=
sess
.target_filesearch
(
PathKind
::
Crate
);
locat
e_ctxt
.maybe_load_library_crate
()
locat
or
.maybe_load_library_crate
()
});
});
let
library
=
match
library
{
let
library
=
match
library
{
Some
(
l
)
=>
l
,
Some
(
l
)
=>
l
,
None
=>
locat
e_ctxt
.report_errs
(),
None
=>
locat
or
.report_errs
(),
};
};
if
target_only
{
if
target_only
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录