Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d08f7dcd
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,发现更多精彩内容 >>
提交
d08f7dcd
编写于
12月 02, 2018
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review comments
上级
d415844f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
27 deletion
+14
-27
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+1
-12
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+7
-9
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+2
-2
src/libsyntax_pos/symbol.rs
src/libsyntax_pos/symbol.rs
+4
-4
未找到文件。
src/libsyntax/ast.rs
浏览文件 @
d08f7dcd
...
...
@@ -105,17 +105,6 @@ pub fn from_ident(ident: Ident) -> Path {
}
}
// Make a "crate root" segment for this path unless it already has it
// or starts with something like `self`/`super`/`$crate`/etc.
pub
fn
make_root
(
&
self
)
->
Option
<
PathSegment
>
{
if
let
Some
(
ident
)
=
self
.segments
.get
(
0
)
.map
(|
seg
|
seg
.ident
)
{
if
ident
.is_path_segment_keyword
()
{
return
None
;
}
}
Some
(
PathSegment
::
crate_root
(
self
.span
.shrink_to_lo
()))
}
pub
fn
is_global
(
&
self
)
->
bool
{
!
self
.segments
.is_empty
()
&&
self
.segments
[
0
]
.ident.name
==
keywords
::
PathRoot
.name
()
}
...
...
@@ -144,7 +133,7 @@ impl PathSegment {
pub
fn
from_ident
(
ident
:
Ident
)
->
Self
{
PathSegment
{
ident
,
id
:
DUMMY_NODE_ID
,
args
:
None
}
}
pub
fn
crate
_root
(
span
:
Span
)
->
Self
{
pub
fn
path
_root
(
span
:
Span
)
->
Self
{
PathSegment
::
from_ident
(
Ident
::
new
(
keywords
::
PathRoot
.name
(),
span
))
}
}
...
...
src/libsyntax/ext/build.rs
浏览文件 @
d08f7dcd
...
...
@@ -318,9 +318,13 @@ fn path_all(&self,
args
:
Vec
<
ast
::
GenericArg
>
,
bindings
:
Vec
<
ast
::
TypeBinding
>
)
->
ast
::
Path
{
assert
!
(
!
idents
.is_empty
());
let
add_root
=
global
&&
!
idents
[
0
]
.is_path_segment_keyword
();
let
mut
segments
=
Vec
::
with_capacity
(
idents
.len
()
+
add_root
as
usize
);
if
add_root
{
segments
.push
(
ast
::
PathSegment
::
path_root
(
span
));
}
let
last_ident
=
idents
.pop
()
.unwrap
();
let
mut
segments
:
Vec
<
ast
::
PathSegment
>
=
vec!
[];
segments
.extend
(
idents
.into_iter
()
.map
(|
ident
|
{
ast
::
PathSegment
::
from_ident
(
ident
.with_span_pos
(
span
))
}));
...
...
@@ -334,13 +338,7 @@ fn path_all(&self,
id
:
ast
::
DUMMY_NODE_ID
,
args
,
});
let
mut
path
=
ast
::
Path
{
span
,
segments
};
if
global
{
if
let
Some
(
seg
)
=
path
.make_root
()
{
path
.segments
.insert
(
0
,
seg
);
}
}
path
ast
::
Path
{
span
,
segments
}
}
/// Constructs a qualified path.
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
d08f7dcd
...
...
@@ -2082,7 +2082,7 @@ pub fn parse_path(&mut self, style: PathStyle) -> PResult<'a, ast::Path> {
let
mut
segments
=
Vec
::
new
();
let
mod_sep_ctxt
=
self
.span
.ctxt
();
if
self
.eat
(
&
token
::
ModSep
)
{
segments
.push
(
PathSegment
::
crate
_root
(
lo
.shrink_to_lo
()
.with_ctxt
(
mod_sep_ctxt
)));
segments
.push
(
PathSegment
::
path
_root
(
lo
.shrink_to_lo
()
.with_ctxt
(
mod_sep_ctxt
)));
}
self
.parse_path_segments
(
&
mut
segments
,
style
,
enable_warning
)
?
;
...
...
@@ -7685,7 +7685,7 @@ fn parse_use_tree(&mut self) -> PResult<'a, UseTree> {
let
mod_sep_ctxt
=
self
.span
.ctxt
();
if
self
.eat
(
&
token
::
ModSep
)
{
prefix
.segments
.push
(
PathSegment
::
crate
_root
(
lo
.shrink_to_lo
()
.with_ctxt
(
mod_sep_ctxt
))
PathSegment
::
path
_root
(
lo
.shrink_to_lo
()
.with_ctxt
(
mod_sep_ctxt
))
);
}
...
...
src/libsyntax_pos/symbol.rs
浏览文件 @
d08f7dcd
...
...
@@ -353,7 +353,7 @@ pub fn fresh() -> Self {
(
2
,
DollarCrate
,
"$crate"
)
(
3
,
Underscore
,
"_"
)
// Keywords
used in the language
.
// Keywords
that are used in stable Rust
.
(
4
,
As
,
"as"
)
(
5
,
Box
,
"box"
)
(
6
,
Break
,
"break"
)
...
...
@@ -391,7 +391,7 @@ pub fn fresh() -> Self {
(
38
,
Where
,
"where"
)
(
39
,
While
,
"while"
)
// Keywords reserved for future use.
// Keywords
that are used in unstable Rust or
reserved for future use.
(
40
,
Abstract
,
"abstract"
)
(
41
,
Become
,
"become"
)
(
42
,
Do
,
"do"
)
...
...
@@ -404,10 +404,10 @@ pub fn fresh() -> Self {
(
49
,
Virtual
,
"virtual"
)
(
50
,
Yield
,
"yield"
)
// Edition-specific keywords
used in the language
.
// Edition-specific keywords
that are used in stable Rust
.
(
51
,
Dyn
,
"dyn"
)
// >= 2018 Edition only
// Edition-specific keywords reserved for future use.
// Edition-specific keywords
that are used in unstable Rust or
reserved for future use.
(
52
,
Async
,
"async"
)
// >= 2018 Edition only
(
53
,
Try
,
"try"
)
// >= 2018 Edition only
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录