Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a636a83c
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,发现更多精彩内容 >>
提交
a636a83c
编写于
9月 20, 2015
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Names in path fragments and MacroDef
上级
64fb709f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
40 addition
and
39 deletion
+40
-39
src/librustc/metadata/encoder.rs
src/librustc/metadata/encoder.rs
+1
-1
src/librustc_front/hir.rs
src/librustc_front/hir.rs
+7
-7
src/librustc_front/lowering.rs
src/librustc_front/lowering.rs
+9
-6
src/librustc_front/print/pprust.rs
src/librustc_front/print/pprust.rs
+4
-5
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+3
-4
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+6
-6
src/librustdoc/clean/inline.rs
src/librustdoc/clean/inline.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+3
-3
src/librustdoc/doctree.rs
src/librustdoc/doctree.rs
+2
-2
src/librustdoc/visit_ast.rs
src/librustdoc/visit_ast.rs
+4
-4
未找到文件。
src/librustc/metadata/encoder.rs
浏览文件 @
a636a83c
...
...
@@ -1787,7 +1787,7 @@ fn encode_macro_defs(rbml_w: &mut Encoder,
for
def
in
&
krate
.exported_macros
{
rbml_w
.start_tag
(
tag_macro_def
);
encode_name
(
rbml_w
,
def
.
ident.
name
);
encode_name
(
rbml_w
,
def
.name
);
encode_attributes
(
rbml_w
,
&
def
.attrs
);
rbml_w
.wr_tagged_str
(
tag_macro_def_body
,
...
...
src/librustc_front/hir.rs
浏览文件 @
a636a83c
...
...
@@ -333,11 +333,11 @@ pub struct Crate {
/// Not parsed directly, but created on macro import or `macro_rules!` expansion.
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
struct
MacroDef
{
pub
ident
:
Ident
,
pub
name
:
Name
,
pub
attrs
:
Vec
<
Attribute
>
,
pub
id
:
NodeId
,
pub
span
:
Span
,
pub
imported_from
:
Option
<
Ident
>
,
pub
imported_from
:
Option
<
Name
>
,
pub
export
:
bool
,
pub
use_locally
:
bool
,
pub
allow_internal_unstable
:
bool
,
...
...
@@ -1039,14 +1039,14 @@ pub struct Variant_ {
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug,
Copy)]
pub
enum
PathListItem_
{
PathListIdent
{
name
:
Ident
,
name
:
Name
,
/// renamed in list, eg `use foo::{bar as baz};`
rename
:
Option
<
Ident
>
,
rename
:
Option
<
Name
>
,
id
:
NodeId
},
PathListMod
{
/// renamed in list, eg `use foo::{self as baz};`
rename
:
Option
<
Ident
>
,
rename
:
Option
<
Name
>
,
id
:
NodeId
}
}
...
...
@@ -1058,7 +1058,7 @@ pub fn id(&self) -> NodeId {
}
}
pub
fn
rename
(
&
self
)
->
Option
<
Ident
>
{
pub
fn
rename
(
&
self
)
->
Option
<
Name
>
{
match
*
self
{
PathListIdent
{
rename
,
..
}
|
PathListMod
{
rename
,
..
}
=>
rename
}
...
...
@@ -1077,7 +1077,7 @@ pub enum ViewPath_ {
/// or just
///
/// `foo::bar::baz` (with `as baz` implicitly on the right)
ViewPathSimple
(
Ident
,
Path
),
ViewPathSimple
(
Name
,
Path
),
/// `foo::bar::*`
ViewPathGlob
(
Path
),
...
...
src/librustc_front/lowering.rs
浏览文件 @
a636a83c
...
...
@@ -22,7 +22,7 @@ pub fn lower_view_path(view_path: &ViewPath) -> P<hir::ViewPath> {
P
(
Spanned
{
node
:
match
view_path
.node
{
ViewPathSimple
(
ident
,
ref
path
)
=>
{
hir
::
ViewPathSimple
(
ident
,
lower_path
(
path
))
hir
::
ViewPathSimple
(
ident
.name
,
lower_path
(
path
))
}
ViewPathGlob
(
ref
path
)
=>
{
hir
::
ViewPathGlob
(
lower_path
(
path
))
...
...
@@ -35,11 +35,14 @@ pub fn lower_view_path(view_path: &ViewPath) -> P<hir::ViewPath> {
PathListIdent
{
id
,
name
,
rename
}
=>
hir
::
PathListIdent
{
id
:
id
,
name
:
name
,
rename
:
rename
.
clone
(
),
name
:
name
.name
,
rename
:
rename
.
map
(|
x
|
x
.name
),
},
PathListMod
{
id
,
rename
}
=>
hir
::
PathListMod
{
id
:
id
,
rename
:
rename
.clone
()
}
hir
::
PathListMod
{
id
:
id
,
rename
:
rename
.map
(|
x
|
x
.name
)
}
},
span
:
path_list_ident
.span
}
...
...
@@ -526,11 +529,11 @@ pub fn lower_crate(c: &Crate) -> hir::Crate {
pub
fn
lower_macro_def
(
m
:
&
MacroDef
)
->
hir
::
MacroDef
{
hir
::
MacroDef
{
ident
:
m
.ident
,
name
:
m
.ident.name
,
attrs
:
m
.attrs
.clone
(),
id
:
m
.id
,
span
:
m
.span
,
imported_from
:
m
.imported_from
,
imported_from
:
m
.imported_from
.map
(|
x
|
x
.name
)
,
export
:
m
.export
,
use_locally
:
m
.use_locally
,
allow_internal_unstable
:
m
.allow_internal_unstable
,
...
...
src/librustc_front/print/pprust.rs
浏览文件 @
a636a83c
...
...
@@ -2174,15 +2174,14 @@ pub fn print_where_clause(&mut self, where_clause: &hir::WhereClause)
pub
fn
print_view_path
(
&
mut
self
,
vp
:
&
hir
::
ViewPath
)
->
io
::
Result
<
()
>
{
match
vp
.node
{
hir
::
ViewPathSimple
(
ident
,
ref
path
)
=>
{
hir
::
ViewPathSimple
(
name
,
ref
path
)
=>
{
try!
(
self
.print_path
(
path
,
false
,
0
));
// FIXME(#6993) can't compare identifiers directly here
if
path
.segments
.last
()
.unwrap
()
.identifier.name
!=
ident
.name
{
if
path
.segments
.last
()
.unwrap
()
.identifier.name
!=
name
{
try!
(
space
(
&
mut
self
.s
));
try!
(
self
.word_space
(
"as"
));
try!
(
self
.print_
ident
(
ident
));
try!
(
self
.print_
name
(
name
));
}
Ok
(())
...
...
@@ -2203,7 +2202,7 @@ pub fn print_view_path(&mut self, vp: &hir::ViewPath) -> io::Result<()> {
try!
(
self
.commasep
(
Inconsistent
,
&
idents
[
..
],
|
s
,
w
|
{
match
w
.node
{
hir
::
PathListIdent
{
name
,
..
}
=>
{
s
.print_
ident
(
name
)
s
.print_
name
(
name
)
},
hir
::
PathListMod
{
..
}
=>
{
word
(
&
mut
s
.s
,
"self"
)
...
...
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
a636a83c
...
...
@@ -312,8 +312,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: &Rc<Module>) ->
ResolutionError
::
SelfImportsOnlyAllowedWithin
);
}
let
subclass
=
SingleImport
(
binding
.name
,
source_name
);
let
subclass
=
SingleImport
(
binding
,
source_name
);
self
.build_import_directive
(
&**
parent
,
module_path
,
subclass
,
...
...
@@ -343,7 +342,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: &Rc<Module>) ->
for
source_item
in
source_items
{
let
(
module_path
,
name
,
rename
)
=
match
source_item
.node
{
PathListIdent
{
name
,
rename
,
..
}
=>
(
module_path
.clone
(),
name
.name
,
rename
.unwrap_or
(
name
)
.name
),
(
module_path
.clone
(),
name
,
rename
.unwrap_or
(
name
)
),
PathListMod
{
rename
,
..
}
=>
{
let
name
=
match
module_path
.last
()
{
Some
(
name
)
=>
*
name
,
...
...
@@ -358,7 +357,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: &Rc<Module>) ->
}
};
let
module_path
=
module_path
.split_last
()
.unwrap
()
.1
;
let
rename
=
rename
.
map
(|
n
|
n
.name
)
.
unwrap_or
(
name
);
let
rename
=
rename
.unwrap_or
(
name
);
(
module_path
.to_vec
(),
name
,
rename
)
}
};
...
...
src/librustc_resolve/lib.rs
浏览文件 @
a636a83c
...
...
@@ -2210,23 +2210,23 @@ fn resolve_item(&mut self, item: &Item) {
ItemUse
(
ref
view_path
)
=>
{
// check for imports shadowing primitive types
let
check_rename
=
|
this
:
&
Self
,
id
,
ident
:
Ident
|
{
let
check_rename
=
|
this
:
&
Self
,
id
,
name
|
{
match
this
.def_map
.borrow
()
.get
(
&
id
)
.map
(|
d
|
d
.full_def
())
{
Some
(
DefTy
(
..
))
|
Some
(
DefStruct
(
..
))
|
Some
(
DefTrait
(
..
))
|
None
=>
{
this
.check_if_primitive_type_name
(
ident
.
name
,
item
.span
);
this
.check_if_primitive_type_name
(
name
,
item
.span
);
}
_
=>
{}
}
};
match
view_path
.node
{
hir
::
ViewPathSimple
(
ident
,
_
)
=>
{
check_rename
(
self
,
item
.id
,
ident
);
hir
::
ViewPathSimple
(
name
,
_
)
=>
{
check_rename
(
self
,
item
.id
,
name
);
}
hir
::
ViewPathList
(
ref
prefix
,
ref
items
)
=>
{
for
item
in
items
{
if
let
Some
(
ident
)
=
item
.node
.rename
()
{
check_rename
(
self
,
item
.node
.id
(),
ident
);
if
let
Some
(
name
)
=
item
.node
.rename
()
{
check_rename
(
self
,
item
.node
.id
(),
name
);
}
}
...
...
src/librustdoc/clean/inline.rs
浏览文件 @
a636a83c
...
...
@@ -43,7 +43,7 @@
///
/// The returned value is `None` if the `id` could not be inlined, and `Some`
/// of a vector of items if it was successfully expanded.
pub
fn
try_inline
(
cx
:
&
DocContext
,
id
:
ast
::
NodeId
,
into
:
Option
<
ast
::
Ident
>
)
pub
fn
try_inline
(
cx
:
&
DocContext
,
id
:
ast
::
NodeId
,
into
:
Option
<
ast
::
Name
>
)
->
Option
<
Vec
<
clean
::
Item
>>
{
let
tcx
=
match
cx
.tcx_opt
()
{
Some
(
tcx
)
=>
tcx
,
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
a636a83c
...
...
@@ -2386,14 +2386,14 @@ fn clean(&self, cx: &DocContext) -> Vec<Item> {
(
ret
,
ImportList
(
resolve_use_source
(
cx
,
p
.clean
(
cx
),
self
.id
),
remaining
))
}
hir
::
ViewPathSimple
(
i
,
ref
p
)
=>
{
hir
::
ViewPathSimple
(
name
,
ref
p
)
=>
{
if
!
denied
{
match
inline
::
try_inline
(
cx
,
self
.id
,
Some
(
i
))
{
match
inline
::
try_inline
(
cx
,
self
.id
,
Some
(
name
))
{
Some
(
items
)
=>
return
items
,
None
=>
{}
}
}
(
vec!
[],
SimpleImport
(
i
.clean
(
cx
),
(
vec!
[],
SimpleImport
(
name
.clean
(
cx
),
resolve_use_source
(
cx
,
p
.clean
(
cx
),
self
.id
)))
}
};
...
...
src/librustdoc/doctree.rs
浏览文件 @
a636a83c
...
...
@@ -210,12 +210,12 @@ pub struct DefaultImpl {
}
pub
struct
Macro
{
pub
name
:
Ident
,
pub
name
:
Name
,
pub
id
:
ast
::
NodeId
,
pub
attrs
:
Vec
<
ast
::
Attribute
>
,
pub
whence
:
Span
,
pub
stab
:
Option
<
attr
::
Stability
>
,
pub
imported_from
:
Option
<
Ident
>
,
pub
imported_from
:
Option
<
Name
>
,
}
pub
struct
ExternCrate
{
...
...
src/librustdoc/visit_ast.rs
浏览文件 @
a636a83c
...
...
@@ -199,7 +199,7 @@ fn visit_view_path(&mut self, path: hir::ViewPath_,
}
fn
resolve_id
(
&
mut
self
,
id
:
ast
::
NodeId
,
renamed
:
Option
<
ast
::
Ident
>
,
fn
resolve_id
(
&
mut
self
,
id
:
ast
::
NodeId
,
renamed
:
Option
<
ast
::
Name
>
,
glob
:
bool
,
om
:
&
mut
Module
,
please_inline
:
bool
)
->
bool
{
let
tcx
=
match
self
.cx
.tcx_opt
()
{
Some
(
tcx
)
=>
tcx
,
...
...
@@ -241,9 +241,9 @@ fn resolve_id(&mut self, id: ast::NodeId, renamed: Option<ast::Ident>,
}
pub
fn
visit_item
(
&
mut
self
,
item
:
&
hir
::
Item
,
renamed
:
Option
<
ast
::
Ident
>
,
om
:
&
mut
Module
)
{
renamed
:
Option
<
ast
::
Name
>
,
om
:
&
mut
Module
)
{
debug!
(
"Visiting item {:?}"
,
item
);
let
name
=
renamed
.
map_or
(
item
.name
,
|
x
|
x
.name
);
let
name
=
renamed
.
unwrap_or
(
item
.name
);
match
item
.node
{
hir
::
ItemExternCrate
(
ref
p
)
=>
{
let
path
=
match
*
p
{
...
...
@@ -398,7 +398,7 @@ fn visit_macro(&self, def: &hir::MacroDef) -> Macro {
Macro
{
id
:
def
.id
,
attrs
:
def
.attrs
.clone
(),
name
:
def
.
ident
,
name
:
def
.
name
,
whence
:
def
.span
,
stab
:
self
.stability
(
def
.id
),
imported_from
:
def
.imported_from
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录