Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0dd07429
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,发现更多精彩内容 >>
提交
0dd07429
编写于
1月 05, 2015
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
差异文件
rollup merge of #20258: sanxiyn/show-span-2
上级
ba2b79c7
98aeac29
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
64 addition
and
12 deletion
+64
-12
src/librustc/session/config.rs
src/librustc/session/config.rs
+4
-2
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+2
-2
src/librustc_driver/driver.rs
src/librustc_driver/driver.rs
+3
-3
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+6
-2
src/libsyntax/show_span.rs
src/libsyntax/show_span.rs
+49
-3
未找到文件。
src/librustc/session/config.rs
浏览文件 @
0dd07429
...
...
@@ -105,6 +105,7 @@ pub struct Options {
pub
prints
:
Vec
<
PrintRequest
>
,
pub
cg
:
CodegenOptions
,
pub
color
:
ColorConfig
,
pub
show_span
:
Option
<
String
>
,
pub
externs
:
HashMap
<
String
,
Vec
<
String
>>
,
pub
crate_name
:
Option
<
String
>
,
/// An optional name to use as the crate for std during std injection,
...
...
@@ -211,6 +212,7 @@ pub fn basic_options() -> Options {
prints
:
Vec
::
new
(),
cg
:
basic_codegen_options
(),
color
:
Auto
,
show_span
:
None
,
externs
:
HashMap
::
new
(),
crate_name
:
None
,
alt_std_name
:
None
,
...
...
@@ -259,7 +261,6 @@ pub enum CrateType {
BORROWCK_STATS
,
NO_LANDING_PADS
,
DEBUG_LLVM
,
SHOW_SPAN
,
COUNT_TYPE_SIZES
,
META_STATS
,
GC
,
...
...
@@ -299,7 +300,6 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
(
"no-landing-pads"
,
"omit landing pads for unwinding"
,
NO_LANDING_PADS
),
(
"debug-llvm"
,
"enable debug output from LLVM"
,
DEBUG_LLVM
),
(
"show-span"
,
"show spans for compiler debugging"
,
SHOW_SPAN
),
(
"count-type-sizes"
,
"count the sizes of aggregate types"
,
COUNT_TYPE_SIZES
),
(
"meta-stats"
,
"gather metadata statistics"
,
META_STATS
),
...
...
@@ -823,6 +823,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node), or
`everybody_loops` (all function bodies replaced with `loop {}`)."
,
"TYPE"
),
opt
::
opt_u
(
""
,
"show-span"
,
"Show spans for compiler debugging"
,
"expr|pat|ty"
),
opt
::
flagopt
(
""
,
"dep-info"
,
"Output dependency info to <filename> after compiling,
\
in a format suitable for use by Makefiles"
,
"FILENAME"
),
...
...
@@ -1143,6 +1144,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
prints
:
prints
,
cg
:
cg
,
color
:
color
,
show_span
:
None
,
externs
:
externs
,
crate_name
:
crate_name
,
alt_std_name
:
None
,
...
...
src/librustc/session/mod.rs
浏览文件 @
0dd07429
...
...
@@ -201,8 +201,8 @@ pub fn lto(&self) -> bool {
pub
fn
no_landing_pads
(
&
self
)
->
bool
{
self
.debugging_opt
(
config
::
NO_LANDING_PADS
)
}
pub
fn
show_span
(
&
self
)
->
bool
{
self
.debugging_opt
(
config
::
SHOW_SPAN
)
pub
fn
unstable_options
(
&
self
)
->
bool
{
self
.debugging_opt
(
config
::
UNSTABLE_OPTIONS
)
}
pub
fn
print_enum_sizes
(
&
self
)
->
bool
{
self
.debugging_opt
(
config
::
PRINT_ENUM_SIZES
)
...
...
src/librustc_driver/driver.rs
浏览文件 @
0dd07429
...
...
@@ -146,8 +146,8 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
println!
(
"{}"
,
json
::
as_json
(
&
krate
));
}
if
sess
.show_span
()
{
syntax
::
show_span
::
run
(
sess
.diagnostic
(),
&
krate
);
if
let
Some
(
ref
s
)
=
sess
.opts.show_span
{
syntax
::
show_span
::
run
(
sess
.diagnostic
(),
s
.as_slice
(),
&
krate
);
}
krate
...
...
@@ -572,7 +572,7 @@ pub fn stop_after_phase_1(sess: &Session) -> bool {
debug!
(
"invoked with --parse-only, returning early from compile_input"
);
return
true
;
}
if
sess
.
show_span
()
{
if
sess
.
opts.show_span
.is_some
()
{
return
true
;
}
return
sess
.opts.debugging_opts
&
config
::
AST_JSON_NOEXPAND
!=
0
;
...
...
src/librustc_driver/lib.rs
浏览文件 @
0dd07429
...
...
@@ -134,7 +134,7 @@ fn run_compiler(args: &[String]) {
_
=>
early_error
(
"multiple input filenames provided"
)
};
let
sess
=
build_session
(
sopts
,
input_file_path
,
descriptions
);
let
mut
sess
=
build_session
(
sopts
,
input_file_path
,
descriptions
);
let
cfg
=
config
::
build_configuration
(
&
sess
);
if
print_crate_info
(
&
sess
,
Some
(
&
input
),
&
odir
,
&
ofile
)
{
return
...
...
@@ -145,7 +145,7 @@ fn run_compiler(args: &[String]) {
pretty
::
parse_pretty
(
&
sess
,
a
.as_slice
(),
false
)
});
let
pretty
=
if
pretty
.is_none
()
&&
sess
.
debugging_opt
(
config
::
UNSTABLE_OPTIONS
)
{
sess
.
unstable_options
(
)
{
matches
.opt_str
(
"xpretty"
)
.map
(|
a
|
{
// extended with unstable pretty-print variants
pretty
::
parse_pretty
(
&
sess
,
a
.as_slice
(),
true
)
...
...
@@ -162,6 +162,10 @@ fn run_compiler(args: &[String]) {
None
=>
{
/* continue */
}
}
if
sess
.unstable_options
()
{
sess
.opts.show_span
=
matches
.opt_str
(
"show-span"
);
}
let
r
=
matches
.opt_strs
(
"Z"
);
if
r
.contains
(
&
(
"ls"
.to_string
()))
{
match
input
{
...
...
src/libsyntax/show_span.rs
浏览文件 @
0dd07429
...
...
@@ -13,27 +13,73 @@
//! This module shows spans for all expressions in the crate
//! to help with compiler debugging.
use
std
::
str
::
FromStr
;
use
ast
;
use
diagnostic
;
use
visit
;
use
visit
::
Visitor
;
enum
Mode
{
Expression
,
Pattern
,
Type
,
}
impl
FromStr
for
Mode
{
fn
from_str
(
s
:
&
str
)
->
Option
<
Mode
>
{
let
mode
=
match
s
{
"expr"
=>
Mode
::
Expression
,
"pat"
=>
Mode
::
Pattern
,
"ty"
=>
Mode
::
Type
,
_
=>
return
None
};
Some
(
mode
)
}
}
struct
ShowSpanVisitor
<
'a
>
{
span_diagnostic
:
&
'a
diagnostic
::
SpanHandler
,
mode
:
Mode
,
}
impl
<
'a
,
'v
>
Visitor
<
'v
>
for
ShowSpanVisitor
<
'a
>
{
fn
visit_expr
(
&
mut
self
,
e
:
&
ast
::
Expr
)
{
self
.span_diagnostic
.span_note
(
e
.span
,
"expression"
);
if
let
Mode
::
Expression
=
self
.mode
{
self
.span_diagnostic
.span_note
(
e
.span
,
"expression"
);
}
visit
::
walk_expr
(
self
,
e
);
}
fn
visit_pat
(
&
mut
self
,
p
:
&
ast
::
Pat
)
{
if
let
Mode
::
Pattern
=
self
.mode
{
self
.span_diagnostic
.span_note
(
p
.span
,
"pattern"
);
}
visit
::
walk_pat
(
self
,
p
);
}
fn
visit_ty
(
&
mut
self
,
t
:
&
ast
::
Ty
)
{
if
let
Mode
::
Type
=
self
.mode
{
self
.span_diagnostic
.span_note
(
t
.span
,
"type"
);
}
visit
::
walk_ty
(
self
,
t
);
}
fn
visit_mac
(
&
mut
self
,
macro
:
&
ast
::
Mac
)
{
visit
::
walk_mac
(
self
,
macro
);
}
}
pub
fn
run
(
span_diagnostic
:
&
diagnostic
::
SpanHandler
,
krate
:
&
ast
::
Crate
)
{
let
mut
v
=
ShowSpanVisitor
{
span_diagnostic
:
span_diagnostic
};
pub
fn
run
(
span_diagnostic
:
&
diagnostic
::
SpanHandler
,
mode
:
&
str
,
krate
:
&
ast
::
Crate
)
{
let
mode
=
match
mode
.parse
()
{
Some
(
mode
)
=>
mode
,
None
=>
return
};
let
mut
v
=
ShowSpanVisitor
{
span_diagnostic
:
span_diagnostic
,
mode
:
mode
,
};
visit
::
walk_crate
(
&
mut
v
,
krate
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录