Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
86eb7259
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
86eb7259
编写于
2月 01, 2018
作者:
K
kennytm
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #47895 - varkor:non-utf-stdin, r=estebank
Fix ICE when reading non-UTF-8 input from stdin Fixes #22387.
上级
61972e73
a43d7eb3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
7 deletion
+29
-7
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+22
-7
src/test/run-make/stdin-non-utf8/Makefile
src/test/run-make/stdin-non-utf8/Makefile
+6
-0
src/test/run-make/stdin-non-utf8/non-utf8
src/test/run-make/stdin-non-utf8/non-utf8
+1
-0
未找到文件。
src/librustc_driver/lib.rs
浏览文件 @
86eb7259
...
...
@@ -456,10 +456,13 @@ pub fn run_compiler<'a>(args: &[String],
None
);
let
(
odir
,
ofile
)
=
make_output
(
&
matches
);
let
(
input
,
input_file_path
)
=
match
make_input
(
&
matches
.free
)
{
Some
((
input
,
input_file_path
))
=>
callbacks
.some_input
(
input
,
input_file_path
),
let
(
input
,
input_file_path
,
input_err
)
=
match
make_input
(
&
matches
.free
)
{
Some
((
input
,
input_file_path
,
input_err
))
=>
{
let
(
input
,
input_file_path
)
=
callbacks
.some_input
(
input
,
input_file_path
);
(
input
,
input_file_path
,
input_err
)
},
None
=>
match
callbacks
.no_input
(
&
matches
,
&
sopts
,
&
cfg
,
&
odir
,
&
ofile
,
&
descriptions
)
{
Some
((
input
,
input_file_path
))
=>
(
input
,
input_file_path
),
Some
((
input
,
input_file_path
))
=>
(
input
,
input_file_path
,
None
),
None
=>
return
(
Ok
(()),
None
),
},
};
...
...
@@ -470,6 +473,13 @@ pub fn run_compiler<'a>(args: &[String],
sopts
,
input_file_path
.clone
(),
descriptions
,
codemap
,
emitter_dest
,
);
if
let
Some
(
err
)
=
input_err
{
// Immediately stop compilation if there was an issue reading
// the input (for example if the input stream is not UTF-8).
sess
.err
(
&
format!
(
"{}"
,
err
));
return
(
Err
(
CompileIncomplete
::
Stopped
),
Some
(
sess
));
}
let
trans
=
get_trans
(
&
sess
);
rustc_lint
::
register_builtins
(
&
mut
sess
.lint_store
.borrow_mut
(),
Some
(
&
sess
));
...
...
@@ -512,17 +522,22 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
}
// Extract input (string or file and optional path) from matches.
fn
make_input
(
free_matches
:
&
[
String
])
->
Option
<
(
Input
,
Option
<
PathBuf
>
)
>
{
fn
make_input
(
free_matches
:
&
[
String
])
->
Option
<
(
Input
,
Option
<
PathBuf
>
,
Option
<
io
::
Error
>
)
>
{
if
free_matches
.len
()
==
1
{
let
ifile
=
&
free_matches
[
0
];
if
ifile
==
"-"
{
let
mut
src
=
String
::
new
();
io
::
stdin
()
.read_to_string
(
&
mut
src
)
.unwrap
();
let
err
=
if
io
::
stdin
()
.read_to_string
(
&
mut
src
)
.is_err
()
{
Some
(
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
"couldn't read from stdin, as it did not contain valid UTF-8"
))
}
else
{
None
};
Some
((
Input
::
Str
{
name
:
FileName
::
Anon
,
input
:
src
},
None
))
None
,
err
))
}
else
{
Some
((
Input
::
File
(
PathBuf
::
from
(
ifile
)),
Some
(
PathBuf
::
from
(
ifile
))))
Some
(
PathBuf
::
from
(
ifile
))
,
None
))
}
}
else
{
None
...
...
src/test/run-make/stdin-non-utf8/Makefile
0 → 100644
浏览文件 @
86eb7259
-include
../tools.mk
all
:
cp
non-utf8
$(TMPDIR)
/non-utf.rs
cat
$(TMPDIR)
/non-utf.rs |
$(RUSTC)
- 2>&1
\
|
$(CGREP)
"error: couldn't read from stdin, as it did not contain valid UTF-8"
src/test/run-make/stdin-non-utf8/non-utf8
0 → 100644
浏览文件 @
86eb7259
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录