Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2eefc9db
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,发现更多精彩内容 >>
提交
2eefc9db
编写于
10月 02, 2017
作者:
A
Alex Burka
提交者:
Alex Burka
12月 14, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add trait aliases to HIR
上级
1b6ad1e6
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
59 addition
and
8 deletion
+59
-8
src/librustc/hir/def.rs
src/librustc/hir/def.rs
+4
-1
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+5
-0
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+4
-2
src/librustc/hir/map/def_collector.rs
src/librustc/hir/map/def_collector.rs
+2
-1
src/librustc/hir/map/mod.rs
src/librustc/hir/map/mod.rs
+1
-0
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+3
-0
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+21
-0
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+2
-0
src/librustc/middle/reachable.rs
src/librustc/middle/reachable.rs
+1
-1
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+1
-0
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+3
-1
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+11
-2
src/librustc_trans_utils/collector.rs
src/librustc_trans_utils/collector.rs
+1
-0
未找到文件。
src/librustc/hir/def.rs
浏览文件 @
2eefc9db
...
...
@@ -37,6 +37,7 @@ pub enum Def {
Trait
(
DefId
),
TyAlias
(
DefId
),
TyForeign
(
DefId
),
TraitAlias
(
DefId
),
AssociatedTy
(
DefId
),
PrimTy
(
hir
::
PrimTy
),
TyParam
(
DefId
),
...
...
@@ -155,7 +156,8 @@ impl Def {
pub
fn
def_id
(
&
self
)
->
DefId
{
match
*
self
{
Def
::
Fn
(
id
)
|
Def
::
Mod
(
id
)
|
Def
::
Static
(
id
,
_
)
|
Def
::
Variant
(
id
)
|
Def
::
VariantCtor
(
id
,
..
)
|
Def
::
Enum
(
id
)
|
Def
::
TyAlias
(
id
)
|
Def
::
Variant
(
id
)
|
Def
::
VariantCtor
(
id
,
..
)
|
Def
::
Enum
(
id
)
|
Def
::
TyAlias
(
id
)
|
Def
::
TraitAlias
(
id
)
|
Def
::
AssociatedTy
(
id
)
|
Def
::
TyParam
(
id
)
|
Def
::
Struct
(
id
)
|
Def
::
StructCtor
(
id
,
..
)
|
Def
::
Union
(
id
)
|
Def
::
Trait
(
id
)
|
Def
::
Method
(
id
)
|
Def
::
Const
(
id
)
|
Def
::
AssociatedConst
(
id
)
|
Def
::
Macro
(
id
,
..
)
|
...
...
@@ -186,6 +188,7 @@ pub fn kind_name(&self) -> &'static str {
Def
::
VariantCtor
(
..
,
CtorKind
::
Fictive
)
=>
"struct variant"
,
Def
::
Enum
(
..
)
=>
"enum"
,
Def
::
TyAlias
(
..
)
=>
"type alias"
,
Def
::
TraitAlias
(
..
)
=>
"trait alias"
,
Def
::
AssociatedTy
(
..
)
=>
"associated type"
,
Def
::
Struct
(
..
)
=>
"struct"
,
Def
::
StructCtor
(
..
,
CtorKind
::
Fn
)
=>
"tuple struct"
,
...
...
src/librustc/hir/intravisit.rs
浏览文件 @
2eefc9db
...
...
@@ -526,6 +526,11 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
walk_list!
(
visitor
,
visit_trait_item_ref
,
trait_item_refs
);
}
ItemTraitAlias
(
ref
generics
,
ref
bounds
)
=>
{
visitor
.visit_id
(
item
.id
);
visitor
.visit_generics
(
generics
);
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
}
}
walk_list!
(
visitor
,
visit_attribute
,
&
item
.attrs
);
}
...
...
src/librustc/hir/lowering.rs
浏览文件 @
2eefc9db
...
...
@@ -1924,9 +1924,11 @@ fn lower_item_kind(&mut self,
bounds
,
items
)
}
ItemKind
::
MacroDef
(
..
)
|
ItemKind
::
Mac
(
..
)
=>
{
panic!
(
"Shouldn't still be around"
)
ItemKind
::
TraitAlias
(
ref
generics
,
ref
bounds
)
=>
{
hir
::
ItemTraitAlias
(
self
.lower_generics
(
generics
),
self
.lower_bounds
(
bounds
,
ImplTraitContext
::
Disallowed
))
}
ItemKind
::
MacroDef
(
..
)
|
ItemKind
::
Mac
(
..
)
=>
panic!
(
"Shouldn't still be around"
),
}
// [1] `defaultness.has_value()` is never called for an `impl`, always `true` in order to
...
...
src/librustc/hir/map/def_collector.rs
浏览文件 @
2eefc9db
...
...
@@ -106,7 +106,8 @@ fn visit_item(&mut self, i: &'a Item) {
let
def_data
=
match
i
.node
{
ItemKind
::
AutoImpl
(
..
)
|
ItemKind
::
Impl
(
..
)
=>
DefPathData
::
Impl
,
ItemKind
::
Enum
(
..
)
|
ItemKind
::
Struct
(
..
)
|
ItemKind
::
Union
(
..
)
|
ItemKind
::
Trait
(
..
)
|
ItemKind
::
Enum
(
..
)
|
ItemKind
::
Struct
(
..
)
|
ItemKind
::
Union
(
..
)
|
ItemKind
::
Trait
(
..
)
|
ItemKind
::
TraitAlias
(
..
)
|
ItemKind
::
ExternCrate
(
..
)
|
ItemKind
::
ForeignMod
(
..
)
|
ItemKind
::
Ty
(
..
)
=>
DefPathData
::
TypeNs
(
i
.ident.name
.as_str
()),
ItemKind
::
Mod
(
..
)
if
i
.ident
==
keywords
::
Invalid
.ident
()
=>
{
...
...
src/librustc/hir/map/mod.rs
浏览文件 @
2eefc9db
...
...
@@ -1185,6 +1185,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
ItemStruct
(
..
)
=>
"struct"
,
ItemUnion
(
..
)
=>
"union"
,
ItemTrait
(
..
)
=>
"trait"
,
ItemTraitAlias
(
..
)
=>
"trait alias"
,
ItemImpl
(
..
)
=>
"impl"
,
ItemAutoImpl
(
..
)
=>
"default impl"
,
};
...
...
src/librustc/hir/mod.rs
浏览文件 @
2eefc9db
...
...
@@ -1888,6 +1888,8 @@ pub enum Item_ {
ItemUnion
(
VariantData
,
Generics
),
/// Represents a Trait Declaration
ItemTrait
(
IsAuto
,
Unsafety
,
Generics
,
TyParamBounds
,
HirVec
<
TraitItemRef
>
),
/// Represents a Trait Alias Declaration
ItemTraitAlias
(
Generics
,
TyParamBounds
),
/// Auto trait implementations
///
...
...
@@ -1919,6 +1921,7 @@ pub fn descriptive_variant(&self) -> &str {
ItemStruct
(
..
)
=>
"struct"
,
ItemUnion
(
..
)
=>
"union"
,
ItemTrait
(
..
)
=>
"trait"
,
ItemTraitAlias
(
..
)
=>
"trait alias"
,
ItemImpl
(
..
)
|
ItemAutoImpl
(
..
)
=>
"item"
,
}
...
...
src/librustc/hir/print.rs
浏览文件 @
2eefc9db
...
...
@@ -747,6 +747,27 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
}
self
.bclose
(
item
.span
)
?
;
}
hir
::
ItemTraitAlias
(
ref
generics
,
ref
bounds
)
=>
{
self
.head
(
""
)
?
;
self
.print_visibility
(
&
item
.vis
)
?
;
self
.word_nbsp
(
"trait"
)
?
;
self
.print_name
(
item
.name
)
?
;
self
.print_generics
(
generics
)
?
;
let
mut
real_bounds
=
Vec
::
with_capacity
(
bounds
.len
());
// FIXME(durka) this seems to be some quite outdated syntax
for
b
in
bounds
.iter
()
{
if
let
TraitTyParamBound
(
ref
ptr
,
hir
::
TraitBoundModifier
::
Maybe
)
=
*
b
{
self
.s
.space
()
?
;
self
.word_space
(
"for ?"
)
?
;
self
.print_trait_ref
(
&
ptr
.trait_ref
)
?
;
}
else
{
real_bounds
.push
(
b
.clone
());
}
}
self
.print_bounds
(
" = "
,
&
real_bounds
[
..
])
?
;
self
.print_where_clause
(
&
generics
.where_clause
)
?
;
self
.s
.word
(
";"
)
?
;
}
}
self
.ann
.post
(
self
,
NodeItem
(
item
))
}
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
2eefc9db
...
...
@@ -848,6 +848,7 @@ fn hash_stable<W: StableHasherResult>(&self,
ItemStruct
(
variant_data
,
generics
),
ItemUnion
(
variant_data
,
generics
),
ItemTrait
(
is_auto
,
unsafety
,
generics
,
bounds
,
item_refs
),
ItemTraitAlias
(
generics
,
bounds
),
ItemAutoImpl
(
unsafety
,
trait_ref
),
ItemImpl
(
unsafety
,
impl_polarity
,
impl_defaultness
,
generics
,
trait_ref
,
ty
,
impl_item_refs
)
});
...
...
@@ -1004,6 +1005,7 @@ fn hash_stable<W: StableHasherResult>(&self,
Variant
(
def_id
),
Trait
(
def_id
),
TyAlias
(
def_id
),
TraitAlias
(
def_id
),
AssociatedTy
(
def_id
),
PrimTy
(
prim_ty
),
TyParam
(
def_id
),
...
...
src/librustc/middle/reachable.rs
浏览文件 @
2eefc9db
...
...
@@ -268,7 +268,7 @@ fn propagate_node(&mut self, node: &hir_map::Node<'tcx>,
hir
::
ItemExternCrate
(
_
)
|
hir
::
ItemUse
(
..
)
|
hir
::
ItemTy
(
..
)
|
hir
::
ItemStatic
(
..
)
|
hir
::
ItemMod
(
..
)
|
hir
::
ItemForeignMod
(
..
)
|
hir
::
ItemImpl
(
..
)
|
hir
::
ItemTrait
(
..
)
|
hir
::
ItemImpl
(
..
)
|
hir
::
ItemTrait
(
..
)
|
hir
::
ItemTraitAlias
(
..
)
|
hir
::
ItemStruct
(
..
)
|
hir
::
ItemEnum
(
..
)
|
hir
::
ItemUnion
(
..
)
|
hir
::
ItemAutoImpl
(
..
)
|
hir
::
ItemGlobalAsm
(
..
)
=>
{}
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
2eefc9db
...
...
@@ -469,6 +469,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
hir
::
ItemStruct
(
_
,
ref
generics
)
|
hir
::
ItemUnion
(
_
,
ref
generics
)
|
hir
::
ItemTrait
(
_
,
_
,
ref
generics
,
..
)
|
hir
::
ItemTraitAlias
(
ref
generics
,
..
)
|
hir
::
ItemImpl
(
_
,
_
,
_
,
ref
generics
,
..
)
=>
{
// These kinds of items have only early bound lifetime parameters.
let
mut
index
=
if
let
hir
::
ItemTrait
(
..
)
=
item
.node
{
...
...
src/librustc_metadata/encoder.rs
浏览文件 @
2eefc9db
...
...
@@ -979,6 +979,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
EntryKind
::
Trait
(
self
.lazy
(
&
data
))
}
hir
::
ItemExternCrate
(
_
)
|
hir
::
ItemTraitAlias
(
..
)
|
hir
::
ItemUse
(
..
)
=>
bug!
(
"cannot encode info for item {:?}"
,
item
),
};
...
...
@@ -1526,7 +1527,8 @@ fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
hir
::
ItemExternCrate
(
..
)
|
hir
::
ItemUse
(
..
)
|
hir
::
ItemAutoImpl
(
..
)
|
hir
::
ItemTy
(
..
)
=>
{
hir
::
ItemTy
(
..
)
|
hir
::
ItemTraitAlias
(
..
)
=>
{
// no sub-item recording needed in these cases
}
hir
::
ItemEnum
(
..
)
=>
{
...
...
src/librustc_privacy/lib.rs
浏览文件 @
2eefc9db
...
...
@@ -158,7 +158,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
// Other `pub` items inherit levels from parents
hir
::
ItemConst
(
..
)
|
hir
::
ItemEnum
(
..
)
|
hir
::
ItemExternCrate
(
..
)
|
hir
::
ItemGlobalAsm
(
..
)
|
hir
::
ItemFn
(
..
)
|
hir
::
ItemMod
(
..
)
|
hir
::
ItemStatic
(
..
)
|
hir
::
ItemStruct
(
..
)
|
hir
::
ItemTrait
(
..
)
|
hir
::
ItemStatic
(
..
)
|
hir
::
ItemStruct
(
..
)
|
hir
::
ItemTrait
(
..
)
|
hir
::
ItemTraitAlias
(
..
)
|
hir
::
ItemTy
(
..
)
|
hir
::
ItemUnion
(
..
)
|
hir
::
ItemUse
(
..
)
=>
{
if
item
.vis
==
hir
::
Public
{
self
.prev_level
}
else
{
None
}
}
...
...
@@ -212,7 +213,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
}
}
hir
::
ItemUse
(
..
)
|
hir
::
ItemStatic
(
..
)
|
hir
::
ItemConst
(
..
)
|
hir
::
ItemGlobalAsm
(
..
)
|
hir
::
ItemTy
(
..
)
|
hir
::
ItemMod
(
..
)
|
hir
::
ItemGlobalAsm
(
..
)
|
hir
::
ItemTy
(
..
)
|
hir
::
ItemMod
(
..
)
|
hir
::
ItemTraitAlias
(
..
)
|
hir
::
ItemFn
(
..
)
|
hir
::
ItemExternCrate
(
..
)
|
hir
::
ItemAutoImpl
(
..
)
=>
{}
}
...
...
@@ -252,6 +253,11 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
}
}
}
hir
::
ItemTraitAlias
(
..
)
=>
{
if
item_level
.is_some
()
{
self
.reach
(
item
.id
)
.generics
()
.predicates
();
}
}
// Visit everything except for private impl items
hir
::
ItemImpl
(
..
,
ref
trait_ref
,
_
,
ref
impl_item_refs
)
=>
{
if
item_level
.is_some
()
{
...
...
@@ -1498,6 +1504,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
}
}
}
hir
::
ItemTraitAlias
(
..
)
=>
{
self
.check
(
item
.id
,
item_visibility
)
.generics
()
.predicates
();
}
hir
::
ItemEnum
(
ref
def
,
_
)
=>
{
self
.check
(
item
.id
,
item_visibility
)
.generics
()
.predicates
();
...
...
src/librustc_trans_utils/collector.rs
浏览文件 @
2eefc9db
...
...
@@ -894,6 +894,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
hir
::
ItemTy
(
..
)
|
hir
::
ItemAutoImpl
(
..
)
|
hir
::
ItemTrait
(
..
)
|
hir
::
ItemTraitAlias
(
..
)
|
hir
::
ItemMod
(
..
)
=>
{
// Nothing to do, just keep recursing...
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录