Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f59198ab
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,发现更多精彩内容 >>
提交
f59198ab
编写于
8月 31, 2021
作者:
B
bjorn3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce CrateRejections struct
上级
b3f850a5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
40 deletion
+36
-40
compiler/rustc_metadata/src/locator.rs
compiler/rustc_metadata/src/locator.rs
+36
-40
未找到文件。
compiler/rustc_metadata/src/locator.rs
浏览文件 @
f59198ab
...
...
@@ -255,11 +255,7 @@
pub
is_proc_macro
:
bool
,
// Mutable in-progress state or output.
rejected_via_hash
:
Vec
<
CrateMismatch
>
,
rejected_via_triple
:
Vec
<
CrateMismatch
>
,
rejected_via_kind
:
Vec
<
CrateMismatch
>
,
rejected_via_version
:
Vec
<
CrateMismatch
>
,
rejected_via_filename
:
Vec
<
CrateMismatch
>
,
crate_rejections
:
CrateRejections
,
}
#[derive(Clone)]
...
...
@@ -343,20 +339,16 @@ impl<'a> CrateLocator<'a> {
sess
.target_filesearch
(
path_kind
)
},
is_proc_macro
:
false
,
rejected_via_hash
:
Vec
::
new
(),
rejected_via_triple
:
Vec
::
new
(),
rejected_via_kind
:
Vec
::
new
(),
rejected_via_version
:
Vec
::
new
(),
rejected_via_filename
:
Vec
::
new
(),
crate_rejections
:
CrateRejections
::
default
(),
}
}
crate
fn
reset
(
&
mut
self
)
{
self
.
rejected_
via_hash
.clear
();
self
.
rejected_
via_triple
.clear
();
self
.
rejected_
via_kind
.clear
();
self
.
rejected_
via_version
.clear
();
self
.
rejected_
via_filename
.clear
();
self
.
crate_rejections.
via_hash
.clear
();
self
.
crate_rejections.
via_triple
.clear
();
self
.
crate_rejections.
via_kind
.clear
();
self
.
crate_rejections.
via_version
.clear
();
self
.
crate_rejections.
via_filename
.clear
();
}
crate
fn
maybe_load_library_crate
(
&
mut
self
)
->
Result
<
Option
<
Library
>
,
CrateError
>
{
...
...
@@ -439,7 +431,7 @@ fn find_library_crate(
};
FileMatches
});
self
.
rejected_
via_kind
.extend
(
staticlibs
);
self
.
crate_rejections.
via_kind
.extend
(
staticlibs
);
// We have now collected all known libraries into a set of candidates
// keyed of the filename hash listed. For each filename, we also have a
...
...
@@ -610,7 +602,8 @@ fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option<S
let
found_version
=
metadata
.get_rustc_version
();
if
found_version
!=
rustc_version
{
info!
(
"Rejecting via version: expected {} got {}"
,
rustc_version
,
found_version
);
self
.rejected_via_version
self
.crate_rejections
.via_version
.push
(
CrateMismatch
{
path
:
libpath
.to_path_buf
(),
got
:
found_version
});
return
None
;
}
...
...
@@ -632,7 +625,7 @@ fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option<S
if
root
.triple
()
!=
&
self
.triple
{
info!
(
"Rejecting via crate triple: expected {} got {}"
,
self
.triple
,
root
.triple
());
self
.
rejected_
via_triple
.push
(
CrateMismatch
{
self
.
crate_rejections.
via_triple
.push
(
CrateMismatch
{
path
:
libpath
.to_path_buf
(),
got
:
root
.triple
()
.to_string
(),
});
...
...
@@ -643,7 +636,8 @@ fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option<S
if
let
Some
(
expected_hash
)
=
self
.hash
{
if
hash
!=
expected_hash
{
info!
(
"Rejecting via hash: expected {} got {}"
,
expected_hash
,
hash
);
self
.rejected_via_hash
self
.crate_rejections
.via_hash
.push
(
CrateMismatch
{
path
:
libpath
.to_path_buf
(),
got
:
hash
.to_string
()
});
return
None
;
}
...
...
@@ -697,7 +691,8 @@ fn find_commandline_library(&mut self) -> Result<Option<Library>, CrateError> {
dylibs
.insert
(
loc_canon
,
PathKind
::
ExternFlag
);
}
}
else
{
self
.rejected_via_filename
self
.crate_rejections
.via_filename
.push
(
CrateMismatch
{
path
:
loc
.original
()
.clone
(),
got
:
String
::
new
()
});
}
}
...
...
@@ -713,11 +708,7 @@ fn find_commandline_library(&mut self) -> Result<Option<Library>, CrateError> {
triple
:
self
.triple
,
dll_prefix
:
self
.target.dll_prefix
.clone
(),
dll_suffix
:
self
.target.dll_suffix
.clone
(),
rejected_via_hash
:
self
.rejected_via_hash
,
rejected_via_triple
:
self
.rejected_via_triple
,
rejected_via_kind
:
self
.rejected_via_kind
,
rejected_via_version
:
self
.rejected_via_version
,
rejected_via_filename
:
self
.rejected_via_filename
,
crate_rejections
:
self
.crate_rejections
,
})
}
}
...
...
@@ -844,6 +835,15 @@ struct CrateMismatch {
got
:
String
,
}
#[derive(Clone,
Default)]
struct
CrateRejections
{
via_hash
:
Vec
<
CrateMismatch
>
,
via_triple
:
Vec
<
CrateMismatch
>
,
via_kind
:
Vec
<
CrateMismatch
>
,
via_version
:
Vec
<
CrateMismatch
>
,
via_filename
:
Vec
<
CrateMismatch
>
,
}
/// Candidate rejection reasons collected during crate search.
/// If no candidate is accepted, then these reasons are presented to the user,
/// otherwise they are ignored.
...
...
@@ -853,11 +853,7 @@ struct CrateMismatch {
triple
:
TargetTriple
,
dll_prefix
:
String
,
dll_suffix
:
String
,
rejected_via_hash
:
Vec
<
CrateMismatch
>
,
rejected_via_triple
:
Vec
<
CrateMismatch
>
,
rejected_via_kind
:
Vec
<
CrateMismatch
>
,
rejected_via_version
:
Vec
<
CrateMismatch
>
,
rejected_via_filename
:
Vec
<
CrateMismatch
>
,
crate_rejections
:
CrateRejections
,
}
crate
enum
CrateError
{
...
...
@@ -966,7 +962,7 @@ impl CrateError {
Some
(
r
)
=>
format!
(
" which `{}` depends on"
,
r
.name
),
};
let
mut
msg
=
"the following crate versions were found:"
.to_string
();
let
mut
err
=
if
!
locator
.
rejected_
via_hash
.is_empty
()
{
let
mut
err
=
if
!
locator
.
crate_rejections.
via_hash
.is_empty
()
{
let
mut
err
=
struct_span_err!
(
sess
,
span
,
...
...
@@ -976,7 +972,7 @@ impl CrateError {
add
,
);
err
.note
(
"perhaps that crate needs to be recompiled?"
);
let
mismatches
=
locator
.
rejected_
via_hash
.iter
();
let
mismatches
=
locator
.
crate_rejections.
via_hash
.iter
();
for
CrateMismatch
{
path
,
..
}
in
mismatches
{
msg
.push_str
(
&
format!
(
"
\n
crate `{}`: {}"
,
crate_name
,
path
.display
()));
}
...
...
@@ -987,7 +983,7 @@ impl CrateError {
}
err
.note
(
&
msg
);
err
}
else
if
!
locator
.
rejected_
via_triple
.is_empty
()
{
}
else
if
!
locator
.
crate_rejections.
via_triple
.is_empty
()
{
let
mut
err
=
struct_span_err!
(
sess
,
span
,
...
...
@@ -997,7 +993,7 @@ impl CrateError {
locator
.triple
,
add
,
);
let
mismatches
=
locator
.
rejected_
via_triple
.iter
();
let
mismatches
=
locator
.
crate_rejections.
via_triple
.iter
();
for
CrateMismatch
{
path
,
got
}
in
mismatches
{
msg
.push_str
(
&
format!
(
"
\n
crate `{}`, target triple {}: {}"
,
...
...
@@ -1008,7 +1004,7 @@ impl CrateError {
}
err
.note
(
&
msg
);
err
}
else
if
!
locator
.
rejected_
via_kind
.is_empty
()
{
}
else
if
!
locator
.
crate_rejections.
via_kind
.is_empty
()
{
let
mut
err
=
struct_span_err!
(
sess
,
span
,
...
...
@@ -1018,13 +1014,13 @@ impl CrateError {
add
,
);
err
.help
(
"please recompile that crate using --crate-type lib"
);
let
mismatches
=
locator
.
rejected_
via_kind
.iter
();
let
mismatches
=
locator
.
crate_rejections.
via_kind
.iter
();
for
CrateMismatch
{
path
,
..
}
in
mismatches
{
msg
.push_str
(
&
format!
(
"
\n
crate `{}`: {}"
,
crate_name
,
path
.display
()));
}
err
.note
(
&
msg
);
err
}
else
if
!
locator
.
rejected_
via_version
.is_empty
()
{
}
else
if
!
locator
.
crate_rejections.
via_version
.is_empty
()
{
let
mut
err
=
struct_span_err!
(
sess
,
span
,
...
...
@@ -1037,7 +1033,7 @@ impl CrateError {
"please recompile that crate using this compiler ({})"
,
rustc_version
(),
));
let
mismatches
=
locator
.
rejected_
via_version
.iter
();
let
mismatches
=
locator
.
crate_rejections.
via_version
.iter
();
for
CrateMismatch
{
path
,
got
}
in
mismatches
{
msg
.push_str
(
&
format!
(
"
\n
crate `{}` compiled by {}: {}"
,
...
...
@@ -1104,8 +1100,8 @@ impl CrateError {
err
};
if
!
locator
.
rejected_
via_filename
.is_empty
()
{
let
mismatches
=
locator
.
rejected_
via_filename
.iter
();
if
!
locator
.
crate_rejections.
via_filename
.is_empty
()
{
let
mismatches
=
locator
.
crate_rejections.
via_filename
.iter
();
for
CrateMismatch
{
path
,
..
}
in
mismatches
{
err
.note
(
&
format!
(
"extern location for {} is of an unknown type: {}"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录