Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f8e06c49
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,发现更多精彩内容 >>
提交
f8e06c49
编写于
6月 26, 2014
作者:
P
Piotr Jawniak
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary to_string calls
This commit removes superfluous to_string calls from various places
上级
99519cc8
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
62 addition
and
106 deletion
+62
-106
src/compiletest/runtest.rs
src/compiletest/runtest.rs
+2
-5
src/libgetopts/lib.rs
src/libgetopts/lib.rs
+1
-3
src/librustc/back/link.rs
src/librustc/back/link.rs
+1
-1
src/librustc/driver/config.rs
src/librustc/driver/config.rs
+3
-8
src/librustc/driver/driver.rs
src/librustc/driver/driver.rs
+3
-3
src/librustc/lib.rs
src/librustc/lib.rs
+1
-3
src/librustc/lib/llvm.rs
src/librustc/lib/llvm.rs
+1
-1
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+2
-2
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/borrowck/mod.rs
+6
-9
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+1
-1
src/librustdoc/html/markdown.rs
src/librustdoc/html/markdown.rs
+3
-3
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+1
-2
src/librustdoc/lib.rs
src/librustdoc/lib.rs
+5
-18
src/librustdoc/markdown.rs
src/librustdoc/markdown.rs
+0
-9
src/librustdoc/passes.rs
src/librustdoc/passes.rs
+1
-1
src/libstd/path/windows.rs
src/libstd/path/windows.rs
+1
-1
src/libsyntax/ast_map.rs
src/libsyntax/ast_map.rs
+18
-24
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+3
-3
src/libsyntax/crateid.rs
src/libsyntax/crateid.rs
+1
-1
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/deriving/generic/mod.rs
+1
-1
src/libsyntax/parse/lexer/comments.rs
src/libsyntax/parse/lexer/comments.rs
+1
-1
src/libsyntax/print/pp.rs
src/libsyntax/print/pp.rs
+1
-1
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+1
-1
src/libtest/lib.rs
src/libtest/lib.rs
+2
-2
src/test/bench/core-std.rs
src/test/bench/core-std.rs
+1
-1
src/test/run-pass/issue-5666.rs
src/test/run-pass/issue-5666.rs
+1
-1
未找到文件。
src/compiletest/runtest.rs
浏览文件 @
f8e06c49
...
...
@@ -320,7 +320,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
let
config
=
&
mut
config
;
let
DebuggerCommands
{
commands
,
check_lines
,
..
}
=
parse_debugger_commands
(
testfile
,
"gdb"
);
let
mut
cmds
=
commands
.connect
(
"
\n
"
)
.to_string
()
;
let
mut
cmds
=
commands
.connect
(
"
\n
"
);
// compile test file (it shoud have 'compile-flags:-g' in the header)
let
compiler_run_result
=
compile_test
(
config
,
props
,
testfile
);
...
...
@@ -1035,10 +1035,7 @@ fn compose_and_run_compiler(
make_compile_args
(
config
,
&
aux_props
,
crate_type
.append
(
extra_link_args
.iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
()),
extra_link_args
.as_slice
()),
|
a
,
b
|
{
let
f
=
make_lib_name
(
a
,
b
,
testfile
);
ThisDirectory
(
f
.dir_path
())
...
...
src/libgetopts/lib.rs
浏览文件 @
f8e06c49
...
...
@@ -49,9 +49,7 @@
//! }
//!
//! fn main() {
//! let args: Vec<String> = os::args().iter()
//! .map(|x| x.to_string())
//! .collect();
//! let args: Vec<String> = os::args();
//!
//! let program = args.get(0).clone();
//!
...
...
src/librustc/back/link.rs
浏览文件 @
f8e06c49
...
...
@@ -659,7 +659,7 @@ pub fn sanitize(s: &str) -> String {
if
result
.len
()
>
0u
&&
result
.as_slice
()[
0
]
!=
'_'
as
u8
&&
!
char
::
is_XID_start
(
result
.as_slice
()[
0
]
as
char
)
{
return
format!
(
"_{}"
,
result
.as_slice
())
.to_string
()
;
return
format!
(
"_{}"
,
result
.as_slice
());
}
return
result
;
...
...
src/librustc/driver/config.rs
浏览文件 @
f8e06c49
...
...
@@ -650,10 +650,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
let
sysroot_opt
=
matches
.opt_str
(
"sysroot"
)
.map
(|
m
|
Path
::
new
(
m
));
let
target
=
match
matches
.opt_str
(
"target"
)
{
Some
(
supplied_target
)
=>
supplied_target
.to_string
(),
None
=>
driver
::
host_triple
()
.to_string
(),
};
let
target
=
matches
.opt_str
(
"target"
)
.unwrap_or
(
driver
::
host_triple
()
.to_string
());
let
opt_level
=
{
if
(
debugging_opts
&
NO_OPT
)
!=
0
{
No
...
...
@@ -705,10 +703,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
Path
::
new
(
s
.as_slice
())
})
.collect
();
let
cfg
=
parse_cfgspecs
(
matches
.opt_strs
(
"cfg"
)
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
());
let
cfg
=
parse_cfgspecs
(
matches
.opt_strs
(
"cfg"
));
let
test
=
matches
.opt_present
(
"test"
);
let
write_dependency_info
=
(
matches
.opt_present
(
"dep-info"
),
matches
.opt_str
(
"dep-info"
)
...
...
src/librustc/driver/driver.rs
浏览文件 @
f8e06c49
...
...
@@ -595,7 +595,7 @@ fn post(&self,
}
pprust
::
NodeBlock
(
blk
)
=>
{
try!
(
pp
::
space
(
&
mut
s
.s
));
s
.synth_comment
(
(
format!
(
"block {}"
,
blk
.id
))
.to_string
(
))
s
.synth_comment
(
format!
(
"block {}"
,
blk
.id
))
}
pprust
::
NodeExpr
(
expr
)
=>
{
try!
(
pp
::
space
(
&
mut
s
.s
));
...
...
@@ -604,7 +604,7 @@ fn post(&self,
}
pprust
::
NodePat
(
pat
)
=>
{
try!
(
pp
::
space
(
&
mut
s
.s
));
s
.synth_comment
(
(
format!
(
"pat {}"
,
pat
.id
))
.to_string
(
))
s
.synth_comment
(
format!
(
"pat {}"
,
pat
.id
))
}
}
}
...
...
@@ -752,7 +752,7 @@ fn print_flowgraph<W:io::Writer>(analysis: CrateAnalysis,
let
cfg
=
cfg
::
CFG
::
new
(
ty_cx
,
&*
block
);
let
lcfg
=
LabelledCFG
{
ast_map
:
&
ty_cx
.map
,
cfg
:
&
cfg
,
name
:
format!
(
"block{}"
,
block
.id
)
.to_string
()
,
};
name
:
format!
(
"block{}"
,
block
.id
),
};
debug!
(
"cfg: {:?}"
,
cfg
);
let
r
=
dot
::
render
(
&
lcfg
,
&
mut
out
);
return
expand_err_details
(
r
);
...
...
src/librustc/lib.rs
浏览文件 @
f8e06c49
...
...
@@ -137,8 +137,6 @@ mod rustc {
}
pub
fn
main
()
{
let
args
=
std
::
os
::
args
()
.iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
();
let
args
=
std
::
os
::
args
();
std
::
os
::
set_exit_status
(
driver
::
main_args
(
args
.as_slice
()));
}
src/librustc/lib/llvm.rs
浏览文件 @
f8e06c49
...
...
@@ -1894,7 +1894,7 @@ pub fn type_to_str(&self, ty: Type) -> String {
pub
fn
types_to_str
(
&
self
,
tys
:
&
[
Type
])
->
String
{
let
strs
:
Vec
<
String
>
=
tys
.iter
()
.map
(|
t
|
self
.type_to_str
(
*
t
))
.collect
();
format!
(
"[{}]"
,
strs
.connect
(
","
)
.to_string
()
)
format!
(
"[{}]"
,
strs
.connect
(
","
))
}
pub
fn
val_to_str
(
&
self
,
val
:
ValueRef
)
->
String
{
...
...
src/librustc/metadata/creader.rs
浏览文件 @
f8e06c49
...
...
@@ -441,11 +441,11 @@ pub fn read_plugin_metadata(&mut self, krate: &ast::ViewItem) -> PluginMetadata
};
let
macros
=
decoder
::
get_exported_macros
(
library
.metadata
.as_slice
());
let
registrar
=
decoder
::
get_plugin_registrar_fn
(
library
.metadata
.as_slice
())
.map
(|
id
|
{
decoder
::
get_symbol
(
library
.metadata
.as_slice
(),
id
)
.to_string
()
decoder
::
get_symbol
(
library
.metadata
.as_slice
(),
id
)
});
let
pc
=
PluginMetadata
{
lib
:
library
.dylib
.clone
(),
macros
:
macros
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
()
,
macros
:
macros
,
registrar_symbol
:
registrar
,
};
if
should_link
&&
existing_match
(
&
self
.env
,
&
info
.crate_id
,
None
)
.is_none
()
{
...
...
src/librustc/middle/borrowck/mod.rs
浏览文件 @
f8e06c49
...
...
@@ -801,13 +801,13 @@ fn initial_value(&self) -> bool {
impl
Repr
for
Loan
{
fn
repr
(
&
self
,
tcx
:
&
ty
::
ctxt
)
->
String
{
(
format!
(
"Loan_{:?}({}, {:?}, {:?}-{:?}, {})"
,
format!
(
"Loan_{:?}({}, {:?}, {:?}-{:?}, {})"
,
self
.index
,
self
.loan_path
.repr
(
tcx
),
self
.kind
,
self
.gen_scope
,
self
.kill_scope
,
self
.restricted_paths
.repr
(
tcx
))
)
.to_string
()
self
.restricted_paths
.repr
(
tcx
))
}
}
...
...
@@ -815,23 +815,20 @@ impl Repr for LoanPath {
fn
repr
(
&
self
,
tcx
:
&
ty
::
ctxt
)
->
String
{
match
self
{
&
LpVar
(
id
)
=>
{
(
format!
(
"$({})"
,
tcx
.map
.node_to_str
(
id
)))
.to_string
(
)
format!
(
"$({})"
,
tcx
.map
.node_to_str
(
id
)
)
}
&
LpUpvar
(
ty
::
UpvarId
{
var_id
,
closure_expr_id
})
=>
{
let
s
=
tcx
.map
.node_to_str
(
var_id
);
let
s
=
format!
(
"$({} captured by id={})"
,
s
,
closure_expr_id
);
s
.to_string
()
format!
(
"$({} captured by id={})"
,
s
,
closure_expr_id
)
}
&
LpExtend
(
ref
lp
,
_
,
LpDeref
(
_
))
=>
{
(
format!
(
"{}.*"
,
lp
.repr
(
tcx
)))
.to_string
(
)
format!
(
"{}.*"
,
lp
.repr
(
tcx
)
)
}
&
LpExtend
(
ref
lp
,
_
,
LpInterior
(
ref
interior
))
=>
{
(
format!
(
"{}.{}"
,
lp
.repr
(
tcx
),
interior
.repr
(
tcx
)))
.to_string
()
format!
(
"{}.{}"
,
lp
.repr
(
tcx
),
interior
.repr
(
tcx
))
}
}
}
...
...
src/librustc/util/ppaux.rs
浏览文件 @
f8e06c49
...
...
@@ -629,7 +629,7 @@ fn repr(&self, tcx: &ctxt) -> String {
for
t
in
self
.trait_bounds
.iter
()
{
res
.push
(
t
.repr
(
tcx
));
}
res
.connect
(
"+"
)
.to_string
()
res
.connect
(
"+"
)
}
}
...
...
src/librustdoc/html/markdown.rs
浏览文件 @
f8e06c49
...
...
@@ -228,12 +228,12 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
};
// Transform the contents of the header into a hyphenated string
let
id
=
(
s
.as_slice
()
.words
()
.map
(|
s
|
{
let
id
=
s
.as_slice
()
.words
()
.map
(|
s
|
{
match
s
.to_ascii_opt
()
{
Some
(
s
)
=>
s
.to_lower
()
.into_str
(),
None
=>
s
.to_string
()
}
})
.collect
::
<
Vec
<
String
>>
()
.connect
(
"-"
)
)
.to_string
()
;
})
.collect
::
<
Vec
<
String
>>
()
.connect
(
"-"
);
// This is a terrible hack working around how hoedown gives us rendered
// html for text rather than the raw text.
...
...
@@ -252,7 +252,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
let
sec
=
match
opaque
.toc_builder
{
Some
(
ref
mut
builder
)
=>
{
builder
.push
(
level
as
u32
,
s
.
to_string
(),
id
.clone
())
builder
.push
(
level
as
u32
,
s
.
clone
(),
id
.clone
())
}
None
=>
{
""
}
};
...
...
src/librustdoc/html/render.rs
浏览文件 @
f8e06c49
...
...
@@ -370,8 +370,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
search_index
.push
(
IndexItem
{
ty
:
shortty
(
item
),
name
:
item
.name
.clone
()
.unwrap
(),
path
:
fqp
.slice_to
(
fqp
.len
()
-
1
)
.connect
(
"::"
)
.to_string
(),
path
:
fqp
.slice_to
(
fqp
.len
()
-
1
)
.connect
(
"::"
),
desc
:
shorter
(
item
.doc_value
())
.to_string
(),
parent
:
Some
(
did
),
});
...
...
src/librustdoc/lib.rs
浏览文件 @
f8e06c49
...
...
@@ -85,10 +85,7 @@ pub mod html {
type
Output
=
(
clean
::
Crate
,
Vec
<
plugins
::
PluginJson
>
);
pub
fn
main
()
{
std
::
os
::
set_exit_status
(
main_args
(
std
::
os
::
args
()
.iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
()));
std
::
os
::
set_exit_status
(
main_args
(
std
::
os
::
args
()
.as_slice
()));
}
pub
fn
opts
()
->
Vec
<
getopts
::
OptGroup
>
{
...
...
@@ -184,17 +181,10 @@ pub fn main_args(args: &[String]) -> int {
match
(
should_test
,
markdown_input
)
{
(
true
,
true
)
=>
{
return
markdown
::
test
(
input
,
libs
,
test_args
.move_iter
()
.collect
())
return
markdown
::
test
(
input
,
libs
,
test_args
)
}
(
true
,
false
)
=>
{
return
test
::
run
(
input
,
cfgs
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
(),
libs
,
test_args
)
return
test
::
run
(
input
,
cfgs
,
libs
,
test_args
)
}
(
false
,
true
)
=>
return
markdown
::
render
(
input
,
output
.unwrap_or
(
Path
::
new
(
"doc"
)),
&
matches
),
...
...
@@ -273,10 +263,7 @@ fn acquire_input(input: &str,
fn
rust_input
(
cratefile
:
&
str
,
matches
:
&
getopts
::
Matches
)
->
Output
{
let
mut
default_passes
=
!
matches
.opt_present
(
"no-defaults"
);
let
mut
passes
=
matches
.opt_strs
(
"passes"
);
let
mut
plugins
=
matches
.opt_strs
(
"plugins"
)
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
();
let
mut
plugins
=
matches
.opt_strs
(
"plugins"
);
// First, parse the crate and extract all relevant information.
let
libs
:
Vec
<
Path
>
=
matches
.opt_strs
(
"L"
)
...
...
@@ -289,7 +276,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
let
(
krate
,
analysis
)
=
std
::
task
::
try
(
proc
()
{
let
cr
=
cr
;
core
::
run_core
(
libs
.move_iter
()
.map
(|
x
|
x
.clone
())
.collect
(),
cfgs
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
()
,
cfgs
,
&
cr
)
})
.map_err
(|
boxed_any
|
format!
(
"{:?}"
,
boxed_any
))
.unwrap
();
info!
(
"finished with rustc"
);
...
...
src/librustdoc/markdown.rs
浏览文件 @
f8e06c49
...
...
@@ -93,19 +93,10 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
let
(
in_header
,
before_content
,
after_content
)
=
match
(
load_external_files
(
matches
.opt_strs
(
"markdown-in-header"
)
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
()),
load_external_files
(
matches
.opt_strs
(
"markdown-before-content"
)
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
()),
load_external_files
(
matches
.opt_strs
(
"markdown-after-content"
)
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
_
>>
()
.as_slice
()))
{
(
Some
(
a
),
Some
(
b
),
Some
(
c
))
=>
(
a
,
b
,
c
),
_
=>
return
3
...
...
src/librustdoc/passes.rs
浏览文件 @
f8e06c49
...
...
@@ -348,7 +348,7 @@ pub fn unindent(s: &str) -> String {
line
.slice_from
(
min_indent
)
.to_string
()
}
})
.collect
::
<
Vec
<
_
>>
()
.as_slice
());
unindented
.connect
(
"
\n
"
)
.to_string
()
unindented
.connect
(
"
\n
"
)
}
else
{
s
.to_string
()
}
...
...
src/libstd/path/windows.rs
浏览文件 @
f8e06c49
...
...
@@ -588,7 +588,7 @@ fn comp_requires_verbatim(s: &str) -> bool {
}
}
}
Some
(
Path
::
new
(
comps
.connect
(
"
\\
"
)
.into_string
()
))
Some
(
Path
::
new
(
comps
.connect
(
"
\\
"
)))
}
}
...
...
src/libsyntax/ast_map.rs
浏览文件 @
f8e06c49
...
...
@@ -680,61 +680,55 @@ fn node_id_to_str(map: &Map, id: NodeId) -> String {
ItemImpl
(
..
)
=>
"impl"
,
ItemMac
(
..
)
=>
"macro"
};
(
format!
(
"{} {} (id={})"
,
item_str
,
path_str
,
id
))
.to_string
(
)
format!
(
"{} {} (id={})"
,
item_str
,
path_str
,
id
)
}
Some
(
NodeForeignItem
(
item
))
=>
{
let
path_str
=
map
.path_to_str_with_ident
(
id
,
item
.ident
);
(
format!
(
"foreign item {} (id={})"
,
path_str
,
id
))
.to_string
(
)
format!
(
"foreign item {} (id={})"
,
path_str
,
id
)
}
Some
(
NodeMethod
(
m
))
=>
{
(
format!
(
"method {} in {} (id={})"
,
format!
(
"method {} in {} (id={})"
,
token
::
get_ident
(
m
.ident
),
map
.path_to_str
(
id
),
id
)
)
.to_string
()
map
.path_to_str
(
id
),
id
)
}
Some
(
NodeTraitMethod
(
ref
tm
))
=>
{
let
m
=
ast_util
::
trait_method_to_ty_method
(
&**
tm
);
(
format!
(
"method {} in {} (id={})"
,
format!
(
"method {} in {} (id={})"
,
token
::
get_ident
(
m
.ident
),
map
.path_to_str
(
id
),
id
)
)
.to_string
()
map
.path_to_str
(
id
),
id
)
}
Some
(
NodeVariant
(
ref
variant
))
=>
{
(
format!
(
"variant {} in {} (id={})"
,
format!
(
"variant {} in {} (id={})"
,
token
::
get_ident
(
variant
.node.name
),
map
.path_to_str
(
id
),
id
)
)
.to_string
()
map
.path_to_str
(
id
),
id
)
}
Some
(
NodeExpr
(
ref
expr
))
=>
{
(
format!
(
"expr {} (id={})"
,
pprust
::
expr_to_str
(
&**
expr
),
id
))
.to_string
()
format!
(
"expr {} (id={})"
,
pprust
::
expr_to_str
(
&**
expr
),
id
)
}
Some
(
NodeStmt
(
ref
stmt
))
=>
{
(
format!
(
"stmt {} (id={})"
,
pprust
::
stmt_to_str
(
&**
stmt
),
id
))
.to_string
()
format!
(
"stmt {} (id={})"
,
pprust
::
stmt_to_str
(
&**
stmt
),
id
)
}
Some
(
NodeArg
(
ref
pat
))
=>
{
(
format!
(
"arg {} (id={})"
,
pprust
::
pat_to_str
(
&**
pat
),
id
))
.to_string
()
format!
(
"arg {} (id={})"
,
pprust
::
pat_to_str
(
&**
pat
),
id
)
}
Some
(
NodeLocal
(
ref
pat
))
=>
{
(
format!
(
"local {} (id={})"
,
pprust
::
pat_to_str
(
&**
pat
),
id
))
.to_string
()
format!
(
"local {} (id={})"
,
pprust
::
pat_to_str
(
&**
pat
),
id
)
}
Some
(
NodePat
(
ref
pat
))
=>
{
(
format!
(
"pat {} (id={})"
,
pprust
::
pat_to_str
(
&**
pat
),
id
))
.to_string
(
)
format!
(
"pat {} (id={})"
,
pprust
::
pat_to_str
(
&**
pat
),
id
)
}
Some
(
NodeBlock
(
ref
block
))
=>
{
(
format!
(
"block {} (id={})"
,
pprust
::
block_to_str
(
&**
block
),
id
))
.to_string
()
format!
(
"block {} (id={})"
,
pprust
::
block_to_str
(
&**
block
),
id
)
}
Some
(
NodeStructCtor
(
_
))
=>
{
(
format!
(
"struct_ctor {} (id={})"
,
map
.path_to_str
(
id
),
id
))
.to_string
()
format!
(
"struct_ctor {} (id={})"
,
map
.path_to_str
(
id
),
id
)
}
Some
(
NodeLifetime
(
ref
l
))
=>
{
(
format!
(
"lifetime {} (id={})"
,
pprust
::
lifetime_to_str
(
&**
l
),
id
)
)
.to_string
()
format!
(
"lifetime {} (id={})"
,
pprust
::
lifetime_to_str
(
&**
l
),
id
)
}
None
=>
{
(
format!
(
"unknown node (id={})"
,
id
))
.to_string
(
)
format!
(
"unknown node (id={})"
,
id
)
}
}
}
src/libsyntax/ast_util.rs
浏览文件 @
f8e06c49
...
...
@@ -30,7 +30,7 @@ pub fn path_name_i(idents: &[Ident]) -> String {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
idents
.iter
()
.map
(|
i
|
{
token
::
get_ident
(
*
i
)
.get
()
.to_string
()
})
.collect
::
<
Vec
<
String
>>
()
.connect
(
"::"
)
.to_string
()
})
.collect
::
<
Vec
<
String
>>
()
.connect
(
"::"
)
}
// totally scary function: ignores all but the last element, should have
...
...
@@ -123,7 +123,7 @@ pub fn int_ty_to_str(t: IntTy, val: Option<i64>) -> String {
// cast to a u64 so we can correctly print INT64_MIN. All integral types
// are parsed as u64, so we wouldn't want to print an extra negative
// sign.
Some
(
n
)
=>
format!
(
"{}{}"
,
n
as
u64
,
s
)
.to_string
()
,
Some
(
n
)
=>
format!
(
"{}{}"
,
n
as
u64
,
s
),
None
=>
s
.to_string
()
}
}
...
...
@@ -150,7 +150,7 @@ pub fn uint_ty_to_str(t: UintTy, val: Option<u64>) -> String {
};
match
val
{
Some
(
n
)
=>
format!
(
"{}{}"
,
n
,
s
)
.to_string
()
,
Some
(
n
)
=>
format!
(
"{}{}"
,
n
,
s
),
None
=>
s
.to_string
()
}
}
...
...
src/libsyntax/crateid.rs
浏览文件 @
f8e06c49
...
...
@@ -112,7 +112,7 @@ pub fn version_or_default<'a>(&'a self) -> &'a str {
}
pub
fn
short_name_with_version
(
&
self
)
->
String
{
(
format!
(
"{}-{}"
,
self
.name
,
self
.version_or_default
()))
.to_string
(
)
format!
(
"{}-{}"
,
self
.name
,
self
.version_or_default
()
)
}
pub
fn
matches
(
&
self
,
other
:
&
CrateId
)
->
bool
{
...
...
src/libsyntax/ext/deriving/generic/mod.rs
浏览文件 @
f8e06c49
...
...
@@ -1015,7 +1015,7 @@ fn set_expn_info(&self,
to_set
.expn_info
=
Some
(
box
(
GC
)
codemap
::
ExpnInfo
{
call_site
:
to_set
,
callee
:
codemap
::
NameAndSpan
{
name
:
format!
(
"deriving({})"
,
trait_name
)
.to_string
()
,
name
:
format!
(
"deriving({})"
,
trait_name
),
format
:
codemap
::
MacroAttribute
,
span
:
Some
(
self
.span
)
}
...
...
src/libsyntax/parse/lexer/comments.rs
浏览文件 @
f8e06c49
...
...
@@ -135,7 +135,7 @@ fn horizontal_trim(lines: Vec<String> ) -> Vec<String> {
let
lines
=
vertical_trim
(
lines
);
let
lines
=
horizontal_trim
(
lines
);
return
lines
.connect
(
"
\n
"
)
.to_string
()
;
return
lines
.connect
(
"
\n
"
);
}
fail
!
(
"not a doc-comment: {}"
,
comment
);
...
...
src/libsyntax/print/pp.rs
浏览文件 @
f8e06c49
...
...
@@ -111,7 +111,7 @@ pub fn is_hardbreak_tok(&self) -> bool {
pub
fn
tok_str
(
t
:
Token
)
->
String
{
match
t
{
String
(
s
,
len
)
=>
return
format!
(
"STR({},{})"
,
s
,
len
)
.to_string
()
,
String
(
s
,
len
)
=>
return
format!
(
"STR({},{})"
,
s
,
len
),
Break
(
_
)
=>
return
"BREAK"
.to_string
(),
Begin
(
_
)
=>
return
"BEGIN"
.to_string
(),
End
=>
return
"END"
.to_string
(),
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
f8e06c49
...
...
@@ -243,7 +243,7 @@ pub fn arg_to_str(arg: &ast::Arg) -> String {
pub
fn
visibility_qualified
(
vis
:
ast
::
Visibility
,
s
:
&
str
)
->
String
{
match
vis
{
ast
::
Public
=>
format!
(
"pub {}"
,
s
)
.to_string
()
,
ast
::
Public
=>
format!
(
"pub {}"
,
s
),
ast
::
Inherited
=>
s
.to_string
()
}
}
...
...
src/libtest/lib.rs
浏览文件 @
f8e06c49
...
...
@@ -403,7 +403,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
let
save_metrics
=
save_metrics
.map
(|
s
|
Path
::
new
(
s
));
let
test_shard
=
matches
.opt_str
(
"test-shard"
);
let
test_shard
=
opt_shard
(
test_shard
.map
(|
x
|
x
.to_string
())
);
let
test_shard
=
opt_shard
(
test_shard
);
let
mut
nocapture
=
matches
.opt_present
(
"nocapture"
);
if
!
nocapture
{
...
...
@@ -756,7 +756,7 @@ pub fn fmt_metrics(mm: &MetricMap) -> String {
.map
(|(
k
,
v
)|
format!
(
"{}: {} (+/- {})"
,
*
k
,
v
.value
as
f64
,
v
.noise
as
f64
))
.collect
();
v
.connect
(
", "
)
.to_string
()
v
.connect
(
", "
)
}
pub
fn
fmt_bench_samples
(
bs
:
&
BenchSamples
)
->
String
{
...
...
src/test/bench/core-std.rs
浏览文件 @
f8e06c49
...
...
@@ -24,7 +24,7 @@
use
std
::
io
::
File
;
fn
main
()
{
let
argv
=
os
::
args
()
.move_iter
()
.map
(|
x
|
x
.to_string
())
.collect
::
<
Vec
<
String
>>
()
;
let
argv
=
os
::
args
();
let
_
tests
=
argv
.slice
(
1
,
argv
.len
());
macro_rules!
bench
(
...
...
src/test/run-pass/issue-5666.rs
浏览文件 @
f8e06c49
...
...
@@ -19,7 +19,7 @@ trait Barks {
impl
Barks
for
Dog
{
fn
bark
(
&
self
)
->
String
{
return
format!
(
"woof! (I'm {})"
,
self
.name
)
.to_string
()
;
return
format!
(
"woof! (I'm {})"
,
self
.name
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录