Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
72cda98e
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
72cda98e
编写于
4月 24, 2019
作者:
S
Santiago Pastorino
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement Debug for Place using Place::iterate
上级
e305df18
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
52 deletion
+86
-52
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+86
-52
未找到文件。
src/librustc/mir/mod.rs
浏览文件 @
72cda98e
...
...
@@ -2156,61 +2156,95 @@ impl<'p, 'tcx> FusedIterator for PlaceProjectionsIter<'p, 'tcx> {}
impl
<
'tcx
>
Debug
for
Place
<
'tcx
>
{
fn
fmt
(
&
self
,
fmt
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
use
self
::
Place
::
*
;
match
*
self
{
Base
(
PlaceBase
::
Local
(
id
))
=>
write!
(
fmt
,
"{:?}"
,
id
),
Base
(
PlaceBase
::
Static
(
box
self
::
Static
{
ty
,
kind
:
StaticKind
::
Static
(
def_id
)
}))
=>
{
write!
(
fmt
,
"({}: {:?})"
,
ty
::
tls
::
with
(|
tcx
|
tcx
.def_path_str
(
def_id
)),
ty
)
},
Base
(
PlaceBase
::
Static
(
box
self
::
Static
{
ty
,
kind
:
StaticKind
::
Promoted
(
promoted
)
})
)
=>
{
write!
(
fmt
,
"({:?}: {:?})"
,
promoted
,
ty
)
},
Projection
(
ref
data
)
=>
match
data
.elem
{
ProjectionElem
::
Downcast
(
Some
(
name
),
_
index
)
=>
{
write!
(
fmt
,
"({:?} as {})"
,
data
.base
,
name
)
}
ProjectionElem
::
Downcast
(
None
,
index
)
=>
{
write!
(
fmt
,
"({:?} as variant#{:?})"
,
data
.base
,
index
)
}
ProjectionElem
::
Deref
=>
write!
(
fmt
,
"(*{:?})"
,
data
.base
),
ProjectionElem
::
Field
(
field
,
ty
)
=>
{
write!
(
fmt
,
"({:?}.{:?}: {:?})"
,
data
.base
,
field
.index
(),
ty
)
}
ProjectionElem
::
Index
(
ref
index
)
=>
write!
(
fmt
,
"{:?}[{:?}]"
,
data
.base
,
index
),
ProjectionElem
::
ConstantIndex
{
offset
,
min_length
,
from_end
:
false
,
}
=>
write!
(
fmt
,
"{:?}[{:?} of {:?}]"
,
data
.base
,
offset
,
min_length
),
ProjectionElem
::
ConstantIndex
{
offset
,
min_length
,
from_end
:
true
,
}
=>
write!
(
fmt
,
"{:?}[-{:?} of {:?}]"
,
data
.base
,
offset
,
min_length
),
ProjectionElem
::
Subslice
{
from
,
to
}
if
to
==
0
=>
{
write!
(
fmt
,
"{:?}[{:?}:]"
,
data
.base
,
from
)
self
.iterate
(|
_
place_base
,
place_projections
|
{
// FIXME: remove this collect once we have migrated to slices
let
projs_vec
:
Vec
<
_
>
=
place_projections
.collect
();
for
projection
in
projs_vec
.iter
()
.rev
()
{
match
projection
.elem
{
ProjectionElem
::
Downcast
(
_
,
_
)
|
ProjectionElem
::
Field
(
_
,
_
)
=>
{
write!
(
fmt
,
"("
)
.unwrap
();
}
ProjectionElem
::
Deref
=>
{
write!
(
fmt
,
"(*"
)
.unwrap
();
}
ProjectionElem
::
Index
(
_
)
|
ProjectionElem
::
ConstantIndex
{
..
}
|
ProjectionElem
::
Subslice
{
..
}
=>
{}
}
ProjectionElem
::
Subslice
{
from
,
to
}
if
from
==
0
=>
{
write!
(
fmt
,
"{:?}[:-{:?}]"
,
data
.base
,
to
)
}
});
self
.iterate
(|
place_base
,
place_projections
|
{
match
place_base
{
PlaceBase
::
Local
(
id
)
=>
{
write!
(
fmt
,
"{:?}"
,
id
)
?
;
}
ProjectionElem
::
Subslice
{
from
,
to
}
=>
{
write!
(
fmt
,
"{:?}[{:?}:-{:?}]"
,
data
.base
,
from
,
to
)
PlaceBase
::
Static
(
box
self
::
Static
{
ty
,
kind
:
StaticKind
::
Static
(
def_id
)
})
=>
{
write!
(
fmt
,
"({}: {:?})"
,
ty
::
tls
::
with
(|
tcx
|
tcx
.def_path_str
(
*
def_id
)),
ty
)
?
;
},
PlaceBase
::
Static
(
box
self
::
Static
{
ty
,
kind
:
StaticKind
::
Promoted
(
promoted
)
}
)
=>
{
write!
(
fmt
,
"({:?}: {:?})"
,
promoted
,
ty
)
?
;
},
}
for
projection
in
place_projections
{
match
projection
.elem
{
ProjectionElem
::
Downcast
(
Some
(
name
),
_
index
)
=>
{
write!
(
fmt
,
" as {})"
,
name
)
?
;
}
ProjectionElem
::
Downcast
(
None
,
index
)
=>
{
write!
(
fmt
,
" as variant#{:?})"
,
index
)
?
;
}
ProjectionElem
::
Deref
=>
{
write!
(
fmt
,
")"
)
?
;
}
ProjectionElem
::
Field
(
field
,
ty
)
=>
{
write!
(
fmt
,
".{:?}: {:?})"
,
field
.index
(),
ty
)
?
;
}
ProjectionElem
::
Index
(
ref
index
)
=>
{
write!
(
fmt
,
"[{:?}]"
,
index
)
?
;
}
ProjectionElem
::
ConstantIndex
{
offset
,
min_length
,
from_end
:
false
,
}
=>
{
write!
(
fmt
,
"[{:?} of {:?}]"
,
offset
,
min_length
)
?
;
}
ProjectionElem
::
ConstantIndex
{
offset
,
min_length
,
from_end
:
true
,
}
=>
{
write!
(
fmt
,
"[-{:?} of {:?}]"
,
offset
,
min_length
)
?
;
}
ProjectionElem
::
Subslice
{
from
,
to
}
if
to
==
0
=>
{
write!
(
fmt
,
"[{:?}:]"
,
from
)
?
;
}
ProjectionElem
::
Subslice
{
from
,
to
}
if
from
==
0
=>
{
write!
(
fmt
,
"[:-{:?}]"
,
to
)
?
;
}
ProjectionElem
::
Subslice
{
from
,
to
}
=>
{
write!
(
fmt
,
"[{:?}:-{:?}]"
,
from
,
to
)
?
;
}
}
},
}
}
Ok
(())
})
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录