Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
382d24e7
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,发现更多精彩内容 >>
提交
382d24e7
编写于
12月 04, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: start moving util::ppaux to ty::print.
上级
228d6f45
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
93 addition
and
83 deletion
+93
-83
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+1
-0
src/librustc/ty/print.rs
src/librustc/ty/print.rs
+91
-0
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+1
-83
未找到文件。
src/librustc/ty/mod.rs
浏览文件 @
382d24e7
...
...
@@ -99,6 +99,7 @@
pub
mod
layout
;
pub
mod
_
match
;
pub
mod
outlives
;
pub
mod
print
;
pub
mod
query
;
pub
mod
relate
;
pub
mod
steal
;
...
...
src/librustc/ty/print.rs
0 → 100644
浏览文件 @
382d24e7
use
crate
::
ty
::{
self
,
TypeFoldable
};
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
syntax
::
symbol
::
InternedString
;
use
std
::
fmt
;
// FIXME(eddyb) this module uses `pub(crate)` for things used only
// from `ppaux` - when that is removed, they can be re-privatized.
struct
LateBoundRegionNameCollector
(
FxHashSet
<
InternedString
>
);
impl
<
'tcx
>
ty
::
fold
::
TypeVisitor
<
'tcx
>
for
LateBoundRegionNameCollector
{
fn
visit_region
(
&
mut
self
,
r
:
ty
::
Region
<
'tcx
>
)
->
bool
{
match
*
r
{
ty
::
ReLateBound
(
_
,
ty
::
BrNamed
(
_
,
name
))
=>
{
self
.0
.insert
(
name
);
},
_
=>
{},
}
r
.super_visit_with
(
self
)
}
}
#[derive(Debug)]
pub
struct
PrintContext
{
pub
(
crate
)
is_debug
:
bool
,
pub
(
crate
)
is_verbose
:
bool
,
pub
(
crate
)
identify_regions
:
bool
,
pub
(
crate
)
used_region_names
:
Option
<
FxHashSet
<
InternedString
>>
,
pub
(
crate
)
region_index
:
usize
,
pub
(
crate
)
binder_depth
:
usize
,
}
impl
PrintContext
{
pub
(
crate
)
fn
new
()
->
Self
{
ty
::
tls
::
with_opt
(|
tcx
|
{
let
(
is_verbose
,
identify_regions
)
=
tcx
.map
(
|
tcx
|
(
tcx
.sess
.verbose
(),
tcx
.sess.opts.debugging_opts.identify_regions
)
)
.unwrap_or
((
false
,
false
));
PrintContext
{
is_debug
:
false
,
is_verbose
:
is_verbose
,
identify_regions
:
identify_regions
,
used_region_names
:
None
,
region_index
:
0
,
binder_depth
:
0
,
}
})
}
pub
(
crate
)
fn
prepare_late_bound_region_info
<
'tcx
,
T
>
(
&
mut
self
,
value
:
&
ty
::
Binder
<
T
>
)
where
T
:
TypeFoldable
<
'tcx
>
{
let
mut
collector
=
LateBoundRegionNameCollector
(
Default
::
default
());
value
.visit_with
(
&
mut
collector
);
self
.used_region_names
=
Some
(
collector
.0
);
self
.region_index
=
0
;
}
}
pub
trait
Print
{
fn
print
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintContext
)
->
fmt
::
Result
;
fn
print_to_string
(
&
self
,
cx
:
&
mut
PrintContext
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print
(
&
mut
result
,
cx
);
result
}
fn
print_display
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintContext
)
->
fmt
::
Result
{
let
old_debug
=
cx
.is_debug
;
cx
.is_debug
=
false
;
let
result
=
self
.print
(
f
,
cx
);
cx
.is_debug
=
old_debug
;
result
}
fn
print_display_to_string
(
&
self
,
cx
:
&
mut
PrintContext
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print_display
(
&
mut
result
,
cx
);
result
}
fn
print_debug
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintContext
)
->
fmt
::
Result
{
let
old_debug
=
cx
.is_debug
;
cx
.is_debug
=
true
;
let
result
=
self
.print
(
f
,
cx
);
cx
.is_debug
=
old_debug
;
result
}
fn
print_debug_to_string
(
&
self
,
cx
:
&
mut
PrintContext
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print_debug
(
&
mut
result
,
cx
);
result
}
}
src/librustc/util/ppaux.rs
浏览文件 @
382d24e7
...
...
@@ -9,8 +9,8 @@
use
crate
::
ty
::{
Closure
,
Generator
,
GeneratorWitness
,
Foreign
,
Projection
,
Opaque
};
use
crate
::
ty
::{
Placeholder
,
UnnormalizedProjection
,
Dynamic
,
Int
,
Uint
,
Infer
};
use
crate
::
ty
::{
self
,
Ty
,
TyCtxt
,
TypeFoldable
,
GenericParamCount
,
GenericParamDefKind
,
ParamConst
};
use
crate
::
ty
::
print
::{
PrintContext
,
Print
};
use
crate
::
mir
::
interpret
::
ConstValue
;
use
crate
::
util
::
nodemap
::
FxHashSet
;
use
std
::
cell
::
Cell
;
use
std
::
fmt
;
...
...
@@ -275,88 +275,6 @@ fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintContext) -> fmt::Resu
};
}
struct
LateBoundRegionNameCollector
(
FxHashSet
<
InternedString
>
);
impl
<
'tcx
>
ty
::
fold
::
TypeVisitor
<
'tcx
>
for
LateBoundRegionNameCollector
{
fn
visit_region
(
&
mut
self
,
r
:
ty
::
Region
<
'tcx
>
)
->
bool
{
match
*
r
{
ty
::
ReLateBound
(
_
,
ty
::
BrNamed
(
_
,
name
))
=>
{
self
.0
.insert
(
name
);
},
_
=>
{},
}
r
.super_visit_with
(
self
)
}
}
#[derive(Debug)]
pub
struct
PrintContext
{
is_debug
:
bool
,
is_verbose
:
bool
,
identify_regions
:
bool
,
used_region_names
:
Option
<
FxHashSet
<
InternedString
>>
,
region_index
:
usize
,
binder_depth
:
usize
,
}
impl
PrintContext
{
fn
new
()
->
Self
{
ty
::
tls
::
with_opt
(|
tcx
|
{
let
(
is_verbose
,
identify_regions
)
=
tcx
.map
(
|
tcx
|
(
tcx
.sess
.verbose
(),
tcx
.sess.opts.debugging_opts.identify_regions
)
)
.unwrap_or
((
false
,
false
));
PrintContext
{
is_debug
:
false
,
is_verbose
:
is_verbose
,
identify_regions
:
identify_regions
,
used_region_names
:
None
,
region_index
:
0
,
binder_depth
:
0
,
}
})
}
fn
prepare_late_bound_region_info
<
'tcx
,
T
>
(
&
mut
self
,
value
:
&
ty
::
Binder
<
T
>
)
where
T
:
TypeFoldable
<
'tcx
>
{
let
mut
collector
=
LateBoundRegionNameCollector
(
Default
::
default
());
value
.visit_with
(
&
mut
collector
);
self
.used_region_names
=
Some
(
collector
.0
);
self
.region_index
=
0
;
}
}
pub
trait
Print
{
fn
print
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintContext
)
->
fmt
::
Result
;
fn
print_to_string
(
&
self
,
cx
:
&
mut
PrintContext
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print
(
&
mut
result
,
cx
);
result
}
fn
print_display
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintContext
)
->
fmt
::
Result
{
let
old_debug
=
cx
.is_debug
;
cx
.is_debug
=
false
;
let
result
=
self
.print
(
f
,
cx
);
cx
.is_debug
=
old_debug
;
result
}
fn
print_display_to_string
(
&
self
,
cx
:
&
mut
PrintContext
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print_display
(
&
mut
result
,
cx
);
result
}
fn
print_debug
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintContext
)
->
fmt
::
Result
{
let
old_debug
=
cx
.is_debug
;
cx
.is_debug
=
true
;
let
result
=
self
.print
(
f
,
cx
);
cx
.is_debug
=
old_debug
;
result
}
fn
print_debug_to_string
(
&
self
,
cx
:
&
mut
PrintContext
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print_debug
(
&
mut
result
,
cx
);
result
}
}
impl
PrintContext
{
fn
fn_sig
<
F
:
fmt
::
Write
>
(
&
mut
self
,
f
:
&
mut
F
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录