Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
25451967
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,发现更多精彩内容 >>
提交
25451967
编写于
4月 17, 2019
作者:
I
Igor Matuszewski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save-analysis: Use serde instead of libserialize to dump JSON data
上级
4d9c6cd7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
9 deletion
+11
-9
Cargo.lock
Cargo.lock
+1
-1
src/librustc_save_analysis/Cargo.toml
src/librustc_save_analysis/Cargo.toml
+1
-2
src/librustc_save_analysis/json_dumper.rs
src/librustc_save_analysis/json_dumper.rs
+2
-4
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+7
-2
未找到文件。
Cargo.lock
浏览文件 @
25451967
...
@@ -2933,11 +2933,11 @@ dependencies = [
...
@@ -2933,11 +2933,11 @@ dependencies = [
"rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-data 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc 0.0.0",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_codegen_utils 0.0.0",
"rustc_codegen_utils 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_target 0.0.0",
"rustc_target 0.0.0",
"rustc_typeck 0.0.0",
"rustc_typeck 0.0.0",
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
"syntax_pos 0.0.0",
]
]
...
...
src/librustc_save_analysis/Cargo.toml
浏览文件 @
25451967
...
@@ -16,9 +16,8 @@ rustc_data_structures = { path = "../librustc_data_structures" }
...
@@ -16,9 +16,8 @@ rustc_data_structures = { path = "../librustc_data_structures" }
rustc_codegen_utils
=
{
path
=
"../librustc_codegen_utils"
}
rustc_codegen_utils
=
{
path
=
"../librustc_codegen_utils"
}
rustc_target
=
{
path
=
"../librustc_target"
}
rustc_target
=
{
path
=
"../librustc_target"
}
rustc_typeck
=
{
path
=
"../librustc_typeck"
}
rustc_typeck
=
{
path
=
"../librustc_typeck"
}
serde_json
=
"1"
syntax
=
{
path
=
"../libsyntax"
}
syntax
=
{
path
=
"../libsyntax"
}
syntax_pos
=
{
path
=
"../libsyntax_pos"
}
syntax_pos
=
{
path
=
"../libsyntax_pos"
}
rls-data
=
"0.18.1"
rls-data
=
"0.18.1"
rls-span
=
"0.4"
rls-span
=
"0.4"
# FIXME(#40527) should move rustc serialize out of tree
rustc-serialize
=
"0.3"
src/librustc_save_analysis/json_dumper.rs
浏览文件 @
25451967
use
std
::
io
::
Write
;
use
std
::
io
::
Write
;
use
rustc_serialize
::
json
::
as_json
;
use
rls_data
::
config
::
Config
;
use
rls_data
::
config
::
Config
;
use
rls_data
::{
self
,
Analysis
,
CompilationOptions
,
CratePreludeData
,
Def
,
DefKind
,
Impl
,
Import
,
use
rls_data
::{
self
,
Analysis
,
CompilationOptions
,
CratePreludeData
,
Def
,
DefKind
,
Impl
,
Import
,
MacroRef
,
Ref
,
RefKind
,
Relation
};
MacroRef
,
Ref
,
RefKind
,
Relation
};
...
@@ -31,8 +29,8 @@ pub struct WriteOutput<'b, W: Write> {
...
@@ -31,8 +29,8 @@ pub struct WriteOutput<'b, W: Write> {
impl
<
'b
,
W
:
Write
>
DumpOutput
for
WriteOutput
<
'b
,
W
>
{
impl
<
'b
,
W
:
Write
>
DumpOutput
for
WriteOutput
<
'b
,
W
>
{
fn
dump
(
&
mut
self
,
result
:
&
Analysis
)
{
fn
dump
(
&
mut
self
,
result
:
&
Analysis
)
{
if
write!
(
self
.output
,
"{}"
,
as_json
(
&
result
))
.is_err
(
)
{
if
let
Err
(
e
)
=
serde_json
::
to_writer
(
self
.output
.by_ref
(),
result
)
{
error!
(
"
Error writing output"
);
error!
(
"
Can't serialize save-analysis: {:?}"
,
e
);
}
}
}
}
}
}
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
25451967
...
@@ -1141,10 +1141,15 @@ fn find_config(supplied: Option<Config>) -> Config {
...
@@ -1141,10 +1141,15 @@ fn find_config(supplied: Option<Config>) -> Config {
if
let
Some
(
config
)
=
supplied
{
if
let
Some
(
config
)
=
supplied
{
return
config
;
return
config
;
}
}
match
env
::
var_os
(
"RUST_SAVE_ANALYSIS_CONFIG"
)
{
match
env
::
var_os
(
"RUST_SAVE_ANALYSIS_CONFIG"
)
{
Some
(
config_string
)
=>
rustc_serialize
::
json
::
decode
(
config_string
.to_str
()
.unwrap
())
.expect
(
"Could not deserialize save-analysis config"
),
None
=>
Config
::
default
(),
None
=>
Config
::
default
(),
Some
(
config
)
=>
config
.to_str
()
.ok_or
(())
.map_err
(|
_
|
error!
(
"`RUST_SAVE_ANALYSIS_CONFIG` isn't UTF-8"
))
.and_then
(|
cfg
|
serde_json
::
from_str
(
cfg
)
.map_err
(|
_
|
error!
(
"Could not deserialize save-analysis config"
))
)
.unwrap_or_default
()
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录