Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1c4d4371
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,发现更多精彩内容 >>
提交
1c4d4371
编写于
2月 08, 2016
作者:
O
Oliver Schneider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[breaking-change] don't glob export ast::ExplicitSelf_ variants
上级
79fa657a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
59 addition
and
60 deletion
+59
-60
src/librustc_front/lowering.rs
src/librustc_front/lowering.rs
+5
-5
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+6
-7
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+10
-10
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+18
-18
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+12
-12
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+4
-4
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/mod.rs
+2
-2
src/libsyntax_ext/deriving/generic/ty.rs
src/libsyntax_ext/deriving/generic/ty.rs
+2
-2
未找到文件。
src/librustc_front/lowering.rs
浏览文件 @
1c4d4371
...
...
@@ -408,17 +408,17 @@ pub fn lower_local(lctx: &LoweringContext, l: &Local) -> P<hir::Local> {
}
pub
fn
lower_explicit_self_underscore
(
lctx
:
&
LoweringContext
,
es
:
&
ExplicitSelf_
)
es
:
&
SelfKind
)
->
hir
::
ExplicitSelf_
{
match
*
es
{
SelfStatic
=>
hir
::
SelfStatic
,
SelfValue
(
v
)
=>
hir
::
SelfValue
(
v
.name
),
SelfRegion
(
ref
lifetime
,
m
,
ident
)
=>
{
Self
Kind
::
Static
=>
hir
::
SelfStatic
,
Self
Kind
::
Value
(
v
)
=>
hir
::
SelfValue
(
v
.name
),
Self
Kind
::
Region
(
ref
lifetime
,
m
,
ident
)
=>
{
hir
::
SelfRegion
(
lower_opt_lifetime
(
lctx
,
lifetime
),
lower_mutability
(
lctx
,
m
),
ident
.name
)
}
SelfExplicit
(
ref
typ
,
ident
)
=>
{
Self
Kind
::
Explicit
(
ref
typ
,
ident
)
=>
{
hir
::
SelfExplicit
(
lower_ty
(
lctx
,
typ
),
ident
.name
)
}
}
...
...
src/libsyntax/ast.rs
浏览文件 @
1c4d4371
...
...
@@ -10,7 +10,6 @@
// The Rust abstract syntax tree.
pub
use
self
::
ExplicitSelf_
::
*
;
pub
use
self
::
Expr_
::
*
;
pub
use
self
::
FloatTy
::
*
;
pub
use
self
::
ForeignItem_
::
*
;
...
...
@@ -1747,18 +1746,18 @@ pub fn span(&self) -> Span {
/// Represents the kind of 'self' associated with a method
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
enum
ExplicitSelf_
{
pub
enum
SelfKind
{
/// No self
S
elfS
tatic
,
Static
,
/// `self`
Self
Value
(
Ident
),
Value
(
Ident
),
/// `&'lt self`, `&'lt mut self`
Self
Region
(
Option
<
Lifetime
>
,
Mutability
,
Ident
),
Region
(
Option
<
Lifetime
>
,
Mutability
,
Ident
),
/// `self: TYPE`
Self
Explicit
(
P
<
Ty
>
,
Ident
),
Explicit
(
P
<
Ty
>
,
Ident
),
}
pub
type
ExplicitSelf
=
Spanned
<
ExplicitSelf_
>
;
pub
type
ExplicitSelf
=
Spanned
<
SelfKind
>
;
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
struct
Mod
{
...
...
src/libsyntax/fold.rs
浏览文件 @
1c4d4371
...
...
@@ -184,8 +184,8 @@ fn fold_explicit_self(&mut self, es: ExplicitSelf) -> ExplicitSelf {
noop_fold_explicit_self
(
es
,
self
)
}
fn
fold_explicit_self_
underscore
(
&
mut
self
,
es
:
ExplicitSelf_
)
->
ExplicitSelf_
{
noop_fold_explicit_self_
underscore
(
es
,
self
)
fn
fold_explicit_self_
kind
(
&
mut
self
,
es
:
SelfKind
)
->
SelfKind
{
noop_fold_explicit_self_
kind
(
es
,
self
)
}
fn
fold_lifetime
(
&
mut
self
,
l
:
Lifetime
)
->
Lifetime
{
...
...
@@ -520,15 +520,15 @@ pub fn noop_fold_attribute<T: Folder>(at: Attribute, fld: &mut T) -> Option<Attr
})
}
pub
fn
noop_fold_explicit_self_
underscore
<
T
:
Folder
>
(
es
:
ExplicitSelf_
,
fld
:
&
mut
T
)
->
ExplicitSelf_
{
pub
fn
noop_fold_explicit_self_
kind
<
T
:
Folder
>
(
es
:
SelfKind
,
fld
:
&
mut
T
)
->
SelfKind
{
match
es
{
Self
Static
|
Self
Value
(
_
)
=>
es
,
SelfRegion
(
lifetime
,
m
,
ident
)
=>
{
SelfRegion
(
fld
.fold_opt_lifetime
(
lifetime
),
m
,
ident
)
Self
Kind
::
Static
|
SelfKind
::
Value
(
_
)
=>
es
,
Self
Kind
::
Region
(
lifetime
,
m
,
ident
)
=>
{
Self
Kind
::
Region
(
fld
.fold_opt_lifetime
(
lifetime
),
m
,
ident
)
}
SelfExplicit
(
typ
,
ident
)
=>
{
SelfExplicit
(
fld
.fold_ty
(
typ
),
ident
)
Self
Kind
::
Explicit
(
typ
,
ident
)
=>
{
Self
Kind
::
Explicit
(
fld
.fold_ty
(
typ
),
ident
)
}
}
}
...
...
@@ -536,7 +536,7 @@ pub fn noop_fold_explicit_self_underscore<T: Folder>(es: ExplicitSelf_, fld: &mu
pub
fn
noop_fold_explicit_self
<
T
:
Folder
>
(
Spanned
{
span
,
node
}:
ExplicitSelf
,
fld
:
&
mut
T
)
->
ExplicitSelf
{
Spanned
{
node
:
fld
.fold_explicit_self_
underscore
(
node
),
node
:
fld
.fold_explicit_self_
kind
(
node
),
span
:
fld
.new_span
(
span
)
}
}
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
1c4d4371
...
...
@@ -46,7 +46,7 @@
use
ast
::{
Stmt
,
StmtDecl
};
use
ast
::{
StmtExpr
,
StmtSemi
,
StmtMac
,
VariantData
,
StructField
};
use
ast
::
StrStyle
;
use
ast
::
{
SelfExplicit
,
SelfRegion
,
SelfStatic
,
SelfValue
}
;
use
ast
::
SelfKind
;
use
ast
::{
Delimited
,
SequenceRepetition
,
TokenTree
,
TraitItem
,
TraitRef
};
use
ast
::{
Ty
,
Ty_
,
TypeBinding
,
TyMac
};
use
ast
::{
TyFixedLengthVec
,
TyBareFn
,
TyTypeof
,
TyInfer
};
...
...
@@ -4411,7 +4411,7 @@ fn parse_fn_decl_with_self<F>(&mut self,
F
:
FnMut
(
&
mut
Parser
<
'a
>
)
->
PResult
<
'a
,
Arg
>
,
{
fn
maybe_parse_borrowed_explicit_self
<
'b
>
(
this
:
&
mut
Parser
<
'b
>
)
->
PResult
<
'b
,
ast
::
ExplicitSelf_
>
{
->
PResult
<
'b
,
ast
::
SelfKind
>
{
// The following things are possible to see here:
//
// fn(&mut self)
...
...
@@ -4423,26 +4423,26 @@ fn maybe_parse_borrowed_explicit_self<'b>(this: &mut Parser<'b>)
if
this
.look_ahead
(
1
,
|
t
|
t
.is_keyword
(
keywords
::
SelfValue
))
{
this
.bump
();
Ok
(
SelfRegion
(
None
,
MutImmutable
,
try!
(
this
.expect_self_ident
())))
Ok
(
Self
Kind
::
Region
(
None
,
MutImmutable
,
try!
(
this
.expect_self_ident
())))
}
else
if
this
.look_ahead
(
1
,
|
t
|
t
.is_mutability
())
&&
this
.look_ahead
(
2
,
|
t
|
t
.is_keyword
(
keywords
::
SelfValue
))
{
this
.bump
();
let
mutability
=
try!
(
this
.parse_mutability
());
Ok
(
SelfRegion
(
None
,
mutability
,
try!
(
this
.expect_self_ident
())))
Ok
(
Self
Kind
::
Region
(
None
,
mutability
,
try!
(
this
.expect_self_ident
())))
}
else
if
this
.look_ahead
(
1
,
|
t
|
t
.is_lifetime
())
&&
this
.look_ahead
(
2
,
|
t
|
t
.is_keyword
(
keywords
::
SelfValue
))
{
this
.bump
();
let
lifetime
=
try!
(
this
.parse_lifetime
());
Ok
(
SelfRegion
(
Some
(
lifetime
),
MutImmutable
,
try!
(
this
.expect_self_ident
())))
Ok
(
Self
Kind
::
Region
(
Some
(
lifetime
),
MutImmutable
,
try!
(
this
.expect_self_ident
())))
}
else
if
this
.look_ahead
(
1
,
|
t
|
t
.is_lifetime
())
&&
this
.look_ahead
(
2
,
|
t
|
t
.is_mutability
())
&&
this
.look_ahead
(
3
,
|
t
|
t
.is_keyword
(
keywords
::
SelfValue
))
{
this
.bump
();
let
lifetime
=
try!
(
this
.parse_lifetime
());
let
mutability
=
try!
(
this
.parse_mutability
());
Ok
(
SelfRegion
(
Some
(
lifetime
),
mutability
,
try!
(
this
.expect_self_ident
())))
Ok
(
Self
Kind
::
Region
(
Some
(
lifetime
),
mutability
,
try!
(
this
.expect_self_ident
())))
}
else
{
Ok
(
SelfStatic
)
Ok
(
Self
Kind
::
Static
)
}
}
...
...
@@ -4477,7 +4477,7 @@ fn maybe_parse_borrowed_explicit_self<'b>(this: &mut Parser<'b>)
self
.bump
();
}
// error case, making bogus self ident:
SelfValue
(
special_idents
::
self_
)
Self
Kind
::
Value
(
special_idents
::
self_
)
}
token
::
Ident
(
..
)
=>
{
if
self
.is_self_ident
()
{
...
...
@@ -4486,9 +4486,9 @@ fn maybe_parse_borrowed_explicit_self<'b>(this: &mut Parser<'b>)
// Determine whether this is the fully explicit form, `self:
// TYPE`.
if
self
.eat
(
&
token
::
Colon
)
{
SelfExplicit
(
try!
(
self
.parse_ty_sum
()),
self_ident
)
Self
Kind
::
Explicit
(
try!
(
self
.parse_ty_sum
()),
self_ident
)
}
else
{
SelfValue
(
self_ident
)
Self
Kind
::
Value
(
self_ident
)
}
}
else
if
self
.token
.is_mutability
()
&&
self
.look_ahead
(
1
,
|
t
|
t
.is_keyword
(
keywords
::
SelfValue
))
{
...
...
@@ -4498,15 +4498,15 @@ fn maybe_parse_borrowed_explicit_self<'b>(this: &mut Parser<'b>)
// Determine whether this is the fully explicit form,
// `self: TYPE`.
if
self
.eat
(
&
token
::
Colon
)
{
SelfExplicit
(
try!
(
self
.parse_ty_sum
()),
self_ident
)
Self
Kind
::
Explicit
(
try!
(
self
.parse_ty_sum
()),
self_ident
)
}
else
{
SelfValue
(
self_ident
)
Self
Kind
::
Value
(
self_ident
)
}
}
else
{
SelfStatic
Self
Kind
::
Static
}
}
_
=>
SelfStatic
,
_
=>
Self
Kind
::
Static
,
};
let
explicit_self_sp
=
mk_sp
(
self_ident_lo
,
self_ident_hi
);
...
...
@@ -4542,14 +4542,14 @@ fn maybe_parse_borrowed_explicit_self<'b>(this: &mut Parser<'b>)
}
let
fn_inputs
=
match
explicit_self
{
SelfStatic
=>
{
Self
Kind
::
Static
=>
{
let
sep
=
seq_sep_trailing_allowed
(
token
::
Comma
);
try!
(
self
.parse_seq_to_before_end
(
&
token
::
CloseDelim
(
token
::
Paren
),
sep
,
parse_arg_fn
))
}
SelfValue
(
id
)
=>
parse_remaining_arguments!
(
id
),
SelfRegion
(
_
,
_
,
id
)
=>
parse_remaining_arguments!
(
id
),
SelfExplicit
(
_
,
id
)
=>
parse_remaining_arguments!
(
id
),
Self
Kind
::
Value
(
id
)
=>
parse_remaining_arguments!
(
id
),
Self
Kind
::
Region
(
_
,
_
,
id
)
=>
parse_remaining_arguments!
(
id
),
Self
Kind
::
Explicit
(
_
,
id
)
=>
parse_remaining_arguments!
(
id
),
};
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
1c4d4371
...
...
@@ -382,7 +382,7 @@ pub fn fun_to_string(decl: &ast::FnDecl,
unsafety
:
ast
::
Unsafety
,
constness
:
ast
::
Constness
,
name
:
ast
::
Ident
,
opt_explicit_self
:
Option
<&
ast
::
ExplicitSelf_
>
,
opt_explicit_self
:
Option
<&
ast
::
SelfKind
>
,
generics
:
&
ast
::
Generics
)
->
String
{
to_string
(|
s
|
{
...
...
@@ -416,7 +416,7 @@ pub fn lit_to_string(l: &ast::Lit) -> String {
to_string
(|
s
|
s
.print_literal
(
l
))
}
pub
fn
explicit_self_to_string
(
explicit_self
:
&
ast
::
ExplicitSelf_
)
->
String
{
pub
fn
explicit_self_to_string
(
explicit_self
:
&
ast
::
SelfKind
)
->
String
{
to_string
(|
s
|
s
.print_explicit_self
(
explicit_self
,
ast
::
MutImmutable
)
.map
(|
_
|
{}))
}
...
...
@@ -2625,21 +2625,21 @@ fn print_arm(&mut self, arm: &ast::Arm) -> io::Result<()> {
// Returns whether it printed anything
fn
print_explicit_self
(
&
mut
self
,
explicit_self
:
&
ast
::
ExplicitSelf_
,
explicit_self
:
&
ast
::
SelfKind
,
mutbl
:
ast
::
Mutability
)
->
io
::
Result
<
bool
>
{
try!
(
self
.print_mutability
(
mutbl
));
match
*
explicit_self
{
ast
::
SelfStatic
=>
{
return
Ok
(
false
);
}
ast
::
SelfValue
(
_
)
=>
{
ast
::
Self
Kind
::
Static
=>
{
return
Ok
(
false
);
}
ast
::
Self
Kind
::
Value
(
_
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"self"
));
}
ast
::
SelfRegion
(
ref
lt
,
m
,
_
)
=>
{
ast
::
Self
Kind
::
Region
(
ref
lt
,
m
,
_
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"&"
));
try!
(
self
.print_opt_lifetime
(
lt
));
try!
(
self
.print_mutability
(
m
));
try!
(
word
(
&
mut
self
.s
,
"self"
));
}
ast
::
SelfExplicit
(
ref
typ
,
_
)
=>
{
ast
::
Self
Kind
::
Explicit
(
ref
typ
,
_
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"self"
));
try!
(
self
.word_space
(
":"
));
try!
(
self
.print_type
(
&**
typ
));
...
...
@@ -2655,7 +2655,7 @@ pub fn print_fn(&mut self,
abi
:
abi
::
Abi
,
name
:
Option
<
ast
::
Ident
>
,
generics
:
&
ast
::
Generics
,
opt_explicit_self
:
Option
<&
ast
::
ExplicitSelf_
>
,
opt_explicit_self
:
Option
<&
ast
::
SelfKind
>
,
vis
:
ast
::
Visibility
)
->
io
::
Result
<
()
>
{
try!
(
self
.print_fn_header_info
(
unsafety
,
constness
,
abi
,
vis
));
...
...
@@ -2669,7 +2669,7 @@ pub fn print_fn(&mut self,
}
pub
fn
print_fn_args
(
&
mut
self
,
decl
:
&
ast
::
FnDecl
,
opt_explicit_self
:
Option
<&
ast
::
ExplicitSelf_
>
,
opt_explicit_self
:
Option
<&
ast
::
SelfKind
>
,
is_closure
:
bool
)
->
io
::
Result
<
()
>
{
// It is unfortunate to duplicate the commasep logic, but we want the
// self type and the args all in the same box.
...
...
@@ -2677,7 +2677,7 @@ pub fn print_fn_args(&mut self, decl: &ast::FnDecl,
let
mut
first
=
true
;
if
let
Some
(
explicit_self
)
=
opt_explicit_self
{
let
m
=
match
*
explicit_self
{
ast
::
SelfStatic
=>
ast
::
MutImmutable
,
ast
::
Self
Kind
::
Static
=>
ast
::
MutImmutable
,
_
=>
match
decl
.inputs
[
0
]
.pat.node
{
ast
::
PatIdent
(
ast
::
BindingMode
::
ByValue
(
m
),
_
,
_
)
=>
m
,
_
=>
ast
::
MutImmutable
...
...
@@ -2702,7 +2702,7 @@ pub fn print_fn_args(&mut self, decl: &ast::FnDecl,
}
pub
fn
print_fn_args_and_ret
(
&
mut
self
,
decl
:
&
ast
::
FnDecl
,
opt_explicit_self
:
Option
<&
ast
::
ExplicitSelf_
>
)
opt_explicit_self
:
Option
<&
ast
::
SelfKind
>
)
->
io
::
Result
<
()
>
{
try!
(
self
.popen
());
try!
(
self
.print_fn_args
(
decl
,
opt_explicit_self
,
false
));
...
...
@@ -3016,7 +3016,7 @@ pub fn print_ty_fn(&mut self,
decl
:
&
ast
::
FnDecl
,
name
:
Option
<
ast
::
Ident
>
,
generics
:
&
ast
::
Generics
,
opt_explicit_self
:
Option
<&
ast
::
ExplicitSelf_
>
)
opt_explicit_self
:
Option
<&
ast
::
SelfKind
>
)
->
io
::
Result
<
()
>
{
try!
(
self
.ibox
(
INDENT_UNIT
));
if
!
generics
.lifetimes
.is_empty
()
||
!
generics
.ty_params
.is_empty
()
{
...
...
src/libsyntax/visit.rs
浏览文件 @
1c4d4371
...
...
@@ -196,15 +196,15 @@ pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_explicit_self
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
explicit_self
:
&
'v
ExplicitSelf
)
{
match
explicit_self
.node
{
SelfStatic
=>
{},
SelfValue
(
ident
)
=>
{
Self
Kind
::
Static
=>
{},
Self
Kind
::
Value
(
ident
)
=>
{
visitor
.visit_ident
(
explicit_self
.span
,
ident
)
}
SelfRegion
(
ref
opt_lifetime
,
_
,
ident
)
=>
{
Self
Kind
::
Region
(
ref
opt_lifetime
,
_
,
ident
)
=>
{
visitor
.visit_ident
(
explicit_self
.span
,
ident
);
walk_list!
(
visitor
,
visit_lifetime
,
opt_lifetime
);
}
SelfExplicit
(
ref
typ
,
ident
)
=>
{
Self
Kind
::
Explicit
(
ref
typ
,
ident
)
=>
{
visitor
.visit_ident
(
explicit_self
.span
,
ident
);
visitor
.visit_ty
(
typ
)
}
...
...
src/libsyntax_ext/deriving/generic/mod.rs
浏览文件 @
1c4d4371
...
...
@@ -821,7 +821,7 @@ fn split_self_nonself_args(&self,
explicit_self
}
None
=>
codemap
::
respan
(
trait_
.span
,
ast
::
SelfStatic
),
None
=>
codemap
::
respan
(
trait_
.span
,
ast
::
Self
Kind
::
Static
),
};
for
(
i
,
ty
)
in
self
.args
.iter
()
.enumerate
()
{
...
...
@@ -862,7 +862,7 @@ fn create_method(&self,
let
fn_generics
=
self
.generics
.to_generics
(
cx
,
trait_
.span
,
type_ident
,
generics
);
let
self_arg
=
match
explicit_self
.node
{
ast
::
SelfStatic
=>
None
,
ast
::
Self
Kind
::
Static
=>
None
,
// creating fresh self id
_
=>
Some
(
ast
::
Arg
::
new_self
(
trait_
.span
,
ast
::
MutImmutable
,
special_idents
::
self_
))
};
...
...
src/libsyntax_ext/deriving/generic/ty.rs
浏览文件 @
1c4d4371
...
...
@@ -264,7 +264,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
let
self_path
=
cx
.expr_self
(
span
);
match
*
self_ptr
{
None
=>
{
(
self_path
,
respan
(
span
,
ast
::
SelfValue
(
special_idents
::
self_
)))
(
self_path
,
respan
(
span
,
ast
::
Self
Kind
::
Value
(
special_idents
::
self_
)))
}
Some
(
ref
ptr
)
=>
{
let
self_ty
=
respan
(
...
...
@@ -272,7 +272,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
match
*
ptr
{
Borrowed
(
ref
lt
,
mutbl
)
=>
{
let
lt
=
lt
.map
(|
s
|
cx
.lifetime
(
span
,
cx
.ident_of
(
s
)
.name
));
ast
::
SelfRegion
(
lt
,
mutbl
,
special_idents
::
self_
)
ast
::
Self
Kind
::
Region
(
lt
,
mutbl
,
special_idents
::
self_
)
}
Raw
(
_
)
=>
cx
.span_bug
(
span
,
"attempted to use *self in deriving definition"
)
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录