Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1fb08f11
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,发现更多精彩内容 >>
提交
1fb08f11
编写于
5月 14, 2014
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libgetopts: Remove all uses of `~str` from `libgetopts`
上级
28bcef85
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
275 addition
and
248 deletion
+275
-248
src/compiletest/compiletest.rs
src/compiletest/compiletest.rs
+6
-7
src/libgetopts/lib.rs
src/libgetopts/lib.rs
+227
-204
src/librustc/driver/config.rs
src/librustc/driver/config.rs
+9
-6
src/librustc/driver/mod.rs
src/librustc/driver/mod.rs
+14
-11
src/librustc/lib.rs
src/librustc/lib.rs
+4
-1
src/librustdoc/lib.rs
src/librustdoc/lib.rs
+11
-12
src/libtest/lib.rs
src/libtest/lib.rs
+3
-6
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-pfib.rs
+1
-1
未找到文件。
src/compiletest/compiletest.rs
浏览文件 @
1fb08f11
...
...
@@ -101,11 +101,7 @@ pub fn parse_config(args: Vec<StrBuf> ) -> Config {
}
let
matches
=
&
match
getopts
::
getopts
(
args_
.iter
()
.map
(|
x
|
x
.to_owned
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
(),
groups
.as_slice
())
{
&
match
getopts
::
getopts
(
args_
.as_slice
(),
groups
.as_slice
())
{
Ok
(
m
)
=>
m
,
Err
(
f
)
=>
fail
!
(
"{}"
,
f
.to_err_msg
())
};
...
...
@@ -146,7 +142,9 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
build_base
:
opt_path
(
matches
,
"build-base"
),
aux_base
:
opt_path
(
matches
,
"aux-base"
),
stage_id
:
matches
.opt_str
(
"stage-id"
)
.unwrap
()
.to_strbuf
(),
mode
:
FromStr
::
from_str
(
matches
.opt_str
(
"mode"
)
.unwrap
())
.expect
(
"invalid mode"
),
mode
:
FromStr
::
from_str
(
matches
.opt_str
(
"mode"
)
.unwrap
()
.as_slice
())
.expect
(
"invalid mode"
),
run_ignored
:
matches
.opt_present
(
"ignored"
),
filter
:
filter
,
logfile
:
matches
.opt_str
(
"logfile"
)
.map
(|
s
|
Path
::
new
(
s
)),
...
...
@@ -154,7 +152,8 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
ratchet_metrics
:
matches
.opt_str
(
"ratchet-metrics"
)
.map
(|
s
|
Path
::
new
(
s
)),
ratchet_noise_percent
:
matches
.opt_str
(
"ratchet-noise-percent"
)
.and_then
(|
s
|
from_str
::
<
f64
>
(
s
)),
matches
.opt_str
(
"ratchet-noise-percent"
)
.and_then
(|
s
|
from_str
::
<
f64
>
(
s
.as_slice
())),
runtool
:
matches
.opt_str
(
"runtool"
)
.map
(|
x
|
x
.to_strbuf
()),
host_rustcflags
:
matches
.opt_str
(
"host-rustcflags"
)
.map
(|
x
|
x
.to_strbuf
()),
...
...
src/libgetopts/lib.rs
浏览文件 @
1fb08f11
此差异已折叠。
点击以展开。
src/librustc/driver/config.rs
浏览文件 @
1fb08f11
...
...
@@ -319,7 +319,7 @@ pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
{
let
mut
cg
=
basic_codegen_options
();
for
option
in
matches
.opt_strs
(
"C"
)
.move_iter
()
{
let
mut
iter
=
option
.splitn
(
'='
,
1
);
let
mut
iter
=
option
.
as_slice
()
.
splitn
(
'='
,
1
);
let
key
=
iter
.next
()
.unwrap
();
let
value
=
iter
.next
();
let
option_to_lookup
=
key
.replace
(
"-"
,
"_"
);
...
...
@@ -563,7 +563,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
mut
crate_types
:
Vec
<
CrateType
>
=
Vec
::
new
();
let
unparsed_crate_types
=
matches
.opt_strs
(
"crate-type"
);
for
unparsed_crate_type
in
unparsed_crate_types
.iter
()
{
for
part
in
unparsed_crate_type
.split
(
','
)
{
for
part
in
unparsed_crate_type
.
as_slice
()
.
split
(
','
)
{
let
new_part
=
match
part
{
"lib"
=>
default_lib_output
(),
"rlib"
=>
CrateTypeRlib
,
...
...
@@ -612,7 +612,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
mut
this_bit
=
0
;
for
tuple
in
debug_map
.iter
()
{
let
(
name
,
bit
)
=
match
*
tuple
{
(
ref
a
,
_
,
b
)
=>
(
a
,
b
)
};
if
*
name
==
*
debug_flag
{
this_bit
=
bit
;
break
;
}
if
*
name
==
debug_flag
.as_slice
()
{
this_bit
=
bit
;
break
;
}
}
if
this_bit
==
0
{
early_error
(
format!
(
"unknown debug flag: {}"
,
*
debug_flag
))
...
...
@@ -628,7 +631,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
if
!
parse_only
&&
!
no_trans
{
let
unparsed_output_types
=
matches
.opt_strs
(
"emit"
);
for
unparsed_output_type
in
unparsed_output_types
.iter
()
{
for
part
in
unparsed_output_type
.split
(
','
)
{
for
part
in
unparsed_output_type
.
as_slice
()
.
split
(
','
)
{
let
output_type
=
match
part
.as_slice
()
{
"asm"
=>
link
::
OutputTypeAssembly
,
"ir"
=>
link
::
OutputTypeLlvmAssembly
,
...
...
@@ -765,7 +768,7 @@ mod test {
#[test]
fn
test_switch_implies_cfg_test
()
{
let
matches
=
&
match
getopts
([
"--test"
.to_
owned
()],
optgroups
()
.as_slice
())
{
&
match
getopts
([
"--test"
.to_
strbuf
()],
optgroups
()
.as_slice
())
{
Ok
(
m
)
=>
m
,
Err
(
f
)
=>
fail
!
(
"test_switch_implies_cfg_test: {}"
,
f
.to_err_msg
())
};
...
...
@@ -780,7 +783,7 @@ fn test_switch_implies_cfg_test() {
#[test]
fn
test_switch_implies_cfg_test_unless_cfg_test
()
{
let
matches
=
&
match
getopts
([
"--test"
.to_
owned
(),
"--cfg=test"
.to_owned
()],
&
match
getopts
([
"--test"
.to_
strbuf
(),
"--cfg=test"
.to_strbuf
()],
optgroups
()
.as_slice
())
{
Ok
(
m
)
=>
m
,
Err
(
f
)
=>
{
...
...
src/librustc/driver/mod.rs
浏览文件 @
1fb08f11
...
...
@@ -35,7 +35,7 @@
pub
mod
config
;
pub
fn
main_args
(
args
:
&
[
~
str
])
->
int
{
pub
fn
main_args
(
args
:
&
[
StrBuf
])
->
int
{
let
owned_args
=
args
.to_owned
();
monitor
(
proc
()
run_compiler
(
owned_args
));
0
...
...
@@ -44,7 +44,7 @@ pub fn main_args(args: &[~str]) -> int {
static
BUG_REPORT_URL
:
&
'static
str
=
"http://static.rust-lang.org/doc/master/complement-bugreport.html"
;
fn
run_compiler
(
args
:
&
[
~
str
])
{
fn
run_compiler
(
args
:
&
[
StrBuf
])
{
let
matches
=
match
handle_options
(
Vec
::
from_slice
(
args
))
{
Some
(
matches
)
=>
matches
,
None
=>
return
...
...
@@ -73,7 +73,7 @@ fn run_compiler(args: &[~str]) {
let
ofile
=
matches
.opt_str
(
"o"
)
.map
(|
o
|
Path
::
new
(
o
));
let
pretty
=
matches
.opt_default
(
"pretty"
,
"normal"
)
.map
(|
a
|
{
parse_pretty
(
&
sess
,
a
)
parse_pretty
(
&
sess
,
a
.as_slice
()
)
});
match
pretty
{
Some
::
<
PpMode
>
(
ppm
)
=>
{
...
...
@@ -84,7 +84,7 @@ fn run_compiler(args: &[~str]) {
}
let
r
=
matches
.opt_strs
(
"Z"
);
if
r
.contains
(
&
(
"ls"
.to_
owned
()))
{
if
r
.contains
(
&
(
"ls"
.to_
strbuf
()))
{
match
input
{
FileInput
(
ref
ifile
)
=>
{
let
mut
stdout
=
io
::
stdout
();
...
...
@@ -191,17 +191,20 @@ fn describe_codegen_flags() {
/// Process command line options. Emits messages as appropirate.If compilation
/// should continue, returns a getopts::Matches object parsed from args, otherwise
/// returns None.
pub
fn
handle_options
(
mut
args
:
Vec
<
~
str
>
)
->
Option
<
getopts
::
Matches
>
{
pub
fn
handle_options
(
mut
args
:
Vec
<
StrBuf
>
)
->
Option
<
getopts
::
Matches
>
{
// Throw away the first argument, the name of the binary
let
_
binary
=
args
.shift
()
.unwrap
();
if
args
.is_empty
()
{
usage
();
return
None
;
}
if
args
.is_empty
()
{
usage
();
return
None
;
}
let
matches
=
match
getopts
::
getopts
(
args
.as_slice
(),
config
::
optgroups
()
.as_slice
())
{
Ok
(
m
)
=>
m
,
Err
(
f
)
=>
{
early_error
(
f
.to_err_msg
());
early_error
(
f
.to_err_msg
()
.as_slice
()
);
}
};
...
...
@@ -212,24 +215,24 @@ pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> {
let
lint_flags
=
matches
.opt_strs
(
"W"
)
.move_iter
()
.collect
::
<
Vec
<
_
>>
()
.append
(
matches
.opt_strs
(
"warn"
)
.as_slice
());
if
lint_flags
.iter
()
.any
(|
x
|
x
==
&
"help"
.to_owned
()
)
{
if
lint_flags
.iter
()
.any
(|
x
|
x
.as_slice
()
==
"help"
)
{
describe_warnings
();
return
None
;
}
let
r
=
matches
.opt_strs
(
"Z"
);
if
r
.iter
()
.any
(|
x
|
x
==
&
"help"
.to_owned
()
)
{
if
r
.iter
()
.any
(|
x
|
x
.as_slice
()
==
"help"
)
{
describe_debug_flags
();
return
None
;
}
let
cg_flags
=
matches
.opt_strs
(
"C"
);
if
cg_flags
.iter
()
.any
(|
x
|
x
==
&
"help"
.to_owned
()
)
{
if
cg_flags
.iter
()
.any
(|
x
|
x
.as_slice
()
==
"help"
)
{
describe_codegen_flags
();
return
None
;
}
if
cg_flags
.contains
(
&
"passes=list"
.to_
owned
())
{
if
cg_flags
.contains
(
&
"passes=list"
.to_
strbuf
())
{
unsafe
{
::
lib
::
llvm
::
llvm
::
LLVMRustPrintPasses
();
}
return
None
;
}
...
...
src/librustc/lib.rs
浏览文件 @
1fb08f11
...
...
@@ -121,5 +121,8 @@ pub mod lib {
}
pub
fn
main
()
{
std
::
os
::
set_exit_status
(
driver
::
main_args
(
std
::
os
::
args
()
.as_slice
()));
let
args
=
std
::
os
::
args
()
.iter
()
.map
(|
x
|
x
.to_strbuf
())
.collect
::
<
Vec
<
_
>>
();
std
::
os
::
set_exit_status
(
driver
::
main_args
(
args
.as_slice
()));
}
src/librustdoc/lib.rs
浏览文件 @
1fb08f11
...
...
@@ -137,12 +137,7 @@ pub fn usage(argv0: &str) {
}
pub
fn
main_args
(
args
:
&
[
StrBuf
])
->
int
{
let
matches
=
match
getopts
::
getopts
(
args
.tail
()
.iter
()
.map
(|
x
|
(
*
x
)
.to_owned
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
(),
opts
()
.as_slice
())
{
let
matches
=
match
getopts
::
getopts
(
args
.tail
(),
opts
()
.as_slice
())
{
Ok
(
m
)
=>
m
,
Err
(
err
)
=>
{
println!
(
"{}"
,
err
.to_err_msg
());
...
...
@@ -170,7 +165,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
let
test_args
=
matches
.opt_strs
(
"test-args"
);
let
test_args
:
Vec
<
StrBuf
>
=
test_args
.iter
()
.flat_map
(|
s
|
s
.words
())
.flat_map
(|
s
|
s
.
as_slice
()
.
words
())
.map
(|
s
|
s
.to_strbuf
())
.collect
();
...
...
@@ -199,7 +194,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
(
false
,
false
)
=>
{}
}
if
matches
.opt_strs
(
"passes"
)
.as_slice
()
==
&
[
"list"
.to_
owned
()]
{
if
matches
.opt_strs
(
"passes"
)
.as_slice
()
==
&
[
"list"
.to_
strbuf
()]
{
println!
(
"Available passes for running rustdoc:"
);
for
&
(
name
,
_
,
description
)
in
PASSES
.iter
()
{
println!
(
"{:>20s} - {}"
,
name
,
description
);
...
...
@@ -306,7 +301,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
clean
::
NameValue
(
ref
x
,
ref
value
)
if
"passes"
==
x
.as_slice
()
=>
{
for
pass
in
value
.as_slice
()
.words
()
{
passes
.push
(
pass
.to_
owned
());
passes
.push
(
pass
.to_
strbuf
());
}
}
clean
::
NameValue
(
ref
x
,
ref
value
)
...
...
@@ -323,15 +318,19 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
}
if
default_passes
{
for
name
in
DEFAULT_PASSES
.iter
()
.rev
()
{
passes
.unshift
(
name
.to_
owned
());
passes
.unshift
(
name
.to_
strbuf
());
}
}
// Load all plugins/passes into a PluginManager
let
path
=
matches
.opt_str
(
"plugin-path"
)
.unwrap_or
(
"/tmp/rustdoc/plugins"
.to_owned
());
let
path
=
matches
.opt_str
(
"plugin-path"
)
.unwrap_or
(
"/tmp/rustdoc/plugins"
.to_strbuf
());
let
mut
pm
=
plugins
::
PluginManager
::
new
(
Path
::
new
(
path
));
for
pass
in
passes
.iter
()
{
let
plugin
=
match
PASSES
.iter
()
.position
(|
&
(
p
,
_
,
_
)|
p
==
*
pass
)
{
let
plugin
=
match
PASSES
.iter
()
.position
(|
&
(
p
,
_
,
_
)|
{
p
==
pass
.as_slice
()
})
{
Some
(
i
)
=>
PASSES
[
i
]
.val1
(),
None
=>
{
error!
(
"unknown pass {}, skipping"
,
*
pass
);
...
...
src/libtest/lib.rs
浏览文件 @
1fb08f11
...
...
@@ -354,11 +354,7 @@ fn usage(binary: &str) {
pub
fn
parse_opts
(
args
:
&
[
StrBuf
])
->
Option
<
OptRes
>
{
let
args_
=
args
.tail
();
let
matches
=
match
getopts
::
getopts
(
args_
.iter
()
.map
(|
x
|
x
.to_owned
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
(),
optgroups
()
.as_slice
())
{
match
getopts
::
getopts
(
args_
.as_slice
(),
optgroups
()
.as_slice
())
{
Ok
(
m
)
=>
m
,
Err
(
f
)
=>
return
Some
(
Err
(
f
.to_err_msg
()
.to_strbuf
()))
};
...
...
@@ -388,7 +384,8 @@ pub fn parse_opts(args: &[StrBuf]) -> Option<OptRes> {
let
ratchet_metrics
=
ratchet_metrics
.map
(|
s
|
Path
::
new
(
s
));
let
ratchet_noise_percent
=
matches
.opt_str
(
"ratchet-noise-percent"
);
let
ratchet_noise_percent
=
ratchet_noise_percent
.map
(|
s
|
from_str
::
<
f64
>
(
s
)
.unwrap
());
let
ratchet_noise_percent
=
ratchet_noise_percent
.map
(|
s
|
from_str
::
<
f64
>
(
s
.as_slice
())
.unwrap
());
let
save_metrics
=
matches
.opt_str
(
"save-metrics"
);
let
save_metrics
=
save_metrics
.map
(|
s
|
Path
::
new
(
s
));
...
...
src/test/bench/shootout-pfib.rs
浏览文件 @
1fb08f11
...
...
@@ -55,7 +55,7 @@ struct Config {
fn
parse_opts
(
argv
:
Vec
<
StrBuf
>
)
->
Config
{
let
opts
=
vec!
(
getopts
::
optflag
(
""
,
"stress"
,
""
));
let
argv
=
argv
.iter
()
.map
(|
x
|
x
.to_str
())
.collect
::
<
Vec
<
_
>>
();
let
argv
=
argv
.iter
()
.map
(|
x
|
x
.to_str
buf
())
.collect
::
<
Vec
<
_
>>
();
let
opt_args
=
argv
.slice
(
1
,
argv
.len
());
match
getopts
::
getopts
(
opt_args
,
opts
.as_slice
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录