Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7a95e716
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,发现更多精彩内容 >>
提交
7a95e716
编写于
12月 19, 2017
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix whitespacing issues in pretty-printing of bounds
上级
b39c4bc1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
42 deletion
+45
-42
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+18
-16
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+18
-17
src/test/parse-fail/trait-object-bad-parens.rs
src/test/parse-fail/trait-object-bad-parens.rs
+3
-3
src/test/parse-fail/trait-object-polytrait-priority.rs
src/test/parse-fail/trait-object-polytrait-priority.rs
+2
-2
src/test/pretty/closure-reform-pretty.rs
src/test/pretty/closure-reform-pretty.rs
+1
-1
src/test/pretty/path-type-bounds.rs
src/test/pretty/path-type-bounds.rs
+3
-3
未找到文件。
src/librustc/hir/print.rs
浏览文件 @
7a95e716
...
...
@@ -408,15 +408,16 @@ pub fn print_type(&mut self, ty: &hir::Ty) -> io::Result<()> {
hir
::
TyTraitObject
(
ref
bounds
,
ref
lifetime
)
=>
{
let
mut
first
=
true
;
for
bound
in
bounds
{
self
.nbsp
()
?
;
if
first
{
first
=
false
;
}
else
{
self
.nbsp
()
?
;
self
.word_space
(
"+"
)
?
;
}
self
.print_poly_trait_ref
(
bound
)
?
;
}
if
!
lifetime
.is_elided
()
{
self
.nbsp
()
?
;
self
.word_space
(
"+"
)
?
;
self
.print_lifetime
(
lifetime
)
?
;
}
...
...
@@ -764,7 +765,8 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
real_bounds
.push
(
b
.clone
());
}
}
self
.print_bounds
(
" = "
,
&
real_bounds
[
..
])
?
;
self
.nbsp
()
?
;
self
.print_bounds
(
"="
,
&
real_bounds
[
..
])
?
;
self
.print_where_clause
(
&
generics
.where_clause
)
?
;
self
.s
.word
(
";"
)
?
;
}
...
...
@@ -788,6 +790,7 @@ fn print_formal_lifetime_list(&mut self, lifetimes: &[hir::LifetimeDef]) -> io::
comma
=
true
;
}
self
.s
.word
(
">"
)
?
;
self
.nbsp
()
?
;
}
Ok
(())
}
...
...
@@ -2016,30 +2019,29 @@ pub fn print_bounds(&mut self, prefix: &str, bounds: &[hir::TyParamBound]) -> io
self
.s
.word
(
prefix
)
?
;
let
mut
first
=
true
;
for
bound
in
bounds
{
self
.nbsp
()
?
;
if
!
(
first
&&
prefix
.is_empty
())
{
self
.nbsp
()
?
;
}
if
first
{
first
=
false
;
}
else
{
self
.word_space
(
"+"
)
?
;
}
match
*
bound
{
TraitTyParamBound
(
ref
tref
,
TraitBoundModifier
::
None
)
=>
{
self
.print_poly_trait_ref
(
tref
)
}
TraitTyParamBound
(
ref
tref
,
TraitBoundModifier
::
Maybe
)
=>
{
self
.s
.word
(
"?"
)
?
;
self
.print_poly_trait_ref
(
tref
)
match
bound
{
TraitTyParamBound
(
tref
,
modifier
)
=>
{
if
modifier
==
&
TraitBoundModifier
::
Maybe
{
self
.s
.word
(
"?"
)
?
;
}
self
.print_poly_trait_ref
(
tref
)
?
;
}
RegionTyParamBound
(
ref
lt
)
=>
{
self
.print_lifetime
(
lt
)
RegionTyParamBound
(
lt
)
=>
{
self
.print_lifetime
(
lt
)
?
;
}
}
?
}
}
Ok
(())
}
else
{
Ok
(())
}
Ok
(())
}
pub
fn
print_lifetime
(
&
mut
self
,
lifetime
:
&
hir
::
Lifetime
)
->
io
::
Result
<
()
>
{
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
7a95e716
...
...
@@ -1066,11 +1066,11 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
self
.print_qpath
(
path
,
qself
,
false
)
?
}
ast
::
TyKind
::
TraitObject
(
ref
bounds
,
syntax
)
=>
{
let
prefix
=
if
syntax
==
ast
::
TraitObjectSyntax
::
Dyn
{
"dyn
"
}
else
{
""
};
let
prefix
=
if
syntax
==
ast
::
TraitObjectSyntax
::
Dyn
{
"dyn"
}
else
{
""
};
self
.print_bounds
(
prefix
,
&
bounds
[
..
])
?
;
}
ast
::
TyKind
::
ImplTrait
(
ref
bounds
)
=>
{
self
.print_bounds
(
"impl
"
,
&
bounds
[
..
])
?
;
self
.print_bounds
(
"impl"
,
&
bounds
[
..
])
?
;
}
ast
::
TyKind
::
Array
(
ref
ty
,
ref
v
)
=>
{
self
.s
.word
(
"["
)
?
;
...
...
@@ -1398,7 +1398,8 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
real_bounds
.push
(
b
.clone
());
}
}
self
.print_bounds
(
" = "
,
&
real_bounds
[
..
])
?
;
self
.nbsp
()
?
;
self
.print_bounds
(
"="
,
&
real_bounds
[
..
])
?
;
self
.print_where_clause
(
&
generics
.where_clause
)
?
;
self
.s
.word
(
";"
)
?
;
}
...
...
@@ -1444,6 +1445,7 @@ fn print_formal_lifetime_list(&mut self, lifetimes: &[ast::LifetimeDef]) -> io::
comma
=
true
;
}
self
.s
.word
(
">"
)
?
;
self
.nbsp
()
?
;
}
Ok
(())
}
...
...
@@ -2818,30 +2820,29 @@ pub fn print_bounds(&mut self,
self
.s
.word
(
prefix
)
?
;
let
mut
first
=
true
;
for
bound
in
bounds
{
self
.nbsp
()
?
;
if
!
(
first
&&
prefix
.is_empty
())
{
self
.nbsp
()
?
;
}
if
first
{
first
=
false
;
}
else
{
self
.word_space
(
"+"
)
?
;
}
(
match
*
bound
{
TraitTyParamBound
(
ref
tref
,
TraitBoundModifier
::
None
)
=>
{
self
.print_poly_trait_ref
(
tref
)
}
TraitTyParamBound
(
ref
tref
,
TraitBoundModifier
::
Maybe
)
=>
{
self
.s
.word
(
"?"
)
?
;
self
.print_poly_trait_ref
(
tref
)
match
bound
{
TraitTyParamBound
(
tref
,
modifier
)
=>
{
if
modifier
==
&
TraitBoundModifier
::
Maybe
{
self
.s
.word
(
"?"
)
?
;
}
self
.print_poly_trait_ref
(
tref
)
?
;
}
RegionTyParamBound
(
ref
lt
)
=>
{
self
.print_lifetime
(
lt
)
RegionTyParamBound
(
lt
)
=>
{
self
.print_lifetime
(
lt
)
?
;
}
}
)
?
}
}
Ok
(())
}
else
{
Ok
(())
}
Ok
(())
}
pub
fn
print_lifetime
(
&
mut
self
,
...
...
src/test/parse-fail/trait-object-bad-parens.rs
浏览文件 @
7a95e716
...
...
@@ -14,9 +14,9 @@ fn main() {
let
_
:
Box
<
((
Copy
))
+
Copy
>
;
//~^ ERROR expected a path on the left-hand side of `+`, not `((Copy))`
let
_
:
Box
<
(
Copy
+
Copy
)
+
Copy
>
;
//~^ ERROR expected a path on the left-hand side of `+`, not `(
Copy + Copy)`
//~^ ERROR expected a path on the left-hand side of `+`, not `(Copy + Copy)`
let
_
:
Box
<
(
Copy
+
)
+
Copy
>
;
//~^ ERROR expected a path on the left-hand side of `+`, not `(
Copy)`
//~^ ERROR expected a path on the left-hand side of `+`, not `(Copy)`
let
_
:
Box
<
(
dyn
Copy
)
+
Copy
>
;
//~^ ERROR expected a path on the left-hand side of `+`, not `(dyn
Copy)`
//~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)`
}
src/test/parse-fail/trait-object-polytrait-priority.rs
浏览文件 @
7a95e716
...
...
@@ -12,7 +12,7 @@ trait Trait<'a> {}
fn
main
()
{
let
_
:
&
for
<
'a
>
Trait
<
'a
>
+
'static
;
//~^ ERROR expected a path on the left-hand side of `+`, not `&
for<'a>
Trait<'a>`
//~^ ERROR expected a path on the left-hand side of `+`, not `&
for<'a>
Trait<'a>`
//~| HELP try adding parentheses
//~| SUGGESTION &(
for<'a>
Trait<'a> + 'static)
//~| SUGGESTION &(
for<'a>
Trait<'a> + 'static)
}
src/test/pretty/closure-reform-pretty.rs
浏览文件 @
7a95e716
...
...
@@ -17,7 +17,7 @@ fn call_it(f: Box<FnMut(String) -> String>) { }
fn
call_this
<
F
>
(
f
:
F
)
where
F
:
Fn
(
&
str
)
+
Send
{
}
fn
call_that
<
F
>
(
f
:
F
)
where
F
:
for
<
'a
>
Fn
(
&
'a
isize
,
&
'a
isize
)
->
isize
{
}
fn
call_that
<
F
>
(
f
:
F
)
where
F
:
for
<
'a
>
Fn
(
&
'a
isize
,
&
'a
isize
)
->
isize
{
}
fn
call_extern
(
f
:
fn
()
->
isize
)
{
}
...
...
src/test/pretty/path-type-bounds.rs
浏览文件 @
7a95e716
...
...
@@ -16,10 +16,10 @@ fn dummy(&self) { }
}
impl
Tr
for
isize
{
}
fn
foo
<
'a
>
(
x
:
Box
<
Tr
+
Sync
+
'a
>
)
->
Box
<
Tr
+
Sync
+
'a
>
{
x
}
fn
foo
<
'a
>
(
x
:
Box
<
Tr
+
Sync
+
'a
>
)
->
Box
<
Tr
+
Sync
+
'a
>
{
x
}
fn
main
()
{
let
x
:
Box
<
Tr
+
Sync
>
;
let
x
:
Box
<
Tr
+
Sync
>
;
Box
::
new
(
1
isize
)
as
Box
<
Tr
+
Sync
>
;
Box
::
new
(
1
isize
)
as
Box
<
Tr
+
Sync
>
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录