Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ed2be6fa
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,发现更多精彩内容 >>
提交
ed2be6fa
编写于
12月 12, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: move the FORCE_IMPL_FILENAME_LINE handling into LocalPathPrinter.
上级
23861681
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
26 deletion
+26
-26
src/librustc/ty/item_path.rs
src/librustc/ty/item_path.rs
+26
-26
未找到文件。
src/librustc/ty/item_path.rs
浏览文件 @
ed2be6fa
...
...
@@ -91,7 +91,7 @@ pub fn default_print_item_path(&mut self, def_id: DefId) -> P::Path {
}
DefPathData
::
Impl
=>
{
self
.
default_
print_impl_path
(
def_id
)
self
.print_impl_path
(
def_id
)
}
// Unclear if there is any value in distinguishing these.
...
...
@@ -132,18 +132,6 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path {
debug!
(
"default_print_impl_path: impl_def_id={:?}"
,
impl_def_id
);
let
parent_def_id
=
self
.tcx
.parent_def_id
(
impl_def_id
)
.unwrap
();
// Always use types for non-local impls, where types are always
// available, and filename/line-number is mostly uninteresting.
let
use_types
=
!
impl_def_id
.is_local
()
||
{
// Otherwise, use filename/line-number if forced.
let
force_no_types
=
FORCE_IMPL_FILENAME_LINE
.with
(|
f
|
f
.get
());
!
force_no_types
};
if
!
use_types
{
return
self
.default_print_impl_path_fallback
(
impl_def_id
);
}
// Decide whether to print the parent path for the impl.
// Logically, since impls are global, it's never needed, but
// users may find it useful. Currently, we omit the parent if
...
...
@@ -210,19 +198,6 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path {
}
}
}
fn
default_print_impl_path_fallback
(
&
mut
self
,
impl_def_id
:
DefId
)
->
P
::
Path
{
// If no type info is available, fall back to
// pretty printing some span information. This should
// only occur very early in the compiler pipeline.
// FIXME(eddyb) this should just be using `tcx.def_span(impl_def_id)`
let
parent_def_id
=
self
.tcx
.parent_def_id
(
impl_def_id
)
.unwrap
();
let
path
=
self
.print_item_path
(
parent_def_id
);
let
hir_id
=
self
.tcx
.hir
()
.as_local_hir_id
(
impl_def_id
)
.unwrap
();
let
item
=
self
.tcx
.hir
()
.expect_item_by_hir_id
(
hir_id
);
let
span_str
=
self
.tcx.sess
.source_map
()
.span_to_string
(
item
.span
);
self
.path_append
(
path
,
&
format!
(
"<impl at {}>"
,
span_str
))
}
}
impl
<
'a
,
'gcx
,
'tcx
>
TyCtxt
<
'a
,
'gcx
,
'tcx
>
{
...
...
@@ -291,6 +266,9 @@ pub trait ItemPathPrinter: Sized {
fn
print_item_path
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
def_id
:
DefId
)
->
Self
::
Path
{
self
.default_print_item_path
(
def_id
)
}
fn
print_impl_path
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
impl_def_id
:
DefId
)
->
Self
::
Path
{
self
.default_print_impl_path
(
impl_def_id
)
}
fn
path_crate
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
cnum
:
CrateNum
)
->
Self
::
Path
;
fn
path_impl
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
text
:
&
str
)
->
Self
::
Path
;
...
...
@@ -470,6 +448,28 @@ fn print_item_path(self: &mut PrintCx<'_, '_, '_, Self>, def_id: DefId) -> Self:
self
.try_print_visible_item_path
(
def_id
)
.unwrap_or_else
(||
self
.default_print_item_path
(
def_id
))
}
fn
print_impl_path
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
impl_def_id
:
DefId
)
->
Self
::
Path
{
// Always use types for non-local impls, where types are always
// available, and filename/line-number is mostly uninteresting.
let
use_types
=
!
impl_def_id
.is_local
()
||
{
// Otherwise, use filename/line-number if forced.
let
force_no_types
=
FORCE_IMPL_FILENAME_LINE
.with
(|
f
|
f
.get
());
!
force_no_types
};
if
!
use_types
{
// If no type info is available, fall back to
// pretty printing some span information. This should
// only occur very early in the compiler pipeline.
// FIXME(eddyb) this should just be using `tcx.def_span(impl_def_id)`
let
parent_def_id
=
self
.tcx
.parent_def_id
(
impl_def_id
)
.unwrap
();
let
path
=
self
.print_item_path
(
parent_def_id
);
let
span
=
self
.tcx
.def_span
(
impl_def_id
);
return
self
.path_append
(
path
,
&
format!
(
"<impl at {:?}>"
,
span
));
}
self
.default_print_impl_path
(
impl_def_id
)
}
fn
path_crate
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
cnum
:
CrateNum
)
->
Self
::
Path
{
if
cnum
==
LOCAL_CRATE
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录