Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e4849d5e
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,发现更多精彩内容 >>
提交
e4849d5e
编写于
1月 13, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Allow a custom diagnostic emitter when building the handler
上级
7cbd90f5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
17 deletion
+36
-17
src/cargo/cargo.rs
src/cargo/cargo.rs
+1
-1
src/comp/driver/diagnostic.rs
src/comp/driver/diagnostic.rs
+30
-11
src/comp/driver/driver.rs
src/comp/driver/driver.rs
+1
-1
src/fuzzer/fuzzer.rs
src/fuzzer/fuzzer.rs
+3
-3
src/rustdoc/rustdoc.rs
src/rustdoc/rustdoc.rs
+1
-1
未找到文件。
src/cargo/cargo.rs
浏览文件 @
e4849d5e
...
...
@@ -104,7 +104,7 @@ fn load_pkg(filename: str) -> option::t<pkg> {
let
sess
=
@
{
cm
:
cm
,
mutable
next_id
:
0
,
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
)
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
,
none
)
};
let
c
=
parser
::
parse_crate_from_crate_file
(
filename
,
[],
sess
);
...
...
src/comp/driver/diagnostic.rs
浏览文件 @
e4849d5e
...
...
@@ -3,10 +3,14 @@
import
syntax
::
codemap
;
import
codemap
::
span
;
export
emit_diagnostic
;
export
emit
ter
,
emit
_diagnostic
;
export
diagnostictype
,
fatal
,
error
,
warning
,
note
;
export
handler
,
mk_codemap_handler
;
type
emitter
=
fn
@
(
cmsp
:
option
<
(
codemap
::
codemap
,
span
)
>
,
msg
:
str
,
t
:
diagnostictype
);
iface
handler
{
fn
span_fatal
(
sp
:
span
,
msg
:
str
)
->
!
;
fn
fatal
(
msg
:
str
)
->
!
;
...
...
@@ -26,24 +30,25 @@
type
codemap_t
=
@
{
cm
:
codemap
::
codemap
,
mutable
err_count
:
uint
mutable
err_count
:
uint
,
emit
:
emitter
};
impl
codemap_handler
of
handler
for
codemap_t
{
fn
span_fatal
(
sp
:
span
,
msg
:
str
)
->
!
{
emit_diagnostic
(
some
((
self
.cm
,
sp
)),
msg
,
fatal
);
self
.emit
(
some
((
self
.cm
,
sp
)),
msg
,
fatal
);
fail
;
}
fn
fatal
(
msg
:
str
)
->
!
{
emit_diagnostic
(
none
,
msg
,
fatal
);
self
.emit
(
none
,
msg
,
fatal
);
fail
;
}
fn
span_err
(
sp
:
span
,
msg
:
str
)
{
emit_diagnostic
(
some
((
self
.cm
,
sp
)),
msg
,
error
);
self
.emit
(
some
((
self
.cm
,
sp
)),
msg
,
error
);
self
.err_count
+=
1u
;
}
fn
err
(
msg
:
str
)
{
emit_diagnostic
(
none
,
msg
,
error
);
self
.emit
(
none
,
msg
,
error
);
self
.err_count
+=
1u
;
}
fn
has_errors
()
->
bool
{
self
.err_count
>
0u
}
...
...
@@ -53,16 +58,16 @@ fn abort_if_errors() {
}
}
fn
span_warn
(
sp
:
span
,
msg
:
str
)
{
emit_diagnostic
(
some
((
self
.cm
,
sp
)),
msg
,
warning
);
self
.emit
(
some
((
self
.cm
,
sp
)),
msg
,
warning
);
}
fn
warn
(
msg
:
str
)
{
emit_diagnostic
(
none
,
msg
,
warning
);
self
.emit
(
none
,
msg
,
warning
);
}
fn
span_note
(
sp
:
span
,
msg
:
str
)
{
emit_diagnostic
(
some
((
self
.cm
,
sp
)),
msg
,
note
);
self
.emit
(
some
((
self
.cm
,
sp
)),
msg
,
note
);
}
fn
note
(
msg
:
str
)
{
emit_diagnostic
(
none
,
msg
,
note
);
self
.emit
(
none
,
msg
,
note
);
}
fn
span_bug
(
sp
:
span
,
msg
:
str
)
->
!
{
self
.span_fatal
(
sp
,
#
fmt
[
"internal compiler error %s"
,
msg
]);
...
...
@@ -76,10 +81,24 @@ fn span_unimpl(sp: span, msg: str) -> ! {
fn
unimpl
(
msg
:
str
)
->
!
{
self
.bug
(
"unimplemented "
+
msg
);
}
}
fn
mk_codemap_handler
(
cm
:
codemap
::
codemap
)
->
handler
{
fn
mk_codemap_handler
(
cm
:
codemap
::
codemap
,
emitter
:
option
<
emitter
>
)
->
handler
{
let
emit
=
alt
emitter
{
some
(
e
)
{
e
}
none
.
{
let
f
=
fn
@
(
cmsp
:
option
<
(
codemap
::
codemap
,
span
)
>
,
msg
:
str
,
t
:
diagnostictype
)
{
emit_diagnostic
(
cmsp
,
msg
,
t
);
};
f
}
};
@
{
cm
:
cm
,
mutable
err_count
:
0u
,
emit
:
emit
}
as
handler
}
...
...
src/comp/driver/driver.rs
浏览文件 @
e4849d5e
...
...
@@ -452,7 +452,7 @@ fn build_session(sopts: @session::options, input: str) -> session::session {
sopts
.target_triple
,
sopts
.addl_lib_search_paths
);
let
codemap
=
codemap
::
new_codemap
();
let
diagnostic_handler
=
diagnostic
::
mk_codemap_handler
(
codemap
);
let
diagnostic_handler
=
diagnostic
::
mk_codemap_handler
(
codemap
,
none
);
@
{
targ_cfg
:
target_cfg
,
opts
:
sopts
,
cstore
:
cstore
,
...
...
src/fuzzer/fuzzer.rs
浏览文件 @
e4849d5e
...
...
@@ -262,7 +262,7 @@ fn check_variants_T<T: copy>(
let
str3
=
as_str
(
bind
pprust
::
print_crate
(
codemap
,
diagnostic
::
mk_codemap_handler
(
codemap
),
diagnostic
::
mk_codemap_handler
(
codemap
,
none
),
crate2
,
filename
,
io
::
string_reader
(
""
),
_
,
...
...
@@ -419,7 +419,7 @@ fn parse_and_print(code: str) -> str {
let
sess
=
@
{
cm
:
cm
,
mutable
next_id
:
0
,
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
)
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
,
none
)
};
write_file
(
filename
,
code
);
let
crate
=
parser
::
parse_crate_from_source_str
(
...
...
@@ -566,7 +566,7 @@ fn check_variants(files: [str], cx: context) {
let
sess
=
@
{
cm
:
cm
,
mutable
next_id
:
0
,
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
)
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
,
none
)
};
let
crate
=
parser
::
parse_crate_from_source_str
(
...
...
src/rustdoc/rustdoc.rs
浏览文件 @
e4849d5e
...
...
@@ -194,7 +194,7 @@ fn main(argv: [str]) {
let
sess
=
@
{
cm
:
cm
,
mutable
next_id
:
0
,
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
)
diagnostic
:
diagnostic
::
mk_codemap_handler
(
cm
,
none
)
};
let
rd
=
{
ps
:
pprust
::
rust_printer
(
w
),
w
:
w
};
doc_header
(
rd
,
argv
[
1
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录