Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f903c979
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,发现更多精彩内容 >>
提交
f903c979
编写于
6月 11, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge PatKind::QPath into PatKind::Path in AST
上级
d06f1dcd
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
24 addition
and
46 deletion
+24
-46
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+2
-2
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+2
-11
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+1
-2
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+5
-10
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+1
-1
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+5
-6
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+1
-6
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+2
-2
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+4
-5
src/test/compile-fail/method-resolvable-path-in-pattern.rs
src/test/compile-fail/method-resolvable-path-in-pattern.rs
+1
-1
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
f903c979
...
...
@@ -866,10 +866,10 @@ fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
pats
.iter
()
.map
(|
x
|
self
.lower_pat
(
x
))
.collect
(),
ddpos
)
}
PatKind
::
Path
(
ref
pth
)
=>
{
PatKind
::
Path
(
None
,
ref
pth
)
=>
{
hir
::
PatKind
::
Path
(
self
.lower_path
(
pth
))
}
PatKind
::
QPath
(
ref
qself
,
ref
pth
)
=>
{
PatKind
::
Path
(
Some
(
ref
qself
)
,
ref
pth
)
=>
{
let
qself
=
hir
::
QSelf
{
ty
:
self
.lower_ty
(
&
qself
.ty
),
position
:
qself
.position
,
...
...
src/librustc_resolve/lib.rs
浏览文件 @
f903c979
...
...
@@ -2332,8 +2332,8 @@ fn resolve_pattern(&mut self,
},
"variant or struct"
);
}
PatKind
::
Path
(
ref
path
)
=>
{
self
.resolve_pattern_path
(
pat
.id
,
None
,
path
,
ValueNS
,
|
def
|
{
PatKind
::
Path
(
ref
qself
,
ref
path
)
=>
{
self
.resolve_pattern_path
(
pat
.id
,
qself
.as_ref
()
,
path
,
ValueNS
,
|
def
|
{
match
def
{
Def
::
Struct
(
..
)
|
Def
::
Variant
(
..
)
|
Def
::
Const
(
..
)
|
Def
::
AssociatedConst
(
..
)
|
Def
::
Err
=>
true
,
...
...
@@ -2342,15 +2342,6 @@ fn resolve_pattern(&mut self,
},
"variant, struct or constant"
);
}
PatKind
::
QPath
(
ref
qself
,
ref
path
)
=>
{
self
.resolve_pattern_path
(
pat
.id
,
Some
(
qself
),
path
,
ValueNS
,
|
def
|
{
match
def
{
Def
::
AssociatedConst
(
..
)
|
Def
::
Err
=>
true
,
_
=>
false
,
}
},
"associated constant"
);
}
PatKind
::
Struct
(
ref
path
,
_
,
_
)
=>
{
self
.resolve_pattern_path
(
pat
.id
,
None
,
path
,
TypeNS
,
|
def
|
{
match
def
{
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
f903c979
...
...
@@ -699,8 +699,7 @@ fn visit_pat(&mut self, p: &ast::Pat) {
ast
::
Mutability
::
Mutable
,
recorder
::
TypeRef
));
}
PatKind
::
TupleStruct
(
ref
path
,
_
,
_
)
|
PatKind
::
Path
(
ref
path
)
|
PatKind
::
QPath
(
_
,
ref
path
)
=>
{
PatKind
::
Path
(
_
,
ref
path
)
=>
{
self
.collected_paths
.push
((
p
.id
,
path
.clone
(),
ast
::
Mutability
::
Mutable
,
recorder
::
VarRef
));
}
...
...
src/libsyntax/ast.rs
浏览文件 @
f903c979
...
...
@@ -579,7 +579,6 @@ pub fn walk<F>(&self, it: &mut F) -> bool
PatKind
::
Range
(
_
,
_
)
|
PatKind
::
Ident
(
_
,
_
,
_
)
|
PatKind
::
Path
(
..
)
|
PatKind
::
QPath
(
_
,
_
)
|
PatKind
::
Mac
(
_
)
=>
{
true
}
...
...
@@ -627,15 +626,11 @@ pub enum PatKind {
/// 0 <= position <= subpats.len()
TupleStruct
(
Path
,
Vec
<
P
<
Pat
>>
,
Option
<
usize
>
),
/// A path pattern.
/// Such pattern can be resolved to a unit struct/variant or a constant.
Path
(
Path
),
/// An associated const named using the qualified path `<T>::CONST` or
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
/// referred to as simply `T::CONST`, in which case they will end up as
/// PatKind::Path, and the resolver will have to sort that out.
QPath
(
QSelf
,
Path
),
/// A possibly qualified path pattern.
/// Unquailfied path patterns `A::B::C` can legally refer to variants, structs, constants
/// or associated constants. Quailfied path patterns `<A>::B::C`/`<A as Trait>::B::C` can
/// only legally refer to associated constants.
Path
(
Option
<
QSelf
>
,
Path
),
/// A tuple pattern `(a, b)`.
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
...
...
src/libsyntax/ext/build.rs
浏览文件 @
f903c979
...
...
@@ -830,7 +830,7 @@ fn pat_ident_binding_mode(&self,
}
fn
pat_enum
(
&
self
,
span
:
Span
,
path
:
ast
::
Path
,
subpats
:
Vec
<
P
<
ast
::
Pat
>>
)
->
P
<
ast
::
Pat
>
{
let
pat
=
if
subpats
.is_empty
()
{
PatKind
::
Path
(
path
)
PatKind
::
Path
(
None
,
path
)
}
else
{
PatKind
::
TupleStruct
(
path
,
subpats
,
None
)
};
...
...
src/libsyntax/fold.rs
浏览文件 @
f903c979
...
...
@@ -1088,12 +1088,11 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
PatKind
::
TupleStruct
(
folder
.fold_path
(
pth
),
pats
.move_map
(|
x
|
folder
.fold_pat
(
x
)),
ddpos
)
}
PatKind
::
Path
(
pth
)
=>
{
PatKind
::
Path
(
folder
.fold_path
(
pth
))
}
PatKind
::
QPath
(
qself
,
pth
)
=>
{
let
qself
=
QSelf
{
ty
:
folder
.fold_ty
(
qself
.ty
),
..
qself
};
PatKind
::
QPath
(
qself
,
folder
.fold_path
(
pth
))
PatKind
::
Path
(
opt_qself
,
pth
)
=>
{
let
opt_qself
=
opt_qself
.map
(|
qself
|
{
QSelf
{
ty
:
folder
.fold_ty
(
qself
.ty
),
position
:
qself
.position
}
});
PatKind
::
Path
(
opt_qself
,
folder
.fold_path
(
pth
))
}
PatKind
::
Struct
(
pth
,
fields
,
etc
)
=>
{
let
pth
=
folder
.fold_path
(
pth
);
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
f903c979
...
...
@@ -3715,12 +3715,7 @@ pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>> {
pat
=
PatKind
::
TupleStruct
(
path
,
fields
,
ddpos
)
}
_
=>
{
pat
=
match
qself
{
// Parse qualified path
Some
(
qself
)
=>
PatKind
::
QPath
(
qself
,
path
),
// Parse nullary enum
None
=>
PatKind
::
Path
(
path
)
};
pat
=
PatKind
::
Path
(
qself
,
path
);
}
}
}
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
f903c979
...
...
@@ -2483,10 +2483,10 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
}
try!
(
self
.pclose
());
}
PatKind
::
Path
(
ref
path
)
=>
{
PatKind
::
Path
(
None
,
ref
path
)
=>
{
try!
(
self
.print_path
(
path
,
true
,
0
));
}
PatKind
::
QPath
(
ref
qself
,
ref
path
)
=>
{
PatKind
::
Path
(
Some
(
ref
qself
)
,
ref
path
)
=>
{
try!
(
self
.print_qpath
(
path
,
qself
,
false
));
}
PatKind
::
Struct
(
ref
path
,
ref
fields
,
etc
)
=>
{
...
...
src/libsyntax/visit.rs
浏览文件 @
f903c979
...
...
@@ -409,11 +409,10 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor
.visit_path
(
path
,
pattern
.id
);
walk_list!
(
visitor
,
visit_pat
,
children
);
}
PatKind
::
Path
(
ref
path
)
=>
{
visitor
.visit_path
(
path
,
pattern
.id
);
}
PatKind
::
QPath
(
ref
qself
,
ref
path
)
=>
{
visitor
.visit_ty
(
&
qself
.ty
);
PatKind
::
Path
(
ref
opt_qself
,
ref
path
)
=>
{
if
let
Some
(
ref
qself
)
=
*
opt_qself
{
visitor
.visit_ty
(
&
qself
.ty
);
}
visitor
.visit_path
(
path
,
pattern
.id
)
}
PatKind
::
Struct
(
ref
path
,
ref
fields
,
_
)
=>
{
...
...
src/test/compile-fail/method-resolvable-path-in-pattern.rs
浏览文件 @
f903c979
...
...
@@ -19,6 +19,6 @@ impl MyTrait for Foo {}
fn
main
()
{
match
0u32
{
<
Foo
as
MyTrait
>
::
trait_bar
=>
{}
//~^ ERROR expected
associated
constant, found method `trait_bar`
//~^ ERROR expected
variant, struct or
constant, found method `trait_bar`
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录