Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8e3df865
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,发现更多精彩内容 >>
提交
8e3df865
编写于
2月 05, 2015
作者:
P
Potpourri
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve error message, when found staticlib instead crate
上级
706be5ba
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
61 addition
and
5 deletion
+61
-5
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+3
-1
src/librustc/metadata/loader.rs
src/librustc/metadata/loader.rs
+27
-4
src/test/run-make/error-found-staticlib-instead-crate/Makefile
...est/run-make/error-found-staticlib-instead-crate/Makefile
+5
-0
src/test/run-make/error-found-staticlib-instead-crate/bar.rs
src/test/run-make/error-found-staticlib-instead-crate/bar.rs
+15
-0
src/test/run-make/error-found-staticlib-instead-crate/foo.rs
src/test/run-make/error-found-staticlib-instead-crate/foo.rs
+11
-0
未找到文件。
src/librustc/metadata/creader.rs
浏览文件 @
8e3df865
// Copyright 2012-201
4
The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-201
5
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -419,6 +419,7 @@ fn resolve_crate(&mut self,
root
:
root
,
rejected_via_hash
:
vec!
(),
rejected_via_triple
:
vec!
(),
rejected_via_kind
:
vec!
(),
should_match_name
:
true
,
};
let
library
=
load_ctxt
.load_library_crate
();
...
...
@@ -483,6 +484,7 @@ pub fn read_plugin_metadata<'b>(&'b mut self,
root
:
&
None
,
rejected_via_hash
:
vec!
(),
rejected_via_triple
:
vec!
(),
rejected_via_kind
:
vec!
(),
should_match_name
:
true
,
};
let
library
=
match
load_ctxt
.maybe_load_library_crate
()
{
...
...
src/librustc/metadata/loader.rs
浏览文件 @
8e3df865
// Copyright 2012-201
4
The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-201
5
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -257,6 +257,7 @@ pub struct Context<'a> {
pub
root
:
&
'a
Option
<
CratePaths
>
,
pub
rejected_via_hash
:
Vec
<
CrateMismatch
>
,
pub
rejected_via_triple
:
Vec
<
CrateMismatch
>
,
pub
rejected_via_kind
:
Vec
<
CrateMismatch
>
,
pub
should_match_name
:
bool
,
}
...
...
@@ -311,6 +312,8 @@ pub fn report_load_errs(&mut self) {
}
else
if
self
.rejected_via_triple
.len
()
>
0
{
format!
(
"couldn't find crate `{}` with expected target triple {}"
,
self
.ident
,
self
.triple
)
}
else
if
self
.rejected_via_kind
.len
()
>
0
{
format!
(
"found staticlib `{}` instead of rlib or dylib"
,
self
.ident
)
}
else
{
format!
(
"can't find crate for `{}`"
,
self
.ident
)
};
...
...
@@ -335,8 +338,8 @@ pub fn report_load_errs(&mut self) {
let
mismatches
=
self
.rejected_via_hash
.iter
();
for
(
i
,
&
CrateMismatch
{
ref
path
,
..
})
in
mismatches
.enumerate
()
{
self
.sess
.fileline_note
(
self
.span
,
&
format!
(
"crate `{}` path
{}
{}: {}"
,
self
.ident
,
"#"
,
i
+
1
,
path
.display
())[]);
&
format!
(
"crate `{}` path
#
{}: {}"
,
self
.ident
,
i
+
1
,
path
.display
())[]);
}
match
self
.root
{
&
None
=>
{}
...
...
@@ -349,6 +352,16 @@ pub fn report_load_errs(&mut self) {
}
}
}
if
self
.rejected_via_kind
.len
()
>
0
{
self
.sess
.span_help
(
self
.span
,
"please recompile this crate using
\
--crate-type lib"
);
let
mismatches
=
self
.rejected_via_kind
.iter
();
for
(
i
,
&
CrateMismatch
{
ref
path
,
..
})
in
mismatches
.enumerate
()
{
self
.sess
.fileline_note
(
self
.span
,
&
format!
(
"crate `{}` path #{}: {}"
,
self
.ident
,
i
+
1
,
path
.display
())[]);
}
}
self
.sess
.abort_if_errors
();
}
...
...
@@ -369,8 +382,10 @@ fn find_library_crate(&mut self) -> Option<Library> {
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
let
dylib_prefix
=
format!
(
"{}{}"
,
dypair
.0
,
self
.crate_name
);
let
rlib_prefix
=
format!
(
"lib{}"
,
self
.crate_name
);
let
staticlib_prefix
=
format!
(
"lib{}"
,
self
.crate_name
);
let
mut
candidates
=
HashMap
::
new
();
let
mut
staticlibs
=
vec!
();
// First, find all possible candidate rlibs and dylibs purely based on
// the name of the files themselves. We're trying to match against an
...
...
@@ -391,7 +406,7 @@ fn find_library_crate(&mut self) -> Option<Library> {
Some
(
file
)
=>
file
,
};
let
(
hash
,
rlib
)
=
if
file
.starts_with
(
&
rlib_prefix
[])
&&
file
.ends_with
(
".rlib"
)
{
file
.ends_with
(
".rlib"
)
{
(
&
file
[(
rlib_prefix
.len
())
..
(
file
.len
()
-
".rlib"
.len
())],
true
)
}
else
if
file
.starts_with
(
&
dylib_prefix
)
&&
...
...
@@ -399,6 +414,13 @@ fn find_library_crate(&mut self) -> Option<Library> {
(
&
file
[(
dylib_prefix
.len
())
..
(
file
.len
()
-
dypair
.1
.len
())],
false
)
}
else
{
if
file
.starts_with
(
&
staticlib_prefix
[])
&&
file
.ends_with
(
".a"
)
{
staticlibs
.push
(
CrateMismatch
{
path
:
path
.clone
(),
got
:
"static"
.to_string
()
});
}
return
FileDoesntMatch
};
info!
(
"lib candidate: {}"
,
path
.display
());
...
...
@@ -415,6 +437,7 @@ fn find_library_crate(&mut self) -> Option<Library> {
FileMatches
});
self
.rejected_via_kind
.extend
(
staticlibs
.into_iter
());
// 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
...
...
src/test/run-make/error-found-staticlib-instead-crate/Makefile
0 → 100644
浏览文件 @
8e3df865
-include
../tools.mk
all
:
$(RUSTC)
foo.rs
--crate-type
staticlib
$(RUSTC)
bar.rs 2>&1 |
grep
"error: found staticlib"
src/test/run-make/error-found-staticlib-instead-crate/bar.rs
0 → 100644
浏览文件 @
8e3df865
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern
crate
foo
;
fn
main
()
{
foo
::
foo
();
}
src/test/run-make/error-found-staticlib-instead-crate/foo.rs
0 → 100644
浏览文件 @
8e3df865
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub
fn
foo
()
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录