Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
36f64f15
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,发现更多精彩内容 >>
提交
36f64f15
编写于
12月 28, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: remove `ty::print::FORCE_ABSOLUTE` altogether.
上级
66cc029d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
45 deletion
+6
-45
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/error_reporting/mod.rs
+2
-2
src/librustc/ty/print.rs
src/librustc/ty/print.rs
+1
-38
src/librustc_codegen_utils/symbol_names.rs
src/librustc_codegen_utils/symbol_names.rs
+3
-5
未找到文件。
src/librustc/infer/error_reporting/mod.rs
浏览文件 @
36f64f15
...
...
@@ -447,7 +447,7 @@ fn check_and_note_conflicting_crates(
use
hir
::
def
::
Namespace
;
use
hir
::
def_id
::
CrateNum
;
use
ty
::
print
::{
PrintCx
,
Printer
};
use
ty
::
subst
::
Substs
;
use
ty
::
subst
::
Substs
Ref
;
struct
AbsolutePathPrinter
;
...
...
@@ -481,7 +481,7 @@ fn path_generic_args<'tcx>(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'tcx
,
Self
>
,
path
:
Self
::
Path
,
_
params
:
&
[
ty
::
GenericParamDef
],
_
substs
:
&
'tcx
Substs
<
'tcx
>
,
_
substs
:
SubstsRef
<
'tcx
>
,
_
ns
:
Namespace
,
_
projections
:
impl
Iterator
<
Item
=
ty
::
ExistentialProjection
<
'tcx
>>
,
)
->
Self
::
Path
{
...
...
src/librustc/ty/print.rs
浏览文件 @
36f64f15
...
...
@@ -16,25 +16,10 @@
use
std
::
ops
::
Deref
;
thread_local!
{
static
FORCE_ABSOLUTE
:
Cell
<
bool
>
=
Cell
::
new
(
false
);
static
FORCE_IMPL_FILENAME_LINE
:
Cell
<
bool
>
=
Cell
::
new
(
false
);
static
SHOULD_PREFIX_WITH_CRATE
:
Cell
<
bool
>
=
Cell
::
new
(
false
);
}
/// Enforces that def_path_str always returns an absolute path and
/// also enables "type-based" impl paths. This is used when building
/// symbols that contain types, where we want the crate name to be
/// part of the symbol.
pub
fn
with_forced_absolute_paths
<
F
:
FnOnce
()
->
R
,
R
>
(
f
:
F
)
->
R
{
FORCE_ABSOLUTE
.with
(|
force
|
{
let
old
=
force
.get
();
force
.set
(
true
);
let
result
=
f
();
force
.set
(
old
);
result
})
}
/// Force us to name impls with just the filename/line number. We
/// normally try to use types. But at some points, notably while printing
/// cycle errors, this can result in extra or suboptimal error output,
...
...
@@ -223,24 +208,7 @@ fn guess_def_namespace(self, def_id: DefId) -> Namespace {
}
/// Returns a string identifying this `DefId`. This string is
/// suitable for user output. It is relative to the current crate
/// root, unless with_forced_absolute_paths was used.
pub
fn
def_path_str_with_substs_and_ns
(
self
,
def_id
:
DefId
,
substs
:
Option
<
SubstsRef
<
'tcx
>>
,
ns
:
Namespace
,
)
->
String
{
debug!
(
"def_path_str: def_id={:?}, substs={:?}, ns={:?}"
,
def_id
,
substs
,
ns
);
let
mut
s
=
String
::
new
();
let
_
=
PrintCx
::
new
(
self
,
FmtPrinter
{
fmt
:
&
mut
s
})
.print_def_path
(
def_id
,
substs
,
ns
,
iter
::
empty
());
s
}
/// Returns a string identifying this `DefId`. This string is
/// suitable for user output. It is relative to the current crate
/// root, unless with_forced_absolute_paths was used.
/// suitable for user output.
pub
fn
def_path_str
(
self
,
def_id
:
DefId
)
->
String
{
let
ns
=
self
.guess_def_namespace
(
def_id
);
debug!
(
"def_path_str: def_id={:?}, ns={:?}"
,
def_id
,
ns
);
...
...
@@ -722,8 +690,6 @@ fn print_def_path(
// FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
// both here and in `default_print_def_path`.
let
generics
=
substs
.map
(|
_
|
self
.tcx
.generics_of
(
def_id
));
// HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
assert
!
(
!
FORCE_ABSOLUTE
.with
(|
force
|
force
.get
()));
if
generics
.as_ref
()
.and_then
(|
g
|
g
.parent
)
.is_none
()
{
if
let
Some
(
path
)
=
self
.try_print_visible_def_path
(
def_id
)
{
let
path
=
if
let
(
Some
(
generics
),
Some
(
substs
))
=
(
generics
,
substs
)
{
...
...
@@ -763,9 +729,6 @@ fn print_def_path(
}
fn
path_crate
(
self
:
&
mut
PrintCx
<
'_
,
'_
,
'_
,
Self
>
,
cnum
:
CrateNum
)
->
Self
::
Path
{
// HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
assert
!
(
!
FORCE_ABSOLUTE
.with
(|
force
|
force
.get
()));
if
cnum
==
LOCAL_CRATE
{
if
self
.tcx.sess
.rust_2018
()
{
// We add the `crate::` keyword on Rust 2018, only when desired.
...
...
src/librustc_codegen_utils/symbol_names.rs
浏览文件 @
36f64f15
...
...
@@ -225,11 +225,9 @@ fn get_symbol_hash<'a, 'tcx>(
}
fn
def_symbol_name
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
def_id
:
DefId
)
->
ty
::
SymbolName
{
ty
::
print
::
with_forced_absolute_paths
(||
{
let
mut
cx
=
PrintCx
::
new
(
tcx
,
SymbolPath
::
new
(
tcx
));
let
_
=
cx
.print_def_path
(
def_id
,
None
,
Namespace
::
ValueNS
,
iter
::
empty
());
cx
.printer
.into_interned
()
})
let
mut
cx
=
PrintCx
::
new
(
tcx
,
SymbolPath
::
new
(
tcx
));
let
_
=
cx
.print_def_path
(
def_id
,
None
,
Namespace
::
ValueNS
,
iter
::
empty
());
cx
.printer
.into_interned
()
}
fn
symbol_name
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
)
->
ty
::
SymbolName
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录