Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5ea959dc
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,发现更多精彩内容 >>
提交
5ea959dc
编写于
3月 16, 2019
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert symbols to strings for pretty printing
上级
438f6b04
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
17 deletion
+14
-17
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+3
-3
src/libsyntax/print/pp.rs
src/libsyntax/print/pp.rs
+4
-7
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+7
-7
未找到文件。
src/librustc/hir/print.rs
浏览文件 @
5ea959dc
...
...
@@ -622,7 +622,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
}
hir
::
ItemKind
::
GlobalAsm
(
ref
ga
)
=>
{
self
.head
(
visibility_qualified
(
&
item
.vis
,
"global asm"
))
?
;
self
.s
.word
(
ga
.asm
.as_str
()
.
get
())
?
;
self
.s
.word
(
ga
.asm
.as_str
()
.
to_string
())
?
;
self
.end
()
?
}
hir
::
ItemKind
::
Ty
(
ref
ty
,
ref
generics
)
=>
{
...
...
@@ -1591,7 +1591,7 @@ pub fn print_ident(&mut self, ident: ast::Ident) -> io::Result<()> {
if
ident
.is_raw_guess
()
{
self
.s
.word
(
format!
(
"r#{}"
,
ident
.name
))
?
;
}
else
{
self
.s
.word
(
ident
.as_str
()
.
get
())
?
;
self
.s
.word
(
ident
.as_str
()
.
to_string
())
?
;
}
self
.ann
.post
(
self
,
AnnNode
::
Name
(
&
ident
.name
))
}
...
...
@@ -1998,7 +1998,7 @@ pub fn print_fn(&mut self,
self
.commasep
(
Inconsistent
,
&
decl
.inputs
,
|
s
,
ty
|
{
s
.ibox
(
indent_unit
)
?
;
if
let
Some
(
arg_name
)
=
arg_names
.get
(
i
)
{
s
.s
.word
(
arg_name
.as_str
()
.
get
())
?
;
s
.s
.word
(
arg_name
.as_str
()
.
to_string
())
?
;
s
.s
.word
(
":"
)
?
;
s
.s
.space
()
?
;
}
else
if
let
Some
(
body_id
)
=
body_id
{
...
...
src/libsyntax/print/pp.rs
浏览文件 @
5ea959dc
...
...
@@ -369,7 +369,7 @@ fn pretty_print_break(&mut self, b: BreakToken) -> io::Result<()> {
Ok
(())
}
fn
pretty_print_string
<
's
>
(
&
mut
self
,
s
:
Cow
<
's
,
str
>
,
len
:
isize
)
->
io
::
Result
<
()
>
{
fn
pretty_print_string
(
&
mut
self
,
s
:
Cow
<
'static
,
str
>
,
len
:
isize
)
->
io
::
Result
<
()
>
{
if
self
.scan_stack
.is_empty
()
{
debug!
(
"pp String('{}')/print Vec<{},{}>"
,
s
,
self
.left
,
self
.right
);
...
...
@@ -378,10 +378,7 @@ fn pretty_print_string<'s>(&mut self, s: Cow<'s, str>, len: isize) -> io::Result
debug!
(
"pp String('{}')/buffer Vec<{},{}>"
,
s
,
self
.left
,
self
.right
);
self
.advance_right
();
self
.buf
[
self
.right
]
=
BufEntry
{
token
:
Token
::
String
(
s
.into_owned
()
.into
(),
len
),
size
:
len
};
self
.buf
[
self
.right
]
=
BufEntry
{
token
:
Token
::
String
(
s
,
len
),
size
:
len
};
self
.right_total
+=
len
;
self
.check_stream
()
}
...
...
@@ -579,7 +576,7 @@ pub fn print_break(&mut self, b: BreakToken, l: isize) -> io::Result<()> {
}
}
pub
fn
print_string
(
&
mut
self
,
s
:
Cow
<
'
_
,
str
>
,
len
:
isize
)
->
io
::
Result
<
()
>
{
pub
fn
print_string
(
&
mut
self
,
s
:
Cow
<
'
static
,
str
>
,
len
:
isize
)
->
io
::
Result
<
()
>
{
debug!
(
"print String({})"
,
s
);
// assert!(len <= space);
self
.space
-=
len
;
...
...
@@ -644,7 +641,7 @@ pub fn eof(&mut self) -> io::Result<()> {
self
.pretty_print_eof
()
}
pub
fn
word
<
's
,
S
:
Into
<
Cow
<
's
,
str
>>>
(
&
mut
self
,
wrd
:
S
)
->
io
::
Result
<
()
>
{
pub
fn
word
<
S
:
Into
<
Cow
<
'static
,
str
>>>
(
&
mut
self
,
wrd
:
S
)
->
io
::
Result
<
()
>
{
let
s
=
wrd
.into
();
let
len
=
s
.len
()
as
isize
;
self
.pretty_print_string
(
s
,
len
)
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
5ea959dc
...
...
@@ -645,7 +645,7 @@ fn print_literal(&mut self, lit: &ast::Lit) -> io::Result<()> {
ast
::
LitKind
::
Float
(
ref
f
,
t
)
=>
{
self
.writer
()
.word
(
format!
(
"{}{}"
,
&
f
,
t
.ty_to_string
()))
}
ast
::
LitKind
::
FloatUnsuffixed
(
ref
f
)
=>
self
.writer
()
.word
(
f
.as_str
()
.
get
()),
ast
::
LitKind
::
FloatUnsuffixed
(
ref
f
)
=>
self
.writer
()
.word
(
f
.as_str
()
.
to_string
()),
ast
::
LitKind
::
Bool
(
val
)
=>
{
if
val
{
self
.writer
()
.word
(
"true"
)
}
else
{
self
.writer
()
.word
(
"false"
)
}
}
...
...
@@ -731,7 +731,7 @@ fn print_attribute_path(&mut self, path: &ast::Path) -> io::Result<()> {
if
segment
.ident.name
==
keywords
::
DollarCrate
.name
()
{
self
.print_dollar_crate
(
segment
.ident
)
?
;
}
else
{
self
.writer
()
.word
(
segment
.ident
.as_str
()
.
get
())
?
;
self
.writer
()
.word
(
segment
.ident
.as_str
()
.
to_string
())
?
;
}
}
}
...
...
@@ -749,7 +749,7 @@ fn print_attribute_inline(&mut self, attr: &ast::Attribute,
}
self
.maybe_print_comment
(
attr
.span
.lo
())
?
;
if
attr
.is_sugared_doc
{
self
.writer
()
.word
(
attr
.value_str
()
.unwrap
()
.as_str
()
.
get
())
?
;
self
.writer
()
.word
(
attr
.value_str
()
.unwrap
()
.as_str
()
.
to_string
())
?
;
self
.writer
()
.hardbreak
()
}
else
{
match
attr
.style
{
...
...
@@ -858,7 +858,7 @@ fn print_dollar_crate(&mut self, ident: ast::Ident) -> io::Result<()> {
if
!
ast
::
Ident
::
with_empty_ctxt
(
name
)
.is_path_segment_keyword
()
{
self
.writer
()
.word
(
"::"
)
?
;
}
self
.writer
()
.word
(
name
.as_str
()
.
get
())
self
.writer
()
.word
(
name
.as_str
()
.
to_string
())
}
}
...
...
@@ -1300,7 +1300,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
}
ast
::
ItemKind
::
GlobalAsm
(
ref
ga
)
=>
{
self
.head
(
visibility_qualified
(
&
item
.vis
,
"global_asm!"
))
?
;
self
.s
.word
(
ga
.asm
.as_str
()
.
get
())
?
;
self
.s
.word
(
ga
.asm
.as_str
()
.
to_string
())
?
;
self
.end
()
?
;
}
ast
::
ItemKind
::
Ty
(
ref
ty
,
ref
generics
)
=>
{
...
...
@@ -2437,7 +2437,7 @@ pub fn print_ident(&mut self, ident: ast::Ident) -> io::Result<()> {
if
ident
.is_raw_guess
()
{
self
.s
.word
(
format!
(
"r#{}"
,
ident
))
?
;
}
else
{
self
.s
.word
(
ident
.as_str
()
.
get
())
?
;
self
.s
.word
(
ident
.as_str
()
.
to_string
())
?
;
}
self
.ann
.post
(
self
,
AnnNode
::
Ident
(
&
ident
))
}
...
...
@@ -2447,7 +2447,7 @@ pub fn print_usize(&mut self, i: usize) -> io::Result<()> {
}
pub
fn
print_name
(
&
mut
self
,
name
:
ast
::
Name
)
->
io
::
Result
<
()
>
{
self
.s
.word
(
name
.as_str
()
.
get
())
?
;
self
.s
.word
(
name
.as_str
()
.
to_string
())
?
;
self
.ann
.post
(
self
,
AnnNode
::
Name
(
&
name
))
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录