Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
196b2e0d
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,发现更多精彩内容 >>
提交
196b2e0d
编写于
5月 16, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: don't call Kind::from directly, use .into() instead.
上级
e3df729c
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
22 addition
and
44 deletion
+22
-44
src/librustc/infer/canonical.rs
src/librustc/infer/canonical.rs
+5
-5
src/librustc/traits/select.rs
src/librustc/traits/select.rs
+2
-2
src/librustc/ty/subst.rs
src/librustc/ty/subst.rs
+4
-25
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+1
-2
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/monomorphize/collector.rs
+2
-2
src/librustc_mir/shim.rs
src/librustc_mir/shim.rs
+2
-2
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+4
-4
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+2
-2
未找到文件。
src/librustc/infer/canonical.rs
浏览文件 @
196b2e0d
...
...
@@ -256,11 +256,11 @@ pub fn fresh_inference_var_for_canonical_var(
CanonicalTyVarKind
::
Float
=>
self
.tcx
.mk_float_var
(
self
.next_float_var_id
()),
};
Kind
::
from
(
ty
)
ty
.into
(
)
}
CanonicalVarKind
::
Region
=>
{
Kind
::
from
(
self
.next_region_var
(
RegionVariableOrigin
::
MiscVariable
(
span
))
)
self
.next_region_var
(
RegionVariableOrigin
::
MiscVariable
(
span
))
.into
(
)
}
}
}
...
...
@@ -555,7 +555,7 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
opportunistically resolved to {:?}"
,
vid
,
r
);
let
cvar
=
self
.canonical_var
(
info
,
Kind
::
from
(
r
));
let
cvar
=
self
.canonical_var
(
info
,
r
.into
(
));
self
.tcx
()
.mk_region
(
ty
::
ReCanonical
(
cvar
))
}
...
...
@@ -570,7 +570,7 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
let
info
=
CanonicalVarInfo
{
kind
:
CanonicalVarKind
::
Region
,
};
let
cvar
=
self
.canonical_var
(
info
,
Kind
::
from
(
r
));
let
cvar
=
self
.canonical_var
(
info
,
r
.into
(
));
self
.tcx
()
.mk_region
(
ty
::
ReCanonical
(
cvar
))
}
else
{
r
...
...
@@ -750,7 +750,7 @@ fn canonicalize_ty_var(&mut self, ty_kind: CanonicalTyVarKind, ty_var: Ty<'tcx>)
let
info
=
CanonicalVarInfo
{
kind
:
CanonicalVarKind
::
Ty
(
ty_kind
),
};
let
cvar
=
self
.canonical_var
(
info
,
Kind
::
from
(
ty_var
));
let
cvar
=
self
.canonical_var
(
info
,
ty_var
.into
(
));
self
.tcx
()
.mk_infer
(
ty
::
InferTy
::
CanonicalTy
(
cvar
))
}
}
...
...
src/librustc/traits/select.rs
浏览文件 @
196b2e0d
...
...
@@ -37,7 +37,7 @@
use
hir
::
def_id
::
DefId
;
use
infer
;
use
infer
::{
InferCtxt
,
InferOk
,
TypeFreshener
};
use
ty
::
subst
::{
Kind
,
Subst
,
Substs
};
use
ty
::
subst
::{
Subst
,
Substs
};
use
ty
::{
self
,
ToPredicate
,
ToPolyTraitRef
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
ty
::
fast_reject
;
use
ty
::
relate
::
TypeRelation
;
...
...
@@ -3019,7 +3019,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
// with a potentially unsized trailing field.
let
params
=
substs_a
.iter
()
.enumerate
()
.map
(|(
i
,
&
k
)|
{
if
ty_params
.contains
(
i
)
{
Kind
::
from
(
tcx
.types.err
)
tcx
.types.err
.into
(
)
}
else
{
k
}
...
...
src/librustc/ty/subst.rs
浏览文件 @
196b2e0d
...
...
@@ -11,7 +11,7 @@
// Type substitutions.
use
hir
::
def_id
::
DefId
;
use
ty
::{
self
,
Lift
,
Slice
,
Region
,
Ty
,
TyCtxt
};
use
ty
::{
self
,
Lift
,
Slice
,
Ty
,
TyCtxt
};
use
ty
::
fold
::{
TypeFoldable
,
TypeFolder
,
TypeVisitor
};
use
serialize
::{
self
,
Encodable
,
Encoder
,
Decodable
,
Decoder
};
...
...
@@ -39,7 +39,7 @@ pub struct Kind<'tcx> {
const
TYPE_TAG
:
usize
=
0b00
;
const
REGION_TAG
:
usize
=
0b01
;
#[derive(Debug)]
#[derive(Debug
,
RustcEncodable,
RustcDecodable
)]
pub
enum
UnpackedKind
<
'tcx
>
{
Lifetime
(
ty
::
Region
<
'tcx
>
),
Type
(
Ty
<
'tcx
>
),
...
...
@@ -142,34 +142,13 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
impl
<
'tcx
>
Encodable
for
Kind
<
'tcx
>
{
fn
encode
<
E
:
Encoder
>
(
&
self
,
e
:
&
mut
E
)
->
Result
<
(),
E
::
Error
>
{
e
.emit_enum
(
"Kind"
,
|
e
|
{
match
self
.unpack
()
{
UnpackedKind
::
Lifetime
(
lt
)
=>
{
e
.emit_enum_variant
(
"Region"
,
REGION_TAG
,
1
,
|
e
|
{
e
.emit_enum_variant_arg
(
0
,
|
e
|
lt
.encode
(
e
))
})
}
UnpackedKind
::
Type
(
ty
)
=>
{
e
.emit_enum_variant
(
"Ty"
,
TYPE_TAG
,
1
,
|
e
|
{
e
.emit_enum_variant_arg
(
0
,
|
e
|
ty
.encode
(
e
))
})
}
}
})
self
.unpack
()
.encode
(
e
)
}
}
impl
<
'tcx
>
Decodable
for
Kind
<
'tcx
>
{
fn
decode
<
D
:
Decoder
>
(
d
:
&
mut
D
)
->
Result
<
Kind
<
'tcx
>
,
D
::
Error
>
{
d
.read_enum
(
"Kind"
,
|
d
|
{
d
.read_enum_variant
(
&
[
"Ty"
,
"Region"
],
|
d
,
tag
|
{
match
tag
{
TYPE_TAG
=>
Ty
::
decode
(
d
)
.map
(
Kind
::
from
),
REGION_TAG
=>
Region
::
decode
(
d
)
.map
(
Kind
::
from
),
_
=>
Err
(
d
.error
(
"invalid Kind tag"
))
}
})
})
Ok
(
UnpackedKind
::
decode
(
d
)
?
.pack
())
}
}
...
...
src/librustc_codegen_llvm/base.rs
浏览文件 @
196b2e0d
...
...
@@ -43,7 +43,6 @@
use
rustc
::
ty
::
layout
::{
self
,
Align
,
TyLayout
,
LayoutOf
};
use
rustc
::
ty
::
maps
::
Providers
;
use
rustc
::
dep_graph
::{
DepNode
,
DepConstructor
};
use
rustc
::
ty
::
subst
::
Kind
;
use
rustc
::
middle
::
cstore
::{
self
,
LinkMeta
,
LinkagePreference
};
use
rustc
::
middle
::
exported_symbols
;
use
rustc
::
util
::
common
::{
time
,
print_time_passes_entry
};
...
...
@@ -595,7 +594,7 @@ fn create_entry_fn<'cx>(cx: &'cx CodegenCx,
let
start_fn
=
callee
::
resolve_and_get_fn
(
cx
,
start_def_id
,
cx
.tcx
.intern_substs
(
&
[
Kind
::
from
(
main_ret_ty
)]),
cx
.tcx
.intern_substs
(
&
[
main_ret_ty
.into
(
)]),
);
(
start_fn
,
vec!
[
bx
.pointercast
(
rust_main
,
Type
::
i8p
(
cx
)
.ptr_to
()),
arg_argc
,
arg_argv
])
...
...
src/librustc_mir/monomorphize/collector.rs
浏览文件 @
196b2e0d
...
...
@@ -196,7 +196,7 @@
use
rustc
::
middle
::
const_val
::
ConstVal
;
use
rustc
::
mir
::
interpret
::{
AllocId
,
ConstValue
};
use
rustc
::
middle
::
lang_items
::{
ExchangeMallocFnLangItem
,
StartFnLangItem
};
use
rustc
::
ty
::
subst
::
{
Substs
,
Kind
}
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
TypeFoldable
,
Ty
,
TyCtxt
,
GenericParamDefKind
};
use
rustc
::
ty
::
adjustment
::
CustomCoerceUnsized
;
use
rustc
::
session
::
config
;
...
...
@@ -1067,7 +1067,7 @@ fn push_extra_entry_roots(&mut self) {
self
.tcx
,
ty
::
ParamEnv
::
reveal_all
(),
start_def_id
,
self
.tcx
.intern_substs
(
&
[
Kind
::
from
(
main_ret_ty
)])
self
.tcx
.intern_substs
(
&
[
main_ret_ty
.into
(
)])
)
.unwrap
();
self
.output
.push
(
create_fn_mono_item
(
start_instance
));
...
...
src/librustc_mir/shim.rs
浏览文件 @
196b2e0d
...
...
@@ -13,7 +13,7 @@
use
rustc
::
infer
;
use
rustc
::
mir
::
*
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
GenericParamDefKind
};
use
rustc
::
ty
::
subst
::{
Kind
,
Subst
,
Substs
};
use
rustc
::
ty
::
subst
::{
Subst
,
Substs
};
use
rustc
::
ty
::
maps
::
Providers
;
use
rustc_data_structures
::
indexed_vec
::{
IndexVec
,
Idx
};
...
...
@@ -170,7 +170,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
let
substs
=
if
let
Some
(
ty
)
=
ty
{
tcx
.mk_substs
(
iter
::
once
(
Kind
::
from
(
ty
)))
tcx
.mk_substs
(
iter
::
once
(
ty
.into
(
)))
}
else
{
Substs
::
identity_for_item
(
tcx
,
def_id
)
};
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
196b2e0d
...
...
@@ -18,9 +18,9 @@
use
hir
::
def_id
::
DefId
;
use
middle
::
resolve_lifetime
as
rl
;
use
namespace
::
Namespace
;
use
rustc
::
ty
::
subst
::{
Kind
,
UnpackedKind
,
Subst
,
Substs
};
use
rustc
::
ty
::
subst
::{
UnpackedKind
,
Subst
,
Substs
};
use
rustc
::
traits
;
use
rustc
::
ty
::{
self
,
RegionKind
,
Ty
,
TyCtxt
,
ToPredicate
,
TypeFoldable
};
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
ToPredicate
,
TypeFoldable
};
use
rustc
::
ty
::
GenericParamDefKind
;
use
rustc
::
ty
::
wf
::
object_region_bounds
;
use
rustc_target
::
spec
::
abi
;
...
...
@@ -1164,7 +1164,7 @@ pub fn impl_trait_ty_to_ty(&self, def_id: DefId, lifetimes: &[hir::Lifetime]) ->
// Replace all lifetimes with 'static
for
subst
in
&
mut
substs
{
if
let
UnpackedKind
::
Lifetime
(
_
)
=
subst
.unpack
()
{
*
subst
=
Kind
::
from
(
&
RegionKind
::
ReStatic
);
*
subst
=
tcx
.types.re_static
.into
(
);
}
}
debug!
(
"impl_trait_ty_to_ty: substs from parent = {:?}"
,
substs
);
...
...
@@ -1173,7 +1173,7 @@ pub fn impl_trait_ty_to_ty(&self, def_id: DefId, lifetimes: &[hir::Lifetime]) ->
// Fill in our own generics with the resolved lifetimes
assert_eq!
(
lifetimes
.len
(),
generics
.params
.len
());
substs
.extend
(
lifetimes
.iter
()
.map
(|
lt
|
Kind
::
from
(
self
.ast_region_to_region
(
lt
,
None
)
)));
substs
.extend
(
lifetimes
.iter
()
.map
(|
lt
|
self
.ast_region_to_region
(
lt
,
None
)
.into
(
)));
debug!
(
"impl_trait_ty_to_ty: final substs = {:?}"
,
substs
);
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
196b2e0d
...
...
@@ -94,7 +94,7 @@
use
rustc
::
infer
::
type_variable
::{
TypeVariableOrigin
};
use
rustc
::
middle
::
region
;
use
rustc
::
mir
::
interpret
::{
GlobalId
};
use
rustc
::
ty
::
subst
::{
Kind
,
UnpackedKind
,
Subst
,
Substs
};
use
rustc
::
ty
::
subst
::{
UnpackedKind
,
Subst
,
Substs
};
use
rustc
::
traits
::{
self
,
ObligationCause
,
ObligationCauseCode
,
TraitEngine
};
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
GenericParamDefKind
,
Visibility
,
ToPredicate
};
use
rustc
::
ty
::
adjustment
::{
Adjust
,
Adjustment
,
AllowTwoPhase
,
AutoBorrow
,
AutoBorrowMutability
};
...
...
@@ -4754,7 +4754,7 @@ pub fn instantiate_value_path(&self,
if
let
GenericParamDefKind
::
Type
(
_
)
=
param
.kind
{
// Handle Self first, so we can adjust the index to match the AST.
if
has_self
&&
i
==
0
{
return
opt_self_ty
.map
(|
ty
|
Kind
::
from
(
ty
))
.unwrap_or_else
(||
{
return
opt_self_ty
.map
(|
ty
|
ty
.into
(
))
.unwrap_or_else
(||
{
self
.var_for_def
(
span
,
param
)
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录