Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4a133640
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,发现更多精彩内容 >>
提交
4a133640
编写于
12月 17, 2013
作者:
S
Seo Sanghyeon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove obsolete mutability from ast::Ty
上级
9eb89a6c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
48 addition
and
48 deletion
+48
-48
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+16
-9
src/librustdoc/clean.rs
src/librustdoc/clean.rs
+4
-4
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+3
-3
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+1
-1
src/libsyntax/ext/format.rs
src/libsyntax/ext/format.rs
+1
-1
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+4
-4
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+8
-9
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+5
-13
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+6
-4
未找到文件。
src/librustc/middle/typeck/astconv.rs
浏览文件 @
4a133640
...
...
@@ -282,6 +282,12 @@ pub fn ast_path_to_ty<AC:AstConv,RS:RegionScope>(
pub
fn
ast_ty_to_ty
<
AC
:
AstConv
,
RS
:
RegionScope
>
(
this
:
&
AC
,
rscope
:
&
RS
,
ast_ty
:
&
ast
::
Ty
)
->
ty
::
t
{
fn
ast_ty_to_mt
<
AC
:
AstConv
,
RS
:
RegionScope
>
(
this
:
&
AC
,
rscope
:
&
RS
,
ty
:
&
ast
::
Ty
)
->
ty
::
mt
{
ty
::
mt
{
ty
:
ast_ty_to_ty
(
this
,
rscope
,
ty
),
mutbl
:
ast
::
MutImmutable
}
}
fn
ast_mt_to_mt
<
AC
:
AstConv
,
RS
:
RegionScope
>
(
this
:
&
AC
,
rscope
:
&
RS
,
mt
:
&
ast
::
mt
)
->
ty
::
mt
{
...
...
@@ -303,8 +309,8 @@ fn mk_pointer<AC:AstConv,
debug!
(
"mk_pointer(vst={:?})"
,
vst
);
match
a_seq_ty
.ty.node
{
ast
::
ty_vec
(
ref
mt
)
=>
{
let
mut
mt
=
ast_
mt_to_mt
(
this
,
rscope
,
mt
);
ast
::
ty_vec
(
ty
)
=>
{
let
mut
mt
=
ast_
ty_to_mt
(
this
,
rscope
,
ty
);
if
a_seq_ty
.mutbl
==
ast
::
MutMutable
{
mt
=
ty
::
mt
{
ty
:
mt
.ty
,
mutbl
:
a_seq_ty
.mutbl
};
}
...
...
@@ -394,14 +400,15 @@ fn check_path_args(tcx: ty::ctxt,
mk_pointer
(
this
,
rscope
,
mt
,
ty
::
vstore_box
,
|
tmt
|
ty
::
mk_box
(
tcx
,
tmt
))
}
ast
::
ty_uniq
(
ref
mt
)
=>
{
mk_pointer
(
this
,
rscope
,
mt
,
ty
::
vstore_uniq
,
ast
::
ty_uniq
(
ty
)
=>
{
let
mt
=
ast
::
mt
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
};
mk_pointer
(
this
,
rscope
,
&
mt
,
ty
::
vstore_uniq
,
|
tmt
|
ty
::
mk_uniq
(
tcx
,
tmt
))
}
ast
::
ty_vec
(
ref
mt
)
=>
{
ast
::
ty_vec
(
ty
)
=>
{
tcx
.sess
.span_err
(
ast_ty
.span
,
"bare `[]` is not a type"
);
// return /something/ so they can at least get more errors
ty
::
mk_evec
(
tcx
,
ast_
mt_to_mt
(
this
,
rscope
,
mt
),
ty
::
vstore_uniq
)
ty
::
mk_evec
(
tcx
,
ast_
ty_to_mt
(
this
,
rscope
,
ty
),
ty
::
vstore_uniq
)
}
ast
::
ty_ptr
(
ref
mt
)
=>
{
ty
::
mk_ptr
(
tcx
,
ast_mt_to_mt
(
this
,
rscope
,
mt
))
...
...
@@ -532,15 +539,15 @@ fn check_path_args(tcx: ty::ctxt,
}
}
}
ast
::
ty_fixed_length_vec
(
ref
a_mt
,
e
)
=>
{
ast
::
ty_fixed_length_vec
(
ty
,
e
)
=>
{
match
const_eval
::
eval_const_expr_partial
(
&
tcx
,
e
)
{
Ok
(
ref
r
)
=>
{
match
*
r
{
const_eval
::
const_int
(
i
)
=>
ty
::
mk_evec
(
tcx
,
ast_
mt_to_mt
(
this
,
rscope
,
a_mt
),
ty
::
mk_evec
(
tcx
,
ast_
ty_to_mt
(
this
,
rscope
,
ty
),
ty
::
vstore_fixed
(
i
as
uint
)),
const_eval
::
const_uint
(
i
)
=>
ty
::
mk_evec
(
tcx
,
ast_
mt_to_mt
(
this
,
rscope
,
a_mt
),
ty
::
mk_evec
(
tcx
,
ast_
ty_to_mt
(
this
,
rscope
,
ty
),
ty
::
vstore_fixed
(
i
as
uint
)),
_
=>
{
tcx
.sess
.span_fatal
(
...
...
src/librustdoc/clean.rs
浏览文件 @
4a133640
...
...
@@ -621,10 +621,10 @@ fn clean(&self) -> Type {
BorrowedRef
{
lifetime
:
l
.clean
(),
mutability
:
m
.mutbl
.clean
(),
type_
:
~
m
.ty
.clean
()},
ty_box
(
ref
m
)
=>
Managed
(
m
.mutbl
.clean
(),
~
m
.ty
.clean
()),
ty_uniq
(
ref
m
)
=>
Unique
(
~
m
.
ty
.clean
()),
ty_vec
(
ref
m
)
=>
Vector
(
~
m
.
ty
.clean
()),
ty_fixed_length_vec
(
ref
m
,
ref
e
)
=>
FixedVector
(
~
m
.
ty
.clean
(),
e
.span
.to_src
()),
ty_uniq
(
ty
)
=>
Unique
(
~
ty
.clean
()),
ty_vec
(
ty
)
=>
Vector
(
~
ty
.clean
()),
ty_fixed_length_vec
(
ty
,
ref
e
)
=>
FixedVector
(
~
ty
.clean
(),
e
.span
.to_src
()),
ty_tup
(
ref
tys
)
=>
Tuple
(
tys
.iter
()
.map
(|
x
|
x
.clean
())
.collect
()),
ty_path
(
ref
p
,
ref
tpbs
,
id
)
=>
resolve_type
(
p
.clean
(),
tpbs
.clean
(),
id
),
...
...
src/libsyntax/ast.rs
浏览文件 @
4a133640
...
...
@@ -875,9 +875,9 @@ pub enum ty_ {
ty_nil
,
ty_bot
,
/* bottom type */
ty_box
(
mt
),
ty_uniq
(
mt
),
ty_vec
(
mt
),
ty_fixed_length_vec
(
mt
,
@
Expr
),
ty_uniq
(
P
<
Ty
>
),
ty_vec
(
P
<
Ty
>
),
ty_fixed_length_vec
(
P
<
Ty
>
,
@
Expr
),
ty_ptr
(
mt
),
ty_rptr
(
Option
<
Lifetime
>
,
mt
),
ty_closure
(
@
TyClosure
),
...
...
src/libsyntax/ext/build.rs
浏览文件 @
4a133640
...
...
@@ -312,7 +312,7 @@ fn ty_rptr(&self,
ast
::
ty_rptr
(
lifetime
,
self
.ty_mt
(
ty
,
mutbl
)))
}
fn
ty_uniq
(
&
self
,
span
:
Span
,
ty
:
P
<
ast
::
Ty
>
)
->
P
<
ast
::
Ty
>
{
self
.ty
(
span
,
ast
::
ty_uniq
(
self
.ty_mt
(
ty
,
ast
::
MutImmutable
)
))
self
.ty
(
span
,
ast
::
ty_uniq
(
ty
))
}
fn
ty_box
(
&
self
,
span
:
Span
,
ty
:
P
<
ast
::
Ty
>
,
mutbl
:
ast
::
Mutability
)
->
P
<
ast
::
Ty
>
{
...
...
src/libsyntax/ext/format.rs
浏览文件 @
4a133640
...
...
@@ -593,7 +593,7 @@ fn to_expr(&self, extra: @ast::Expr) -> @ast::Expr {
~
[]
),
None
);
let
ty
=
ast
::
ty_fixed_length_vec
(
self
.ecx
.ty_mt
(
piece_ty
,
ast
::
MutImmutable
)
,
piece_ty
,
self
.ecx
.expr_uint
(
self
.fmtsp
,
self
.pieces
.len
())
);
let
ty
=
self
.ecx
.ty
(
self
.fmtsp
,
ty
);
...
...
src/libsyntax/fold.rs
浏览文件 @
4a133640
...
...
@@ -241,8 +241,8 @@ fn fold_ty(&self, t: P<Ty>) -> P<Ty> {
let
node
=
match
t
.node
{
ty_nil
|
ty_bot
|
ty_infer
=>
t
.node
.clone
(),
ty_box
(
ref
mt
)
=>
ty_box
(
fold_mt
(
mt
,
self
)),
ty_uniq
(
ref
mt
)
=>
ty_uniq
(
fold_mt
(
mt
,
self
)),
ty_vec
(
ref
mt
)
=>
ty_vec
(
fold_mt
(
mt
,
self
)),
ty_uniq
(
ty
)
=>
ty_uniq
(
self
.fold_ty
(
ty
)),
ty_vec
(
ty
)
=>
ty_vec
(
self
.fold_ty
(
ty
)),
ty_ptr
(
ref
mt
)
=>
ty_ptr
(
fold_mt
(
mt
,
self
)),
ty_rptr
(
ref
region
,
ref
mt
)
=>
{
ty_rptr
(
fold_opt_lifetime
(
region
,
self
),
fold_mt
(
mt
,
self
))
...
...
@@ -272,8 +272,8 @@ fn fold_ty(&self, t: P<Ty>) -> P<Ty> {
fold_opt_bounds
(
bounds
,
self
),
self
.new_id
(
id
))
}
ty_fixed_length_vec
(
ref
mt
,
e
)
=>
{
ty_fixed_length_vec
(
fold_mt
(
mt
,
self
),
self
.fold_expr
(
e
))
ty_fixed_length_vec
(
ty
,
e
)
=>
{
ty_fixed_length_vec
(
self
.fold_ty
(
ty
),
self
.fold_expr
(
e
))
}
ty_typeof
(
expr
)
=>
ty_typeof
(
self
.fold_expr
(
expr
)),
};
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
4a133640
...
...
@@ -1213,11 +1213,11 @@ pub fn parse_ty(&self, _: bool) -> P<Ty> {
}
else
if
*
self
.token
==
token
::
AT
{
// MANAGED POINTER
self
.bump
();
self
.parse_box_or_uniq_pointee
(
ManagedSigil
,
ty_box
)
self
.parse_box_or_uniq_pointee
(
ManagedSigil
)
}
else
if
*
self
.token
==
token
::
TILDE
{
// OWNED POINTER
self
.bump
();
self
.parse_box_or_uniq_pointee
(
OwnedSigil
,
ty_uniq
)
self
.parse_box_or_uniq_pointee
(
OwnedSigil
)
}
else
if
*
self
.token
==
token
::
BINOP
(
token
::
STAR
)
{
// STAR POINTER (bare pointer?)
self
.bump
();
...
...
@@ -1225,13 +1225,13 @@ pub fn parse_ty(&self, _: bool) -> P<Ty> {
}
else
if
*
self
.token
==
token
::
LBRACKET
{
// VECTOR
self
.expect
(
&
token
::
LBRACKET
);
let
mt
=
mt
{
ty
:
self
.parse_ty
(
false
),
mutbl
:
MutImmutable
}
;
let
t
=
self
.parse_ty
(
false
)
;
// Parse the `, ..e` in `[ int, ..e ]`
// where `e` is a const expression
let
t
=
match
self
.maybe_parse_fixed_vstore
()
{
None
=>
ty_vec
(
m
t
),
Some
(
suffix
)
=>
ty_fixed_length_vec
(
m
t
,
suffix
)
None
=>
ty_vec
(
t
),
Some
(
suffix
)
=>
ty_fixed_length_vec
(
t
,
suffix
)
};
self
.expect
(
&
token
::
RBRACKET
);
t
...
...
@@ -1284,8 +1284,7 @@ pub fn parse_ty(&self, _: bool) -> P<Ty> {
// parse the type following a @ or a ~
pub
fn
parse_box_or_uniq_pointee
(
&
self
,
sigil
:
ast
::
Sigil
,
ctor
:
|
v
:
mt
|
->
ty_
)
sigil
:
ast
::
Sigil
)
->
ty_
{
// ~'foo fn() or ~fn() are parsed directly as obsolete fn types:
match
*
self
.token
{
...
...
@@ -1309,9 +1308,9 @@ pub fn parse_box_or_uniq_pointee(&self,
// rather than boxed ptrs. But the special casing of str/vec is not
// reflected in the AST type.
if
sigil
==
OwnedSigil
{
ctor
(
mt
{
ty
:
self
.parse_ty
(
false
),
mutbl
:
MutImmutable
}
)
ty_uniq
(
self
.parse_ty
(
false
)
)
}
else
{
ctor
(
self
.parse_mt
())
ty_box
(
self
.parse_mt
())
}
}
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
4a133640
...
...
@@ -401,14 +401,10 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
ast
::
ty_nil
=>
word
(
s
.s
,
"()"
),
ast
::
ty_bot
=>
word
(
s
.s
,
"!"
),
ast
::
ty_box
(
ref
mt
)
=>
{
word
(
s
.s
,
"@"
);
print_mt
(
s
,
mt
);
}
ast
::
ty_uniq
(
ref
mt
)
=>
{
word
(
s
.s
,
"~"
);
print_mt
(
s
,
mt
);
}
ast
::
ty_vec
(
ref
mt
)
=>
{
ast
::
ty_uniq
(
ty
)
=>
{
word
(
s
.s
,
"~"
);
print_type
(
s
,
ty
);
}
ast
::
ty_vec
(
ty
)
=>
{
word
(
s
.s
,
"["
);
match
mt
.mutbl
{
ast
::
MutMutable
=>
word_space
(
s
,
"mut"
),
ast
::
MutImmutable
=>
()
}
print_type
(
s
,
mt
.ty
);
print_type
(
s
,
ty
);
word
(
s
.s
,
"]"
);
}
ast
::
ty_ptr
(
ref
mt
)
=>
{
word
(
s
.s
,
"*"
);
print_mt
(
s
,
mt
);
}
...
...
@@ -444,13 +440,9 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
Some
(
&
generics
),
None
);
}
ast
::
ty_path
(
ref
path
,
ref
bounds
,
_
)
=>
print_bounded_path
(
s
,
path
,
bounds
),
ast
::
ty_fixed_length_vec
(
ref
mt
,
v
)
=>
{
ast
::
ty_fixed_length_vec
(
ty
,
v
)
=>
{
word
(
s
.s
,
"["
);
match
mt
.mutbl
{
ast
::
MutMutable
=>
word_space
(
s
,
"mut"
),
ast
::
MutImmutable
=>
()
}
print_type
(
s
,
mt
.ty
);
print_type
(
s
,
ty
);
word
(
s
.s
,
", .."
);
print_expr
(
s
,
v
);
word
(
s
.s
,
"]"
);
...
...
src/libsyntax/visit.rs
浏览文件 @
4a133640
...
...
@@ -298,8 +298,10 @@ pub fn skip_ty<E, V:Visitor<E>>(_: &mut V, _: &Ty, _: E) {
pub
fn
walk_ty
<
E
:
Clone
,
V
:
Visitor
<
E
>>
(
visitor
:
&
mut
V
,
typ
:
&
Ty
,
env
:
E
)
{
match
typ
.node
{
ty_box
(
ref
mutable_type
)
|
ty_uniq
(
ref
mutable_type
)
|
ty_vec
(
ref
mutable_type
)
|
ty_ptr
(
ref
mutable_type
)
=>
{
ty_uniq
(
ty
)
|
ty_vec
(
ty
)
=>
{
visitor
.visit_ty
(
ty
,
env
)
}
ty_box
(
ref
mutable_type
)
|
ty_ptr
(
ref
mutable_type
)
=>
{
visitor
.visit_ty
(
mutable_type
.ty
,
env
)
}
ty_rptr
(
ref
lifetime
,
ref
mutable_type
)
=>
{
...
...
@@ -340,8 +342,8 @@ pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
walk_ty_param_bounds
(
visitor
,
bounds
,
env
.clone
())
}
}
ty_fixed_length_vec
(
ref
mutable_type
,
expression
)
=>
{
visitor
.visit_ty
(
mutable_type
.
ty
,
env
.clone
());
ty_fixed_length_vec
(
ty
,
expression
)
=>
{
visitor
.visit_ty
(
ty
,
env
.clone
());
visitor
.visit_expr
(
expression
,
env
)
}
ty_typeof
(
expression
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录