Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c30ce357
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,发现更多精彩内容 >>
提交
c30ce357
编写于
10月 05, 2018
作者:
L
ljedrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove graphviz::IntoCow
上级
b8bea5a0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
81 deletion
+40
-81
src/libgraphviz/lib.rs
src/libgraphviz/lib.rs
+18
-55
src/librustc/cfg/graphviz.rs
src/librustc/cfg/graphviz.rs
+7
-8
src/librustc_borrowck/graphviz.rs
src/librustc_borrowck/graphviz.rs
+2
-3
src/librustc_incremental/assert_dep_graph.rs
src/librustc_incremental/assert_dep_graph.rs
+2
-3
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
+9
-9
src/librustc_mir/dataflow/graphviz.rs
src/librustc_mir/dataflow/graphviz.rs
+2
-3
未找到文件。
src/libgraphviz/lib.rs
浏览文件 @
c30ce357
...
...
@@ -49,7 +49,6 @@
//! ```rust
//! #![feature(rustc_private)]
//!
//! use graphviz::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
//!
...
...
@@ -84,12 +83,12 @@
//! }
//! nodes.sort();
//! nodes.dedup();
//! nodes.into
_cow
()
//! nodes.into()
//! }
//!
//! fn edges(&'a self) -> dot::Edges<'a,Ed> {
//! let &Edges(ref edges) = self;
//! (&edges[..]).into
_cow
()
//! (&edges[..]).into()
//! }
//!
//! fn source(&self, e: &Ed) -> Nd { let &(s,_) = e; s }
...
...
@@ -144,9 +143,8 @@
//! Since both the set of nodes and the set of edges are always
//! constructed from scratch via iterators, we use the `collect()` method
//! from the `Iterator` trait to collect the nodes and edges into freshly
//! constructed growable `Vec` values (rather use the `into_cow`
//! from the `IntoCow` trait as was used in the first example
//! above).
//! constructed growable `Vec` values (rather than using `Cow` as in the
//! first example above).
//!
//! The output from this example renders four nodes that make up the
//! Hasse-diagram for the subsets of the set `{x, y}`. Each edge is
...
...
@@ -293,7 +291,7 @@
use
self
::
LabelText
::
*
;
use
std
::
borrow
::
{
Cow
,
ToOwned
}
;
use
std
::
borrow
::
Cow
;
use
std
::
io
::
prelude
::
*
;
use
std
::
io
;
...
...
@@ -411,8 +409,8 @@ impl<'a> Id<'a> {
///
/// Passing an invalid string (containing spaces, brackets,
/// quotes, ...) will return an empty `Err` value.
pub
fn
new
<
Name
:
Into
Cow
<
'a
,
str
>>
(
name
:
Name
)
->
Result
<
Id
<
'a
>
,
()
>
{
let
name
=
name
.into
_cow
();
pub
fn
new
<
Name
:
Into
<
Cow
<
'a
,
str
>
>>
(
name
:
Name
)
->
Result
<
Id
<
'a
>
,
()
>
{
let
name
=
name
.into
();
match
name
.chars
()
.next
()
{
Some
(
c
)
if
c
.is_ascii_alphabetic
()
||
c
==
'_'
=>
{}
_
=>
return
Err
(()),
...
...
@@ -473,7 +471,7 @@ fn node_label(&'a self, n: &Self::Node) -> LabelText<'a> {
/// The label need not be unique, and may be the empty string; the
/// default is in fact the empty string.
fn
edge_label
(
&
'a
self
,
_
e
:
&
Self
::
Edge
)
->
LabelText
<
'a
>
{
LabelStr
(
""
.into
_cow
())
LabelStr
(
""
.into
())
}
/// Maps `n` to a style that will be used in the rendered output.
...
...
@@ -497,16 +495,16 @@ pub fn escape_html(s: &str) -> String {
}
impl
<
'a
>
LabelText
<
'a
>
{
pub
fn
label
<
S
:
Into
Cow
<
'a
,
str
>>
(
s
:
S
)
->
LabelText
<
'a
>
{
LabelStr
(
s
.into
_cow
())
pub
fn
label
<
S
:
Into
<
Cow
<
'a
,
str
>
>>
(
s
:
S
)
->
LabelText
<
'a
>
{
LabelStr
(
s
.into
())
}
pub
fn
escaped
<
S
:
Into
Cow
<
'a
,
str
>>
(
s
:
S
)
->
LabelText
<
'a
>
{
EscStr
(
s
.into
_cow
())
pub
fn
escaped
<
S
:
Into
<
Cow
<
'a
,
str
>
>>
(
s
:
S
)
->
LabelText
<
'a
>
{
EscStr
(
s
.into
())
}
pub
fn
html
<
S
:
Into
Cow
<
'a
,
str
>>
(
s
:
S
)
->
LabelText
<
'a
>
{
HtmlStr
(
s
.into
_cow
())
pub
fn
html
<
S
:
Into
<
Cow
<
'a
,
str
>
>>
(
s
:
S
)
->
LabelText
<
'a
>
{
HtmlStr
(
s
.into
())
}
fn
escape_char
<
F
>
(
c
:
char
,
mut
f
:
F
)
...
...
@@ -550,7 +548,7 @@ fn pre_escaped_content(self) -> Cow<'a, str> {
EscStr
(
s
)
=>
s
,
LabelStr
(
s
)
=>
{
if
s
.contains
(
'\\'
)
{
(
&*
s
)
.escape_default
()
.into
_cow
()
(
&*
s
)
.escape_default
()
.into
()
}
else
{
s
}
...
...
@@ -570,7 +568,7 @@ pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> {
let
suffix
=
suffix
.pre_escaped_content
();
prefix
.push_str
(
r"\n\n"
);
prefix
.push_str
(
&
suffix
);
EscStr
(
prefix
.into
_cow
())
EscStr
(
prefix
.into
())
}
}
...
...
@@ -696,40 +694,6 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G,
writeln!
(
w
,
"}}"
)
}
pub
trait
IntoCow
<
'a
,
B
:
?
Sized
>
where
B
:
ToOwned
{
fn
into_cow
(
self
)
->
Cow
<
'a
,
B
>
;
}
impl
<
'a
>
IntoCow
<
'a
,
str
>
for
String
{
fn
into_cow
(
self
)
->
Cow
<
'a
,
str
>
{
Cow
::
Owned
(
self
)
}
}
impl
<
'a
>
IntoCow
<
'a
,
str
>
for
&
'a
str
{
fn
into_cow
(
self
)
->
Cow
<
'a
,
str
>
{
Cow
::
Borrowed
(
self
)
}
}
impl
<
'a
>
IntoCow
<
'a
,
str
>
for
Cow
<
'a
,
str
>
{
fn
into_cow
(
self
)
->
Cow
<
'a
,
str
>
{
self
}
}
impl
<
'a
,
T
:
Clone
>
IntoCow
<
'a
,
[
T
]
>
for
Vec
<
T
>
{
fn
into_cow
(
self
)
->
Cow
<
'a
,
[
T
]
>
{
Cow
::
Owned
(
self
)
}
}
impl
<
'a
,
T
:
Clone
>
IntoCow
<
'a
,
[
T
]
>
for
&
'a
[
T
]
{
fn
into_cow
(
self
)
->
Cow
<
'a
,
[
T
]
>
{
Cow
::
Borrowed
(
self
)
}
}
#[cfg(test)]
mod
tests
{
use
self
::
NodeLabels
::
*
;
...
...
@@ -737,7 +701,6 @@ mod tests {
use
super
::
LabelText
::{
self
,
LabelStr
,
EscStr
,
HtmlStr
};
use
std
::
io
;
use
std
::
io
::
prelude
::
*
;
use
IntoCow
;
/// each node is an index in a vector in the graph.
type
Node
=
usize
;
...
...
@@ -852,12 +815,12 @@ fn node_id(&'a self, n: &Node) -> Id<'a> {
}
fn
node_label
(
&
'a
self
,
n
:
&
Node
)
->
LabelText
<
'a
>
{
match
self
.node_labels
[
*
n
]
{
Some
(
ref
l
)
=>
LabelStr
(
l
.into_cow
()),
Some
(
l
)
=>
LabelStr
(
l
.into
()),
None
=>
LabelStr
(
id_name
(
n
)
.name
()),
}
}
fn
edge_label
(
&
'a
self
,
e
:
&&
'a
Edge
)
->
LabelText
<
'a
>
{
LabelStr
(
e
.label
.into
_cow
())
LabelStr
(
e
.label
.into
())
}
fn
node_style
(
&
'a
self
,
n
:
&
Node
)
->
Style
{
self
.node_styles
[
*
n
]
...
...
src/librustc/cfg/graphviz.rs
浏览文件 @
c30ce357
...
...
@@ -13,7 +13,6 @@
// For clarity, rename the graphviz crate locally to dot.
use
graphviz
as
dot
;
use
graphviz
::
IntoCow
;
use
cfg
;
use
hir
;
...
...
@@ -71,21 +70,21 @@ fn node_id(&'a self, &(i,_): &Node<'a>) -> dot::Id<'a> {
fn
node_label
(
&
'a
self
,
&
(
i
,
n
):
&
Node
<
'a
>
)
->
dot
::
LabelText
<
'a
>
{
if
i
==
self
.cfg.entry
{
dot
::
LabelText
::
LabelStr
(
"entry"
.into
_cow
())
dot
::
LabelText
::
LabelStr
(
"entry"
.into
())
}
else
if
i
==
self
.cfg.exit
{
dot
::
LabelText
::
LabelStr
(
"exit"
.into
_cow
())
dot
::
LabelText
::
LabelStr
(
"exit"
.into
())
}
else
if
n
.data
.id
()
==
hir
::
DUMMY_ITEM_LOCAL_ID
{
dot
::
LabelText
::
LabelStr
(
"(dummy_node)"
.into
_cow
())
dot
::
LabelText
::
LabelStr
(
"(dummy_node)"
.into
())
}
else
{
let
s
=
self
.local_id_to_string
(
n
.data
.id
());
dot
::
LabelText
::
EscStr
(
s
.into
_cow
())
dot
::
LabelText
::
EscStr
(
s
.into
())
}
}
fn
edge_label
(
&
self
,
e
:
&
Edge
<
'a
>
)
->
dot
::
LabelText
<
'a
>
{
let
mut
label
=
String
::
new
();
if
!
self
.labelled_edges
{
return
dot
::
LabelText
::
EscStr
(
label
.into
_cow
());
return
dot
::
LabelText
::
EscStr
(
label
.into
());
}
let
mut
put_one
=
false
;
for
(
i
,
&
id
)
in
e
.data.exiting_scopes
.iter
()
.enumerate
()
{
...
...
@@ -99,7 +98,7 @@ fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> {
i
,
&
s
[
..
]));
}
dot
::
LabelText
::
EscStr
(
label
.into
_cow
())
dot
::
LabelText
::
EscStr
(
label
.into
())
}
}
...
...
@@ -109,7 +108,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG {
fn
nodes
(
&
'a
self
)
->
dot
::
Nodes
<
'a
,
Node
<
'a
>>
{
let
mut
v
=
Vec
::
new
();
self
.graph
.each_node
(|
i
,
nd
|
{
v
.push
((
i
,
nd
));
true
});
v
.into
_cow
()
v
.into
()
}
fn
edges
(
&
'a
self
)
->
dot
::
Edges
<
'a
,
Edge
<
'a
>>
{
self
.graph
.all_edges
()
.iter
()
.collect
()
...
...
src/librustc_borrowck/graphviz.rs
浏览文件 @
c30ce357
...
...
@@ -23,7 +23,6 @@
use
rustc
::
cfg
::
CFGIndex
;
use
dataflow
::{
DataFlowOperator
,
DataFlowContext
,
EntryOrExit
};
use
std
::
rc
::
Rc
;
use
dot
::
IntoCow
;
#[derive(Debug,
Copy,
Clone)]
pub
enum
Variant
{
...
...
@@ -139,8 +138,8 @@ fn node_label(&'a self, n: &Node<'a>) -> dot::LabelText<'a> {
let
suffix
=
self
.dataflow_for
(
EntryOrExit
::
Exit
,
n
);
let
inner_label
=
self
.inner
.node_label
(
n
);
inner_label
.prefix_line
(
dot
::
LabelText
::
LabelStr
(
prefix
.into
_cow
()))
.suffix_line
(
dot
::
LabelText
::
LabelStr
(
suffix
.into
_cow
()))
.prefix_line
(
dot
::
LabelText
::
LabelStr
(
prefix
.into
()))
.suffix_line
(
dot
::
LabelText
::
LabelStr
(
suffix
.into
()))
}
fn
edge_label
(
&
'a
self
,
e
:
&
Edge
<
'a
>
)
->
dot
::
LabelText
<
'a
>
{
self
.inner
.edge_label
(
e
)
}
}
...
...
src/librustc_incremental/assert_dep_graph.rs
浏览文件 @
c30ce357
...
...
@@ -55,7 +55,6 @@
use
rustc
::
hir
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
ich
::{
ATTR_IF_THIS_CHANGED
,
ATTR_THEN_THIS_WOULD_NEED
};
use
graphviz
::
IntoCow
;
use
std
::
env
;
use
std
::
fs
::{
self
,
File
};
use
std
::
io
::
Write
;
...
...
@@ -274,10 +273,10 @@ impl<'a, 'tcx, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> {
type
Edge
=
(
&
'q
DepNode
,
&
'q
DepNode
);
fn
nodes
(
&
self
)
->
dot
::
Nodes
<&
'q
DepNode
>
{
let
nodes
:
Vec
<
_
>
=
self
.0
.iter
()
.cloned
()
.collect
();
nodes
.into
_cow
()
nodes
.into
()
}
fn
edges
(
&
self
)
->
dot
::
Edges
<
(
&
'q
DepNode
,
&
'q
DepNode
)
>
{
self
.1
[
..
]
.into
_cow
()
self
.1
[
..
]
.into
()
}
fn
source
(
&
self
,
edge
:
&
(
&
'q
DepNode
,
&
'q
DepNode
))
->
&
'q
DepNode
{
edge
.0
...
...
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
浏览文件 @
c30ce357
...
...
@@ -14,7 +14,7 @@
use
super
::
*
;
use
borrow_check
::
nll
::
constraints
::
OutlivesConstraint
;
use
dot
::{
self
,
IntoCow
}
;
use
dot
;
use
std
::
borrow
::
Cow
;
use
std
::
io
::{
self
,
Write
};
...
...
@@ -49,7 +49,7 @@ impl<'a, 'this, 'tcx> dot::Labeller<'this> for RawConstraints<'a, 'tcx> {
type
Edge
=
OutlivesConstraint
;
fn
graph_id
(
&
'this
self
)
->
dot
::
Id
<
'this
>
{
dot
::
Id
::
new
(
"RegionInferenceContext"
.to_string
()
)
.unwrap
()
dot
::
Id
::
new
(
"RegionInferenceContext"
)
.unwrap
()
}
fn
node_id
(
&
'this
self
,
n
:
&
RegionVid
)
->
dot
::
Id
<
'this
>
{
dot
::
Id
::
new
(
format!
(
"r{}"
,
n
.index
()))
.unwrap
()
...
...
@@ -58,10 +58,10 @@ fn node_shape(&'this self, _node: &RegionVid) -> Option<dot::LabelText<'this>> {
Some
(
dot
::
LabelText
::
LabelStr
(
Cow
::
Borrowed
(
"box"
)))
}
fn
node_label
(
&
'this
self
,
n
:
&
RegionVid
)
->
dot
::
LabelText
<
'this
>
{
dot
::
LabelText
::
LabelStr
(
format!
(
"{:?}"
,
n
)
.into
_cow
())
dot
::
LabelText
::
LabelStr
(
format!
(
"{:?}"
,
n
)
.into
())
}
fn
edge_label
(
&
'this
self
,
e
:
&
OutlivesConstraint
)
->
dot
::
LabelText
<
'this
>
{
dot
::
LabelText
::
LabelStr
(
format!
(
"{:?}"
,
e
.locations
)
.into
_cow
())
dot
::
LabelText
::
LabelStr
(
format!
(
"{:?}"
,
e
.locations
)
.into
())
}
}
...
...
@@ -71,10 +71,10 @@ impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for RawConstraints<'a, 'tcx> {
fn
nodes
(
&
'this
self
)
->
dot
::
Nodes
<
'this
,
RegionVid
>
{
let
vids
:
Vec
<
RegionVid
>
=
self
.regioncx.definitions
.indices
()
.collect
();
vids
.into
_cow
()
vids
.into
()
}
fn
edges
(
&
'this
self
)
->
dot
::
Edges
<
'this
,
OutlivesConstraint
>
{
(
&
self
.regioncx.constraints.raw
[
..
])
.into
_cow
()
(
&
self
.regioncx.constraints.raw
[
..
])
.into
()
}
// Render `a: b` as `a -> b`, indicating the flow
...
...
@@ -109,7 +109,7 @@ fn node_shape(&'this self, _node: &ConstraintSccIndex) -> Option<dot::LabelText<
}
fn
node_label
(
&
'this
self
,
n
:
&
ConstraintSccIndex
)
->
dot
::
LabelText
<
'this
>
{
let
nodes
=
&
self
.nodes_per_scc
[
*
n
];
dot
::
LabelText
::
LabelStr
(
format!
(
"{:?} = {:?}"
,
n
,
nodes
)
.into
_cow
())
dot
::
LabelText
::
LabelStr
(
format!
(
"{:?} = {:?}"
,
n
,
nodes
)
.into
())
}
}
...
...
@@ -119,7 +119,7 @@ impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for SccConstraints<'a, 'tcx> {
fn
nodes
(
&
'this
self
)
->
dot
::
Nodes
<
'this
,
ConstraintSccIndex
>
{
let
vids
:
Vec
<
ConstraintSccIndex
>
=
self
.regioncx.constraint_sccs
.all_sccs
()
.collect
();
vids
.into
_cow
()
vids
.into
()
}
fn
edges
(
&
'this
self
)
->
dot
::
Edges
<
'this
,
(
ConstraintSccIndex
,
ConstraintSccIndex
)
>
{
let
edges
:
Vec
<
_
>
=
self
.regioncx
...
...
@@ -134,7 +134,7 @@ fn edges(&'this self) -> dot::Edges<'this, (ConstraintSccIndex, ConstraintSccInd
})
.collect
();
edges
.into
_cow
()
edges
.into
()
}
// Render `a: b` as `a -> b`, indicating the flow
...
...
src/librustc_mir/dataflow/graphviz.rs
浏览文件 @
c30ce357
...
...
@@ -14,7 +14,6 @@
use
rustc
::
mir
::{
BasicBlock
,
Mir
};
use
dot
;
use
dot
::
IntoCow
;
use
std
::
fs
;
use
std
::
io
;
...
...
@@ -257,7 +256,7 @@ fn nodes(&self) -> dot::Nodes<Node> {
.basic_blocks
()
.indices
()
.collect
::
<
Vec
<
_
>>
()
.into
_cow
()
.into
()
}
fn
edges
(
&
self
)
->
dot
::
Edges
<
Edge
>
{
...
...
@@ -267,7 +266,7 @@ fn edges(&self) -> dot::Edges<Edge> {
.indices
()
.flat_map
(|
bb
|
outgoing
(
mir
,
bb
))
.collect
::
<
Vec
<
_
>>
()
.into
_cow
()
.into
()
}
fn
source
(
&
self
,
edge
:
&
Edge
)
->
Node
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录