Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
eb525b09
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,发现更多精彩内容 >>
提交
eb525b09
编写于
12月 07, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: tie the 'tcx between Print and PrintCx in ty::print.
上级
3bad9f7b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
115 addition
and
94 deletion
+115
-94
src/librustc/infer/outlives/free_region_map.rs
src/librustc/infer/outlives/free_region_map.rs
+1
-1
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+1
-1
src/librustc/ty/instance.rs
src/librustc/ty/instance.rs
+1
-1
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+2
-2
src/librustc/ty/print.rs
src/librustc/ty/print.rs
+10
-6
src/librustc/ty/structural_impls.rs
src/librustc/ty/structural_impls.rs
+32
-0
src/librustc/ty/sty.rs
src/librustc/ty/sty.rs
+1
-1
src/librustc/ty/subst.rs
src/librustc/ty/subst.rs
+3
-3
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+62
-77
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/intrinsic.rs
+2
-2
未找到文件。
src/librustc/infer/outlives/free_region_map.rs
浏览文件 @
eb525b09
...
...
@@ -91,7 +91,7 @@ fn is_free_or_static(r: Region<'_>) -> bool {
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
FreeRegionMap
<
'a
>
{
type
Lifted
=
FreeRegionMap
<
'tcx
>
;
fn
lift_to_tcx
<
'b
,
'gcx
>
(
&
self
,
tcx
:
TyCtxt
<
'b
,
'gcx
,
'tcx
>
)
->
Option
<
FreeRegionMap
<
'tcx
>>
{
self
.relation
.maybe_map
(|
&
fr
|
fr
.lift_to_tcx
(
tcx
))
self
.relation
.maybe_map
(|
&
fr
|
tcx
.lift
(
&
fr
))
.map
(|
relation
|
FreeRegionMap
{
relation
})
}
}
src/librustc/mir/mod.rs
浏览文件 @
eb525b09
...
...
@@ -2405,7 +2405,7 @@ fn fmt_tuple(fmt: &mut Formatter<'_>, places: &[Operand<'_>]) -> fmt::Result {
AggregateKind
::
Adt
(
adt_def
,
variant
,
substs
,
_u
ser_ty
,
_
)
=>
{
let
variant_def
=
&
adt_def
.variants
[
variant
];
ppaux
::
parameterized
(
fmt
,
substs
,
variant_def
.did
,
&
[]
)
?
;
ppaux
::
parameterized
(
fmt
,
variant_def
.did
,
substs
)
?
;
match
variant_def
.ctor_kind
{
CtorKind
::
Const
=>
Ok
(()),
...
...
src/librustc/ty/instance.rs
浏览文件 @
eb525b09
...
...
@@ -175,7 +175,7 @@ pub fn requires_local<'a>(
impl
<
'tcx
>
fmt
::
Display
for
Instance
<
'tcx
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
ppaux
::
parameterized
(
f
,
self
.
substs
,
self
.def_id
(),
&
[]
)
?
;
ppaux
::
parameterized
(
f
,
self
.
def_id
(),
self
.substs
)
?
;
match
self
.def
{
InstanceDef
::
Item
(
_
)
=>
Ok
(()),
InstanceDef
::
VtableShim
(
_
)
=>
{
...
...
src/librustc/ty/mod.rs
浏览文件 @
eb525b09
...
...
@@ -1001,7 +1001,7 @@ pub fn const_param(&'tcx self,
}
/// Bounds on generics.
#[derive(Clone,
Default,
HashStable)]
#[derive(Clone,
Default,
Debug,
HashStable)]
pub
struct
GenericPredicates
<
'tcx
>
{
pub
parent
:
Option
<
DefId
>
,
pub
predicates
:
Vec
<
(
Predicate
<
'tcx
>
,
Span
)
>
,
...
...
@@ -1506,7 +1506,7 @@ pub fn to_opt_type_outlives(&self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
/// `[[], [U:Bar<T>]]`. Now if there were some particular reference
/// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[],
/// [usize:Bar<isize>]]`.
#[derive(Clone)]
#[derive(Clone
,
Debug
)]
pub
struct
InstantiatedPredicates
<
'tcx
>
{
pub
predicates
:
Vec
<
Predicate
<
'tcx
>>
,
}
...
...
src/librustc/ty/print.rs
浏览文件 @
eb525b09
...
...
@@ -56,32 +56,36 @@ pub(crate) fn prepare_late_bound_region_info<T>(&mut self, value: &ty::Binder<T>
}
pub
trait
Print
<
'tcx
>
{
fn
print
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
_
>
)
->
fmt
::
Result
;
fn
print_to_string
(
&
self
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
_
>
)
->
String
{
fn
print
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
)
->
fmt
::
Result
;
fn
print_to_string
(
&
self
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
)
->
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
PrintCx
<
'_
,
'_
,
'_
>
)
->
fmt
::
Result
{
fn
print_display
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'tcx
>
,
)
->
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
PrintCx
<
'_
,
'_
,
'
_
>
)
->
String
{
fn
print_display_to_string
(
&
self
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
)
->
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
PrintCx
<
'_
,
'_
,
'
_
>
)
->
fmt
::
Result
{
fn
print_debug
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
)
->
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
PrintCx
<
'_
,
'_
,
'
_
>
)
->
String
{
fn
print_debug_to_string
(
&
self
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
)
->
String
{
let
mut
result
=
String
::
new
();
let
_
=
self
.print_debug
(
&
mut
result
,
cx
);
result
...
...
src/librustc/ty/structural_impls.rs
浏览文件 @
eb525b09
...
...
@@ -48,7 +48,10 @@
// really meant to be folded. In general, we can only fold a fully
// general `Region`.
crate
::
ty
::
BoundRegion
,
crate
::
ty
::
Placeholder
<
crate
::
ty
::
BoundRegion
>
,
crate
::
ty
::
ClosureKind
,
crate
::
ty
::
FreeRegion
,
crate
::
ty
::
InferTy
,
crate
::
ty
::
IntVarValue
,
crate
::
ty
::
ParamConst
,
crate
::
ty
::
ParamTy
,
...
...
@@ -480,6 +483,13 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
}
}
BraceStructLiftImpl!
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
ty
::
TypeAndMut
<
'a
>
{
type
Lifted
=
ty
::
TypeAndMut
<
'tcx
>
;
ty
,
mutbl
}
}
BraceStructLiftImpl!
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
ty
::
Instance
<
'a
>
{
type
Lifted
=
ty
::
Instance
<
'tcx
>
;
...
...
@@ -494,6 +504,28 @@ impl<'a, 'tcx> Lift<'tcx> for interpret::GlobalId<'a> {
}
}
// FIXME(eddyb) this is like what some of the macros above generate,
// except that macros *also* generate a foldable impl, which we don't
// want (with it we'd risk bypassing `fold_region` / `fold_const`).
impl
<
'tcx
>
Lift
<
'tcx
>
for
ty
::
RegionKind
{
type
Lifted
=
ty
::
RegionKind
;
fn
lift_to_tcx
<
'b
,
'gcx
>
(
&
self
,
_
:
TyCtxt
<
'b
,
'gcx
,
'tcx
>
)
->
Option
<
Self
::
Lifted
>
{
Some
(
self
.clone
())
}
}
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
ty
::
LazyConst
<
'a
>
{
type
Lifted
=
ty
::
LazyConst
<
'tcx
>
;
fn
lift_to_tcx
<
'b
,
'gcx
>
(
&
self
,
tcx
:
TyCtxt
<
'b
,
'gcx
,
'tcx
>
)
->
Option
<
Self
::
Lifted
>
{
match
self
{
ty
::
LazyConst
::
Evaluated
(
v
)
=>
Some
(
ty
::
LazyConst
::
Evaluated
(
tcx
.lift
(
v
)
?
)),
ty
::
LazyConst
::
Unevaluated
(
def_id
,
substs
)
=>
{
Some
(
ty
::
LazyConst
::
Unevaluated
(
*
def_id
,
tcx
.lift
(
substs
)
?
))
}
}
}
}
BraceStructLiftImpl!
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
ty
::
Const
<
'a
>
{
type
Lifted
=
ty
::
Const
<
'tcx
>
;
...
...
src/librustc/ty/sty.rs
浏览文件 @
eb525b09
...
...
@@ -616,7 +616,7 @@ pub fn principal_def_id(&self) -> Option<DefId> {
#[inline]
pub
fn
projection_bounds
<
'a
>
(
&
'a
self
)
->
impl
Iterator
<
Item
=
ExistentialProjection
<
'tcx
>>
+
'a
{
impl
Iterator
<
Item
=
ExistentialProjection
<
'tcx
>>
+
Clone
+
'a
{
self
.iter
()
.filter_map
(|
predicate
|
{
match
*
predicate
{
ExistentialPredicate
::
Projection
(
p
)
=>
Some
(
p
),
...
...
src/librustc/ty/subst.rs
浏览文件 @
eb525b09
...
...
@@ -140,9 +140,9 @@ impl<'a, 'tcx> Lift<'tcx> for Kind<'a> {
fn
lift_to_tcx
<
'cx
,
'gcx
>
(
&
self
,
tcx
:
TyCtxt
<
'cx
,
'gcx
,
'tcx
>
)
->
Option
<
Self
::
Lifted
>
{
match
self
.unpack
()
{
UnpackedKind
::
Lifetime
(
lt
)
=>
lt
.lift_to_tcx
(
tcx
)
.map
(|
lt
|
lt
.into
()),
UnpackedKind
::
Type
(
ty
)
=>
t
y
.lift_to_tcx
(
tcx
)
.map
(|
ty
|
ty
.into
()),
UnpackedKind
::
Const
(
ct
)
=>
ct
.lift_to_tcx
(
tcx
)
.map
(|
ct
|
ct
.into
()),
UnpackedKind
::
Lifetime
(
lt
)
=>
tcx
.lift
(
&
lt
)
.map
(|
lt
|
lt
.into
()),
UnpackedKind
::
Type
(
ty
)
=>
t
cx
.lift
(
&
ty
)
.map
(|
ty
|
ty
.into
()),
UnpackedKind
::
Const
(
ct
)
=>
tcx
.lift
(
&
ct
)
.map
(|
ct
|
ct
.into
()),
}
}
}
...
...
src/librustc/util/ppaux.rs
浏览文件 @
eb525b09
...
...
@@ -14,6 +14,7 @@
use
std
::
cell
::
Cell
;
use
std
::
fmt
;
use
std
::
iter
;
use
std
::
usize
;
use
rustc_target
::
spec
::
abi
::
Abi
;
...
...
@@ -182,7 +183,9 @@ pub fn placeholder_highlight(&self, p: ty::PlaceholderRegion) -> Option<usize> {
macro_rules!
gen_display_debug_body
{
(
$with:path
)
=>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
PrintCx
::
with
(|
mut
cx
|
$with
(
self
,
f
,
&
mut
cx
))
PrintCx
::
with
(|
mut
cx
|
{
$with
(
&
cx
.tcx
.lift
(
self
)
.expect
(
"could not lift for printing"
),
f
,
&
mut
cx
)
})
}
};
}
...
...
@@ -215,7 +218,7 @@ impl<$($x)+> Print<'tcx> for $target {
fn
print
<
F
:
fmt
::
Write
>
(
&
$self
,
$f
:
&
mut
F
,
$cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
_
>
,
$cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
,
)
->
fmt
::
Result
{
if
$cx
.is_debug
$dbg
else
$disp
...
...
@@ -227,7 +230,7 @@ impl Print<'tcx> for $target {
fn
print
<
F
:
fmt
::
Write
>
(
&
$self
,
$f
:
&
mut
F
,
$cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
_
>
,
$cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
,
)
->
fmt
::
Result
{
if
$cx
.is_debug
$dbg
else
$disp
...
...
@@ -285,9 +288,9 @@ fn print<F: fmt::Write>(
impl
PrintCx
<
'a
,
'gcx
,
'tcx
>
{
fn
fn_sig
<
F
:
fmt
::
Write
>
(
&
mut
self
,
f
:
&
mut
F
,
inputs
:
&
[
Ty
<
'
_
>
],
inputs
:
&
[
Ty
<
'
tcx
>
],
c_variadic
:
bool
,
output
:
Ty
<
'
_
>
)
output
:
Ty
<
'
tcx
>
)
->
fmt
::
Result
{
write!
(
f
,
"("
)
?
;
let
mut
inputs
=
inputs
.iter
();
...
...
@@ -308,12 +311,13 @@ fn fn_sig<F: fmt::Write>(&mut self,
Ok
(())
}
fn
parameterized
<
F
:
fmt
::
Write
>
(
&
mut
self
,
f
:
&
mut
F
,
substs
:
SubstsRef
<
'_
>
,
did
:
DefId
,
projections
:
&
[
ty
::
ProjectionPredicate
<
'_
>
])
->
fmt
::
Result
{
fn
parameterized
<
F
:
fmt
::
Write
>
(
&
mut
self
,
f
:
&
mut
F
,
did
:
DefId
,
substs
:
SubstsRef
<
'tcx
>
,
projections
:
impl
Iterator
<
Item
=
ty
::
ExistentialProjection
<
'tcx
>>
+
Clone
,
)
->
fmt
::
Result
{
let
key
=
self
.tcx
.def_key
(
did
);
let
verbose
=
self
.is_verbose
;
...
...
@@ -411,7 +415,6 @@ fn parameterized<F: fmt::Write>(&mut self,
*
has_default
.unwrap_or
(
&
false
)
};
if
has_default
{
let
substs
=
self
.tcx
.lift
(
&
substs
)
.expect
(
"could not lift for printing"
);
let
types
=
substs
.types
()
.rev
()
.skip
(
child_types
);
for
((
def_id
,
has_default
),
actual
)
in
type_params
.zip
(
types
)
{
if
!
has_default
{
...
...
@@ -428,10 +431,12 @@ fn parameterized<F: fmt::Write>(&mut self,
print!
(
f
,
self
,
write
(
"{}"
,
self
.tcx
.item_path_str
(
path_def_id
)))
?
;
let
fn_trait_kind
=
self
.tcx
.lang_items
()
.fn_trait_kind
(
path_def_id
);
if
!
verbose
&&
fn_trait_kind
.is_some
()
&&
projections
.len
()
==
1
{
let
projection_ty
=
projections
[
0
]
.ty
;
if
!
verbose
&&
fn_trait_kind
.is_some
()
{
if
let
Tuple
(
ref
args
)
=
substs
.type_at
(
1
)
.sty
{
return
self
.fn_sig
(
f
,
args
,
false
,
projection_ty
);
let
mut
projections
=
projections
.clone
();
if
let
(
Some
(
proj
),
None
)
=
(
projections
.next
(),
projections
.next
())
{
return
self
.fn_sig
(
f
,
args
,
false
,
proj
.ty
);
}
}
}
...
...
@@ -490,7 +495,7 @@ fn parameterized<F: fmt::Write>(&mut self,
start_or_continue
(
f
,
"<"
,
", "
)
?
;
print!
(
f
,
self
,
write
(
"{}="
,
self
.tcx
.associated_item
(
projection
.
projection_ty.
item_def_id
)
.ident
),
self
.tcx
.associated_item
(
projection
.item_def_id
)
.ident
),
print_display
(
projection
.ty
))
?
;
}
...
...
@@ -530,7 +535,7 @@ fn parameterized<F: fmt::Write>(&mut self,
Ok
(())
}
fn
in_binder
<
T
,
F
>
(
&
mut
self
,
f
:
&
mut
F
,
value
:
ty
::
Binder
<
T
>
)
->
fmt
::
Result
fn
in_binder
<
T
,
F
>
(
&
mut
self
,
f
:
&
mut
F
,
value
:
&
ty
::
Binder
<
T
>
)
->
fmt
::
Result
where
T
:
Print
<
'tcx
>
+
TypeFoldable
<
'tcx
>
,
F
:
fmt
::
Write
{
fn
name_by_region_index
(
index
:
usize
)
->
InternedString
{
...
...
@@ -547,7 +552,7 @@ fn name_by_region_index(index: usize) -> InternedString {
// the output. We'll probably want to tweak this over time to
// decide just how much information to give.
if
self
.binder_depth
==
0
{
self
.prepare_late_bound_region_info
(
&
value
);
self
.prepare_late_bound_region_info
(
value
);
}
let
mut
empty
=
true
;
...
...
@@ -562,7 +567,7 @@ fn name_by_region_index(index: usize) -> InternedString {
let
old_region_index
=
self
.region_index
;
let
mut
region_index
=
old_region_index
;
let
new_value
=
self
.tcx
.replace_late_bound_regions
(
&
value
,
|
br
|
{
let
new_value
=
self
.tcx
.replace_late_bound_regions
(
value
,
|
br
|
{
let
_
=
start_or_continue
(
f
,
"for<"
,
", "
);
let
br
=
match
br
{
ty
::
BrNamed
(
_
,
name
)
=>
{
...
...
@@ -604,16 +609,15 @@ fn is_name_used(&self, name: &InternedString) -> bool {
}
}
pub
fn
parameterized
<
F
:
fmt
::
Write
>
(
f
:
&
mut
F
,
substs
:
SubstsRef
<
'_
>
,
did
:
DefId
,
projections
:
&
[
ty
::
ProjectionPredicate
<
'_
>
])
->
fmt
::
Result
{
PrintCx
::
with
(|
mut
cx
|
cx
.parameterized
(
f
,
substs
,
did
,
projections
))
pub
fn
parameterized
<
F
:
fmt
::
Write
>
(
f
:
&
mut
F
,
did
:
DefId
,
substs
:
SubstsRef
<
'_
>
)
->
fmt
::
Result
{
PrintCx
::
with
(|
mut
cx
|
{
let
substs
=
cx
.tcx
.lift
(
&
substs
)
.expect
(
"could not lift for printing"
);
cx
.parameterized
(
f
,
did
,
substs
,
iter
::
empty
())
})
}
impl
<
'a
,
'tcx
,
T
:
Print
<
'tcx
>>
Print
<
'tcx
>
for
&
'a
T
{
fn
print
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
_
>
)
->
fmt
::
Result
{
fn
print
<
F
:
fmt
::
Write
>
(
&
self
,
f
:
&
mut
F
,
cx
:
&
mut
PrintCx
<
'_
,
'_
,
'
tcx
>
)
->
fmt
::
Result
{
(
*
self
)
.print
(
f
,
cx
)
}
}
...
...
@@ -628,16 +632,13 @@ fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx<'_, '_, '_>) -> fmt::
let
mut
first
=
true
;
if
let
Some
(
principal
)
=
self
.principal
()
{
let
principal
=
cx
.tcx
.lift
(
&
principal
)
.expect
(
"could not lift for printing"
)
.with_self_ty
(
cx
.tcx
,
dummy_self
);
let
projections
=
self
.projection_bounds
()
.map
(|
p
|
{
cx
.tcx
.lift
(
&
p
)
.expect
(
"could not lift for printing"
)
.with_self_ty
(
cx
.tcx
,
dummy_self
)
})
.collect
::
<
Vec
<
_
>>
();
cx
.parameterized
(
f
,
principal
.substs
,
principal
.def_id
,
&
projections
)
?
;
let
principal
=
principal
.with_self_ty
(
cx
.tcx
,
dummy_self
);
cx
.parameterized
(
f
,
principal
.def_id
,
principal
.substs
,
self
.projection_bounds
(),
)
?
;
first
=
false
;
}
...
...
@@ -755,15 +756,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
define_print!
{
(
'tcx
)
ty
::
ExistentialTraitRef
<
'tcx
>
,
(
self
,
f
,
cx
)
{
display
{
cx
.parameterized
(
f
,
self
.substs
,
self
.def_id
,
&
[])
}
debug
{
let
dummy_self
=
cx
.tcx
.mk_infer
(
ty
::
FreshTy
(
0
));
let
trait_ref
=
*
cx
.tcx
.lift
(
&
ty
::
Binder
::
bind
(
*
self
))
.expect
(
"could not lift for printing"
)
.with_self_ty
(
cx
.tcx
,
dummy_self
)
.skip_binder
();
cx
.parameterized
(
f
,
trait_ref
.substs
,
trait_ref
.def_id
,
&
[])
let
trait_ref
=
*
ty
::
Binder
::
bind
(
*
self
)
.with_self_ty
(
cx
.tcx
,
dummy_self
)
.skip_binder
();
cx
.parameterized
(
f
,
trait_ref
.def_id
,
trait_ref
.substs
,
iter
::
empty
())
}
debug
{
self
.print_display
(
f
,
cx
)
}
}
}
...
...
@@ -957,22 +958,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
define_print!
{
(
'tcx
)
ty
::
GenericPredicates
<
'tcx
>
,
(
self
,
f
,
cx
)
{
debug
{
write!
(
f
,
"GenericPredicates({:?})"
,
self
.predicates
)
}
}
}
define_print!
{
(
'tcx
)
ty
::
InstantiatedPredicates
<
'tcx
>
,
(
self
,
f
,
cx
)
{
debug
{
write!
(
f
,
"InstantiatedPredicates({:?})"
,
self
.predicates
)
}
}
}
define_print!
{
(
'tcx
)
ty
::
FnSig
<
'tcx
>
,
(
self
,
f
,
cx
)
{
display
{
...
...
@@ -1098,8 +1083,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
]
(
self
,
f
,
cx
)
{
display
{
cx
.in_binder
(
f
,
cx
.tcx
.lift
(
self
)
.expect
(
"could not lift for printing"
))
cx
.in_binder
(
f
,
self
)
}
}
}
...
...
@@ -1107,7 +1091,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
define_print!
{
(
'tcx
)
ty
::
TraitRef
<
'tcx
>
,
(
self
,
f
,
cx
)
{
display
{
cx
.parameterized
(
f
,
self
.
substs
,
self
.def_id
,
&
[]
)
cx
.parameterized
(
f
,
self
.
def_id
,
self
.substs
,
iter
::
empty
()
)
}
debug
{
// when printing out the debug representation, we don't need
...
...
@@ -1117,7 +1101,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write
(
"<"
),
print
(
self
.self_ty
()),
write
(
" as "
))
?
;
cx
.parameterized
(
f
,
self
.
substs
,
self
.def_id
,
&
[]
)
?
;
cx
.parameterized
(
f
,
self
.
def_id
,
self
.substs
,
iter
::
empty
()
)
?
;
write!
(
f
,
">"
)
}
}
...
...
@@ -1166,11 +1150,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!
(
f
,
")"
)
}
FnDef
(
def_id
,
substs
)
=>
{
let
substs
=
cx
.tcx
.lift
(
&
substs
)
.expect
(
"could not lift for printing"
);
let
sig
=
cx
.tcx
.fn_sig
(
def_id
)
.subst
(
cx
.tcx
,
substs
);
print!
(
f
,
cx
,
print
(
sig
),
write
(
" {{"
))
?
;
cx
.parameterized
(
f
,
substs
,
def_id
,
&
[]
)
?
;
cx
.parameterized
(
f
,
def_id
,
substs
,
iter
::
empty
()
)
?
;
write!
(
f
,
"}}"
)
}
FnPtr
(
ref
bare_fn
)
=>
{
...
...
@@ -1192,7 +1174,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty
::
BoundTyKind
::
Param
(
p
)
=>
write!
(
f
,
"{}"
,
p
),
}
}
Adt
(
def
,
substs
)
=>
cx
.parameterized
(
f
,
substs
,
def
.did
,
&
[]
),
Adt
(
def
,
substs
)
=>
cx
.parameterized
(
f
,
def
.did
,
substs
,
iter
::
empty
()
),
Dynamic
(
data
,
r
)
=>
{
let
r
=
r
.print_to_string
(
cx
);
if
!
r
.is_empty
()
{
...
...
@@ -1206,7 +1188,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok
(())
}
}
Foreign
(
def_id
)
=>
parameterized
(
f
,
subst
::
InternalSubsts
::
empty
(),
def_id
,
&
[]),
Foreign
(
def_id
)
=>
{
cx
.parameterized
(
f
,
def_id
,
subst
::
InternalSubsts
::
empty
(),
iter
::
empty
())
}
Projection
(
ref
data
)
=>
data
.print
(
f
,
cx
),
UnnormalizedProjection
(
ref
data
)
=>
{
write!
(
f
,
"Unnormalized("
)
?
;
...
...
@@ -1237,8 +1221,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
// by looking up the projections associated with the def_id.
let
substs
=
cx
.tcx
.lift
(
&
substs
)
.expect
(
"could not lift for printing"
);
let
bounds
=
cx
.tcx
.predicates_of
(
def_id
)
.instantiate
(
cx
.tcx
,
substs
);
let
mut
first
=
true
;
...
...
@@ -1305,8 +1287,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
print!
(
f
,
cx
,
write
(
" "
),
print
(
witness
),
write
(
"]"
))
},
GeneratorWitness
(
types
)
=>
{
cx
.in_binder
(
f
,
cx
.tcx
.lift
(
&
types
)
.expect
(
"could not lift for printing"
))
cx
.in_binder
(
f
,
&
types
)
}
Closure
(
did
,
substs
)
=>
{
let
upvar_tys
=
substs
.upvar_tys
(
did
,
cx
.tcx
);
...
...
@@ -1347,8 +1328,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!
(
f
,
" closure_kind_ty={:?} closure_sig_ty={:?}"
,
substs
.closure_kind_ty
(
did
,
tcx
),
substs
.closure_sig_ty
(
did
,
tcx
),
substs
.closure_kind_ty
(
did
,
cx
.
tcx
),
substs
.closure_sig_ty
(
did
,
cx
.
tcx
),
)
?
;
}
...
...
@@ -1435,8 +1416,12 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
define_print!
{
(
'tcx
,
T
:
Print
<
'tcx
>
+
fmt
::
Debug
,
U
:
Print
<
'tcx
>
+
fmt
::
Debug
)
ty
::
OutlivesPredicate
<
T
,
U
>
,
// Similar problem to `Binder<T>`, can't define a generic impl.
define_print_multi!
{
[
(
'tcx
)
ty
::
OutlivesPredicate
<
Ty
<
'tcx
>
,
ty
::
Region
<
'tcx
>>
,
(
'tcx
)
ty
::
OutlivesPredicate
<
ty
::
Region
<
'tcx
>
,
ty
::
Region
<
'tcx
>>
]
(
self
,
f
,
cx
)
{
display
{
print!
(
f
,
cx
,
print
(
self
.0
),
write
(
" : "
),
print
(
self
.1
))
...
...
@@ -1524,7 +1509,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
ty
::
Predicate
::
ConstEvaluatable
(
def_id
,
substs
)
=>
{
write!
(
f
,
"the constant `"
)
?
;
cx
.parameterized
(
f
,
substs
,
def_id
,
&
[]
)
?
;
cx
.parameterized
(
f
,
def_id
,
substs
,
iter
::
empty
()
)
?
;
write!
(
f
,
"` can be evaluated"
)
}
}
...
...
src/librustc_codegen_llvm/intrinsic.rs
浏览文件 @
eb525b09
...
...
@@ -1903,7 +1903,7 @@ enum Style { Float, Int(/* is signed? */ bool), Unsupported }
return_error!
(
"expected element type `{}` of vector type `{}`
\
to be a signed or unsigned integer type"
,
arg_tys
[
0
]
.simd_type
(
tcx
)
.sty
,
arg_tys
[
0
]
arg_tys
[
0
]
.simd_type
(
tcx
),
arg_tys
[
0
]
);
}
};
...
...
@@ -1955,7 +1955,7 @@ fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, boo
// Returns the width of a float Ty
// Returns None if the type is not a float
fn
float_type_width
(
ty
:
Ty
)
->
Option
<
u64
>
{
fn
float_type_width
(
ty
:
Ty
<
'_
>
)
->
Option
<
u64
>
{
match
ty
.sty
{
ty
::
Float
(
t
)
=>
Some
(
t
.bit_width
()
as
u64
),
_
=>
None
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录