Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7b2026bf
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
7b2026bf
编写于
7月 31, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce 'return', 'match' and 'module' as synonyms
上级
7d183698
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
349 addition
and
319 deletion
+349
-319
src/cargo/cargo.rs
src/cargo/cargo.rs
+9
-9
src/compiletest/compiletest.rs
src/compiletest/compiletest.rs
+16
-16
src/libcore/dvec.rs
src/libcore/dvec.rs
+6
-6
src/libstd/list.rs
src/libstd/list.rs
+5
-5
src/libstd/test.rs
src/libstd/test.rs
+5
-5
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+4
-4
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+21
-7
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+2
-2
src/rustc/driver/driver.rs
src/rustc/driver/driver.rs
+30
-30
src/rustc/driver/rustc.rs
src/rustc/driver/rustc.rs
+13
-13
src/rustc/metadata/creader.rs
src/rustc/metadata/creader.rs
+3
-3
src/rustc/metadata/encoder.rs
src/rustc/metadata/encoder.rs
+3
-3
src/rustc/metadata/loader.rs
src/rustc/metadata/loader.rs
+3
-3
src/rustc/middle/check_alt.rs
src/rustc/middle/check_alt.rs
+4
-4
src/rustc/middle/resolve3.rs
src/rustc/middle/resolve3.rs
+166
-166
src/rustc/middle/trans/alt.rs
src/rustc/middle/trans/alt.rs
+25
-25
src/rustc/middle/typeck/coherence.rs
src/rustc/middle/typeck/coherence.rs
+3
-3
src/rustdoc/config.rs
src/rustdoc/config.rs
+11
-10
src/rustdoc/extract.rs
src/rustdoc/extract.rs
+4
-4
src/test/compile-fail/attr-bad-crate-attr.rc
src/test/compile-fail/attr-bad-crate-attr.rc
+1
-1
src/test/run-pass/keyword-changes-2012-07-31.rs
src/test/run-pass/keyword-changes-2012-07-31.rs
+15
-0
未找到文件。
src/cargo/cargo.rs
浏览文件 @
7b2026bf
...
...
@@ -600,21 +600,21 @@ fn load_source_packages(c: cargo, src: source) {
}
fn
build_cargo_options
(
argv
:
~
[
~
str
])
->
options
{
let
match
=
alt
getopts
::
getopts
(
argv
,
opts
())
{
let
match
es
=
alt
getopts
::
getopts
(
argv
,
opts
())
{
result
::
ok
(
m
)
{
m
}
result
::
err
(
f
)
{
fail
fmt!
{
"%s"
,
getopts
::
fail_str
(
f
)};
}
};
let
test
=
opt_present
(
match
,
~
"test"
);
let
G
=
opt_present
(
match
,
~
"G"
);
let
g
=
opt_present
(
match
,
~
"g"
);
let
help
=
opt_present
(
match
,
~
"h"
)
||
opt_present
(
match
,
~
"help"
);
let
len
=
vec
::
len
(
match
.free
);
let
test
=
opt_present
(
match
es
,
~
"test"
);
let
G
=
opt_present
(
match
es
,
~
"G"
);
let
g
=
opt_present
(
match
es
,
~
"g"
);
let
help
=
opt_present
(
match
es
,
~
"h"
)
||
opt_present
(
matches
,
~
"help"
);
let
len
=
vec
::
len
(
match
es
.free
);
let
is_install
=
len
>
1u
&&
match
.free
[
1
]
==
~
"install"
;
let
is_uninstall
=
len
>
1u
&&
match
.free
[
1
]
==
~
"uninstall"
;
let
is_install
=
len
>
1u
&&
match
es
.free
[
1
]
==
~
"install"
;
let
is_uninstall
=
len
>
1u
&&
match
es
.free
[
1
]
==
~
"uninstall"
;
if
G
&&
g
{
fail
~
"-G and -g both provided"
;
}
...
...
@@ -627,7 +627,7 @@ fn build_cargo_options(argv: ~[~str]) -> options {
else
if
G
{
system_mode
}
else
{
local_mode
};
{
test
:
test
,
mode
:
mode
,
free
:
match
.free
,
help
:
help
}
{
test
:
test
,
mode
:
mode
,
free
:
match
es
.free
,
help
:
help
}
}
fn
configure
(
opts
:
options
)
->
cargo
{
...
...
src/compiletest/compiletest.rs
浏览文件 @
7b2026bf
...
...
@@ -41,29 +41,29 @@ fn parse_config(args: ~[~str]) -> config {
assert
(
vec
::
is_not_empty
(
args
));
let
args_
=
vec
::
tail
(
args
);
let
match
=
let
match
es
=
alt
getopts
::
getopts
(
args_
,
opts
)
{
ok
(
m
)
{
m
}
err
(
f
)
{
fail
getopts
::
fail_str
(
f
)
}
};
ret
{
compile_lib_path
:
getopts
::
opt_str
(
match
,
~
"compile-lib-path"
),
run_lib_path
:
getopts
::
opt_str
(
match
,
~
"run-lib-path"
),
rustc_path
:
getopts
::
opt_str
(
match
,
~
"rustc-path"
),
src_base
:
getopts
::
opt_str
(
match
,
~
"src-base"
),
build_base
:
getopts
::
opt_str
(
match
,
~
"build-base"
),
aux_base
:
getopts
::
opt_str
(
match
,
~
"aux-base"
),
stage_id
:
getopts
::
opt_str
(
match
,
~
"stage-id"
),
mode
:
str_mode
(
getopts
::
opt_str
(
match
,
~
"mode"
)),
run_ignored
:
getopts
::
opt_present
(
match
,
~
"ignored"
),
ret
{
compile_lib_path
:
getopts
::
opt_str
(
match
es
,
~
"compile-lib-path"
),
run_lib_path
:
getopts
::
opt_str
(
match
es
,
~
"run-lib-path"
),
rustc_path
:
getopts
::
opt_str
(
match
es
,
~
"rustc-path"
),
src_base
:
getopts
::
opt_str
(
match
es
,
~
"src-base"
),
build_base
:
getopts
::
opt_str
(
match
es
,
~
"build-base"
),
aux_base
:
getopts
::
opt_str
(
match
es
,
~
"aux-base"
),
stage_id
:
getopts
::
opt_str
(
match
es
,
~
"stage-id"
),
mode
:
str_mode
(
getopts
::
opt_str
(
match
es
,
~
"mode"
)),
run_ignored
:
getopts
::
opt_present
(
match
es
,
~
"ignored"
),
filter
:
if
vec
::
len
(
match
.free
)
>
0u
{
option
::
some
(
match
.free
[
0
])
if
vec
::
len
(
match
es
.free
)
>
0u
{
option
::
some
(
match
es
.free
[
0
])
}
else
{
option
::
none
},
logfile
:
getopts
::
opt_maybe_str
(
match
,
~
"logfile"
),
runtool
:
getopts
::
opt_maybe_str
(
match
,
~
"runtool"
),
rustcflags
:
getopts
::
opt_maybe_str
(
match
,
~
"rustcflags"
),
verbose
:
getopts
::
opt_present
(
match
,
~
"verbose"
)};
logfile
:
getopts
::
opt_maybe_str
(
match
es
,
~
"logfile"
),
runtool
:
getopts
::
opt_maybe_str
(
match
es
,
~
"runtool"
),
rustcflags
:
getopts
::
opt_maybe_str
(
match
es
,
~
"rustcflags"
),
verbose
:
getopts
::
opt_present
(
match
es
,
~
"verbose"
)};
}
fn
log_config
(
config
:
config
)
{
...
...
src/libcore/dvec.rs
浏览文件 @
7b2026bf
...
...
@@ -97,7 +97,7 @@ fn borrow<B>(f: fn(-~[mut A]) -> B) -> B {
}
#[inline(always)]
fn
return
(
-
data
:
~
[
mut
A
])
{
fn
give_back
(
-
data
:
~
[
mut
A
])
{
unsafe
{
self
.data
<-
data
;
}
...
...
@@ -120,7 +120,7 @@ fn reserve(count: uint) {
*/
#[inline(always)]
fn
swap
(
f
:
fn
(
-~
[
mut
A
])
->
~
[
mut
A
])
{
self
.borrow
(|
v
|
self
.
return
(
f
(
v
)))
self
.borrow
(|
v
|
self
.
give_back
(
f
(
v
)))
}
/// Returns the number of elements currently in the dvec
...
...
@@ -128,7 +128,7 @@ fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
unchecked
{
do
self
.borrow
|
v
|
{
let
l
=
v
.len
();
self
.
return
(
v
);
self
.
give_back
(
v
);
l
}
}
...
...
@@ -145,7 +145,7 @@ fn pop() -> A {
do
self
.borrow
|
v
|
{
let
mut
v
<-
v
;
let
result
=
vec
::
pop
(
v
);
self
.
return
(
v
);
self
.
give_back
(
v
);
result
}
}
...
...
@@ -175,7 +175,7 @@ fn shift() -> A {
do
self
.borrow
|
v
|
{
let
mut
v
=
vec
::
from_mut
(
v
);
let
result
=
vec
::
shift
(
v
);
self
.
return
(
vec
::
to_mut
(
v
));
self
.
give_back
(
vec
::
to_mut
(
v
));
result
}
}
...
...
@@ -247,7 +247,7 @@ fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
unchecked
{
do
self
.borrow
|
v
|
{
let
w
=
vec
::
from_mut
(
copy
v
);
self
.
return
(
v
);
self
.
give_back
(
v
);
w
}
}
...
...
src/libstd/list.rs
浏览文件 @
7b2026bf
...
...
@@ -192,18 +192,18 @@ fn sub(&&a: int, &&b: int) -> int {
#[test]
fn
test_find_success
()
{
fn
match
(
&&
i
:
int
)
->
bool
{
ret
i
==
2
;
}
fn
match
_
(
&&
i
:
int
)
->
bool
{
ret
i
==
2
;
}
let
l
=
from_vec
(
~
[
0
,
1
,
2
]);
assert
(
list
::
find
(
l
,
match
)
==
option
::
some
(
2
));
assert
(
list
::
find
(
l
,
match
_
)
==
option
::
some
(
2
));
}
#[test]
fn
test_find_fail
()
{
fn
match
(
&&
_
i
:
int
)
->
bool
{
ret
false
;
}
fn
match
_
(
&&
_
i
:
int
)
->
bool
{
ret
false
;
}
let
l
=
from_vec
(
~
[
0
,
1
,
2
]);
let
empty
=
@
list
::
nil
::
<
int
>
;
assert
(
list
::
find
(
l
,
match
)
==
option
::
none
::
<
int
>
);
assert
(
list
::
find
(
empty
,
match
)
==
option
::
none
::
<
int
>
);
assert
(
list
::
find
(
l
,
match
_
)
==
option
::
none
::
<
int
>
);
assert
(
list
::
find
(
empty
,
match
_
)
==
option
::
none
::
<
int
>
);
}
#[test]
...
...
src/libstd/test.rs
浏览文件 @
7b2026bf
...
...
@@ -68,19 +68,19 @@ fn test_main(args: ~[~str], tests: ~[test_desc]) {
fn
parse_opts
(
args
:
~
[
~
str
])
->
opt_res
{
let
args_
=
vec
::
tail
(
args
);
let
opts
=
~
[
getopts
::
optflag
(
~
"ignored"
),
getopts
::
optopt
(
~
"logfile"
)];
let
match
=
let
match
es
=
alt
getopts
::
getopts
(
args_
,
opts
)
{
ok
(
m
)
{
m
}
err
(
f
)
{
ret
either
::
right
(
getopts
::
fail_str
(
f
))
}
};
let
filter
=
if
vec
::
len
(
match
.free
)
>
0u
{
option
::
some
(
match
.free
[
0
])
if
vec
::
len
(
match
es
.free
)
>
0u
{
option
::
some
(
match
es
.free
[
0
])
}
else
{
option
::
none
};
let
run_ignored
=
getopts
::
opt_present
(
match
,
~
"ignored"
);
let
logfile
=
getopts
::
opt_maybe_str
(
match
,
~
"logfile"
);
let
run_ignored
=
getopts
::
opt_present
(
match
es
,
~
"ignored"
);
let
logfile
=
getopts
::
opt_maybe_str
(
match
es
,
~
"logfile"
);
let
test_opts
=
{
filter
:
filter
,
run_ignored
:
run_ignored
,
logfile
:
logfile
};
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
7b2026bf
...
...
@@ -129,17 +129,17 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt,
// NB: there is some redundancy between this and expand_item, below, and
// they might benefit from some amount of semantic and language-UI merger.
fn
expand_mod_items
(
exts
:
hashmap
<~
str
,
syntax_extension
>
,
cx
:
ext_ctxt
,
module
:
ast
::
_
mod
,
fld
:
ast_fold
,
module
_
:
ast
::
_
mod
,
fld
:
ast_fold
,
orig
:
fn
@
(
ast
::
_
mod
,
ast_fold
)
->
ast
::
_
mod
)
->
ast
::
_
mod
{
// Fold the contents first:
let
module
=
orig
(
module
,
fld
);
let
module
_
=
orig
(
module_
,
fld
);
// For each item, look through the attributes. If any of them are
// decorated with "item decorators", then use that function to transform
// the item into a new set of items.
let
new_items
=
do
vec
::
flat_map
(
module
.items
)
|
item
|
{
let
new_items
=
do
vec
::
flat_map
(
module
_
.items
)
|
item
|
{
do
vec
::
foldr
(
item
.attrs
,
~
[
item
])
|
attr
,
items
|
{
let
mname
=
alt
attr
.node.value.node
{
ast
::
meta_word
(
n
)
{
n
}
...
...
@@ -159,7 +159,7 @@ fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt,
}
};
ret
{
items
:
new_items
with
module
};
ret
{
items
:
new_items
with
module
_
};
}
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
7b2026bf
...
...
@@ -789,7 +789,7 @@ fn parse_bottom_expr() -> pexpr {
ret
pexpr
(
self
.parse_while_expr
());
}
else
if
self
.eat_keyword
(
~
"loop"
)
{
ret
pexpr
(
self
.parse_loop_expr
());
}
else
if
self
.eat_keyword
(
~
"alt"
)
{
}
else
if
self
.eat_keyword
(
~
"alt"
)
||
self
.eat_keyword
(
~
"match"
)
{
ret
pexpr
(
self
.parse_alt_expr
());
}
else
if
self
.eat_keyword
(
~
"fn"
)
{
let
proto
=
self
.parse_fn_ty_proto
();
...
...
@@ -838,7 +838,7 @@ fn parse_bottom_expr() -> pexpr {
let
e
=
self
.parse_expr
();
ex
=
expr_assert
(
e
);
hi
=
e
.span.hi
;
}
else
if
self
.eat_keyword
(
~
"ret"
)
{
}
else
if
self
.eat_keyword
(
~
"ret"
)
||
self
.eat_keyword
(
~
"return"
)
{
if
can_begin_expr
(
self
.token
)
{
let
e
=
self
.parse_expr
();
hi
=
e
.span.hi
;
...
...
@@ -2569,7 +2569,11 @@ fn parse_foreign_mod_items(+first_item_attrs: ~[attribute]) ->
}
fn
parse_item_foreign_mod
()
->
item_info
{
self
.expect_keyword
(
~
"mod"
);
if
self
.is_keyword
(
~
"mod"
)
{
self
.expect_keyword
(
~
"mod"
);
}
else
{
self
.expect_keyword
(
~
"module"
);
}
let
id
=
self
.parse_ident
();
self
.expect
(
token
::
LBRACE
);
let
more_attrs
=
self
.parse_inner_attrs_and_next
();
...
...
@@ -2714,7 +2718,7 @@ fn parse_item(+attrs: ~[attribute], vis: visibility)
}
else
{
self
.parse_item_foreign_mod
()
}
}
else
if
self
.eat_keyword
(
~
"mod"
)
{
}
else
if
self
.eat_keyword
(
~
"mod"
)
||
self
.eat_keyword
(
~
"module"
)
{
self
.parse_item_mod
()
}
else
if
self
.eat_keyword
(
~
"type"
)
{
self
.parse_item_type
()
...
...
@@ -2919,8 +2923,14 @@ fn parse_crate_directive(first_outer_attr: ~[attribute]) ->
let
expect_mod
=
vec
::
len
(
outer_attrs
)
>
0u
;
let
lo
=
self
.span.lo
;
if
expect_mod
||
self
.is_keyword
(
~
"mod"
)
{
self
.expect_keyword
(
~
"mod"
);
if
expect_mod
||
self
.is_keyword
(
~
"mod"
)
||
self
.is_keyword
(
~
"module"
)
{
if
self
.is_keyword
(
~
"mod"
)
{
self
.expect_keyword
(
~
"mod"
);
}
else
{
self
.expect_keyword
(
~
"module"
);
}
let
id
=
self
.parse_ident
();
alt
self
.token
{
// mod x = "foo.rs";
...
...
@@ -2958,7 +2968,11 @@ fn parse_crate_directives(term: token::token,
// accept seeing the terminator next, so if we do see it then fail the
// same way parse_crate_directive would
if
vec
::
len
(
first_outer_attr
)
>
0u
&&
self
.token
==
term
{
self
.expect_keyword
(
~
"mod"
);
if
self
.is_keyword
(
~
"mod"
)
{
self
.expect_keyword
(
~
"mod"
);
}
else
{
self
.expect_keyword
(
~
"module"
);
}
}
let
mut
cdirs
:
~
[
@
crate_directive
]
=
~
[];
...
...
src/libsyntax/parse/token.rs
浏览文件 @
7b2026bf
...
...
@@ -327,11 +327,11 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
~
"fail"
,
~
"false"
,
~
"fn"
,
~
"for"
,
~
"if"
,
~
"iface"
,
~
"impl"
,
~
"import"
,
~
"let"
,
~
"log"
,
~
"loop"
,
~
"m
od
"
,
~
"mut"
,
~
"m
atch"
,
~
"mod"
,
~
"module
"
,
~
"mut"
,
~
"new"
,
~
"owned"
,
~
"pure"
,
~
"ret"
,
~
"ret"
,
~
"return"
,
~
"struct"
,
~
"true"
,
~
"trait"
,
~
"type"
,
~
"unchecked"
,
~
"unsafe"
,
...
...
src/rustc/driver/driver.rs
浏览文件 @
7b2026bf
...
...
@@ -408,19 +408,19 @@ fn host_triple() -> ~str {
};
}
fn
build_session_options
(
match
:
getopts
::
matches
,
fn
build_session_options
(
match
es
:
getopts
::
matches
,
demitter
:
diagnostic
::
emitter
)
->
@
session
::
options
{
let
crate_type
=
if
opt_present
(
match
,
~
"lib"
)
{
let
crate_type
=
if
opt_present
(
match
es
,
~
"lib"
)
{
session
::
lib_crate
}
else
if
opt_present
(
match
,
~
"bin"
)
{
}
else
if
opt_present
(
match
es
,
~
"bin"
)
{
session
::
bin_crate
}
else
{
session
::
unknown_crate
};
let
static
=
opt_present
(
match
,
~
"static"
);
let
static
=
opt_present
(
match
es
,
~
"static"
);
let
parse_only
=
opt_present
(
match
,
~
"parse-only"
);
let
no_trans
=
opt_present
(
match
,
~
"no-trans"
);
let
parse_only
=
opt_present
(
match
es
,
~
"parse-only"
);
let
no_trans
=
opt_present
(
match
es
,
~
"no-trans"
);
let
lint_levels
=
[
lint
::
allow
,
lint
::
warn
,
lint
::
deny
,
lint
::
forbid
];
...
...
@@ -429,8 +429,8 @@ fn build_session_options(match: getopts::matches,
for
lint_levels
.each
|
level
|
{
let
level_name
=
lint
::
level_to_str
(
level
);
let
level_short
=
level_name
.substr
(
0
,
1
)
.to_upper
();
let
flags
=
vec
::
append
(
getopts
::
opt_strs
(
match
,
level_short
),
getopts
::
opt_strs
(
match
,
level_name
));
let
flags
=
vec
::
append
(
getopts
::
opt_strs
(
match
es
,
level_short
),
getopts
::
opt_strs
(
match
es
,
level_name
));
for
flags
.each
|
lint_name
|
{
let
lint_name
=
str
::
replace
(
lint_name
,
~
"-"
,
~
"_"
);
alt
lint_dict
.find
(
lint_name
)
{
...
...
@@ -446,7 +446,7 @@ fn build_session_options(match: getopts::matches,
}
let
mut
debugging_opts
=
0u
;
let
debug_flags
=
getopts
::
opt_strs
(
match
,
~
"Z"
);
let
debug_flags
=
getopts
::
opt_strs
(
match
es
,
~
"Z"
);
let
debug_map
=
session
::
debugging_opts_map
();
for
debug_flags
.each
|
debug_flag
|
{
let
mut
this_bit
=
0u
;
...
...
@@ -466,34 +466,34 @@ fn build_session_options(match: getopts::matches,
let
output_type
=
if
parse_only
||
no_trans
{
link
::
output_type_none
}
else
if
opt_present
(
match
,
~
"S"
)
&&
opt_present
(
match
,
~
"emit-llvm"
)
{
}
else
if
opt_present
(
match
es
,
~
"S"
)
&&
opt_present
(
match
es
,
~
"emit-llvm"
)
{
link
::
output_type_llvm_assembly
}
else
if
opt_present
(
match
,
~
"S"
)
{
}
else
if
opt_present
(
match
es
,
~
"S"
)
{
link
::
output_type_assembly
}
else
if
opt_present
(
match
,
~
"c"
)
{
}
else
if
opt_present
(
match
es
,
~
"c"
)
{
link
::
output_type_object
}
else
if
opt_present
(
match
,
~
"emit-llvm"
)
{
}
else
if
opt_present
(
match
es
,
~
"emit-llvm"
)
{
link
::
output_type_bitcode
}
else
{
link
::
output_type_exe
};
let
extra_debuginfo
=
opt_present
(
match
,
~
"xg"
);
let
debuginfo
=
opt_present
(
match
,
~
"g"
)
||
extra_debuginfo
;
let
sysroot_opt
=
getopts
::
opt_maybe_str
(
match
,
~
"sysroot"
);
let
target_opt
=
getopts
::
opt_maybe_str
(
match
,
~
"target"
);
let
save_temps
=
getopts
::
opt_present
(
match
,
~
"save-temps"
);
let
extra_debuginfo
=
opt_present
(
match
es
,
~
"xg"
);
let
debuginfo
=
opt_present
(
match
es
,
~
"g"
)
||
extra_debuginfo
;
let
sysroot_opt
=
getopts
::
opt_maybe_str
(
match
es
,
~
"sysroot"
);
let
target_opt
=
getopts
::
opt_maybe_str
(
match
es
,
~
"target"
);
let
save_temps
=
getopts
::
opt_present
(
match
es
,
~
"save-temps"
);
alt
output_type
{
// unless we're emitting huamn-readable assembly, omit comments.
link
::
output_type_llvm_assembly
|
link
::
output_type_assembly
{}
_
{
debugging_opts
|
=
session
::
no_asm_comments
;
}
}
let
opt_level
:
uint
=
if
opt_present
(
match
,
~
"O"
)
{
if
opt_present
(
match
,
~
"opt-level"
)
{
if
opt_present
(
match
es
,
~
"O"
)
{
if
opt_present
(
match
es
,
~
"opt-level"
)
{
early_error
(
demitter
,
~
"-O and --opt-level both provided"
);
}
2u
}
else
if
opt_present
(
match
,
~
"opt-level"
)
{
alt
getopts
::
opt_str
(
match
,
~
"opt-level"
)
{
}
else
if
opt_present
(
match
es
,
~
"opt-level"
)
{
alt
getopts
::
opt_str
(
match
es
,
~
"opt-level"
)
{
~
"0"
{
0u
}
~
"1"
{
1u
}
~
"2"
{
2u
}
...
...
@@ -510,9 +510,9 @@ fn build_session_options(match: getopts::matches,
some
(
s
)
{
s
}
};
let
addl_lib_search_paths
=
getopts
::
opt_strs
(
match
,
~
"L"
);
let
cfg
=
parse_cfgspecs
(
getopts
::
opt_strs
(
match
,
~
"cfg"
));
let
test
=
opt_present
(
match
,
~
"test"
);
let
addl_lib_search_paths
=
getopts
::
opt_strs
(
match
es
,
~
"L"
);
let
cfg
=
parse_cfgspecs
(
getopts
::
opt_strs
(
match
es
,
~
"cfg"
));
let
test
=
opt_present
(
match
es
,
~
"test"
);
let
sopts
:
@
session
::
options
=
@
{
crate_type
:
crate_type
,
static
:
static
,
...
...
@@ -719,13 +719,13 @@ mod test {
// When the user supplies --test we should implicitly supply --cfg test
#[test]
fn
test_switch_implies_cfg_test
()
{
let
match
=
let
match
es
=
alt
getopts
::
getopts
(
~
[
~
"--test"
],
opts
())
{
ok
(
m
)
{
m
}
err
(
f
)
{
fail
~
"test_switch_implies_cfg_test: "
+
getopts
::
fail_str
(
f
);
}
};
let
sessopts
=
build_session_options
(
match
,
diagnostic
::
emit
);
let
sessopts
=
build_session_options
(
match
es
,
diagnostic
::
emit
);
let
sess
=
build_session
(
sessopts
,
diagnostic
::
emit
);
let
cfg
=
build_configuration
(
sess
,
~
"whatever"
,
str_input
(
~
""
));
assert
(
attr
::
contains_name
(
cfg
,
~
"test"
));
...
...
@@ -735,7 +735,7 @@ fn test_switch_implies_cfg_test() {
// another --cfg test
#[test]
fn
test_switch_implies_cfg_test_unless_cfg_test
()
{
let
match
=
let
match
es
=
alt
getopts
::
getopts
(
~
[
~
"--test"
,
~
"--cfg=test"
],
opts
())
{
ok
(
m
)
{
m
}
err
(
f
)
{
...
...
@@ -743,7 +743,7 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
getopts
::
fail_str
(
f
);
}
};
let
sessopts
=
build_session_options
(
match
,
diagnostic
::
emit
);
let
sessopts
=
build_session_options
(
match
es
,
diagnostic
::
emit
);
let
sess
=
build_session
(
sessopts
,
diagnostic
::
emit
);
let
cfg
=
build_configuration
(
sess
,
~
"whatever"
,
str_input
(
~
""
));
let
test_items
=
attr
::
find_meta_items_by_name
(
cfg
,
~
"test"
);
...
...
src/rustc/driver/rustc.rs
浏览文件 @
7b2026bf
...
...
@@ -128,7 +128,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
if
vec
::
len
(
args
)
==
0u
{
usage
(
binary
);
ret
;
}
let
match
=
let
match
es
=
alt
getopts
::
getopts
(
args
,
opts
())
{
ok
(
m
)
{
m
}
err
(
f
)
{
...
...
@@ -136,31 +136,31 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
}
};
if
opt_present
(
match
,
~
"h"
)
||
opt_present
(
match
,
~
"help"
)
{
if
opt_present
(
match
es
,
~
"h"
)
||
opt_present
(
matches
,
~
"help"
)
{
usage
(
binary
);
ret
;
}
let
lint_flags
=
vec
::
append
(
getopts
::
opt_strs
(
match
,
~
"W"
),
getopts
::
opt_strs
(
match
,
~
"warn"
));
let
lint_flags
=
vec
::
append
(
getopts
::
opt_strs
(
match
es
,
~
"W"
),
getopts
::
opt_strs
(
match
es
,
~
"warn"
));
if
lint_flags
.contains
(
~
"help"
)
{
describe_warnings
();
ret
;
}
if
getopts
::
opt_strs
(
match
,
~
"Z"
)
.contains
(
~
"help"
)
{
if
getopts
::
opt_strs
(
match
es
,
~
"Z"
)
.contains
(
~
"help"
)
{
describe_debug_flags
();
ret
;
}
if
opt_present
(
match
,
~
"v"
)
||
opt_present
(
match
,
~
"version"
)
{
if
opt_present
(
match
es
,
~
"v"
)
||
opt_present
(
matches
,
~
"version"
)
{
version
(
binary
);
ret
;
}
let
input
=
alt
vec
::
len
(
match
.free
)
{
let
input
=
alt
vec
::
len
(
match
es
.free
)
{
0u
{
early_error
(
demitter
,
~
"no input filename given"
)
}
1u
{
let
ifile
=
match
.free
[
0
];
let
ifile
=
match
es
.free
[
0
];
if
ifile
==
~
"-"
{
let
src
=
str
::
from_bytes
(
io
::
stdin
()
.read_whole_stream
());
str_input
(
src
)
...
...
@@ -171,20 +171,20 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
_
{
early_error
(
demitter
,
~
"multiple input filenames provided"
)
}
};
let
sopts
=
build_session_options
(
match
,
demitter
);
let
sopts
=
build_session_options
(
match
es
,
demitter
);
let
sess
=
build_session
(
sopts
,
demitter
);
let
odir
=
getopts
::
opt_maybe_str
(
match
,
~
"out-dir"
);
let
ofile
=
getopts
::
opt_maybe_str
(
match
,
~
"o"
);
let
odir
=
getopts
::
opt_maybe_str
(
match
es
,
~
"out-dir"
);
let
ofile
=
getopts
::
opt_maybe_str
(
match
es
,
~
"o"
);
let
cfg
=
build_configuration
(
sess
,
binary
,
input
);
let
pretty
=
option
::
map
(
getopts
::
opt_default
(
match
,
~
"pretty"
,
option
::
map
(
getopts
::
opt_default
(
match
es
,
~
"pretty"
,
~
"normal"
),
|
a
|
parse_pretty
(
sess
,
a
)
);
alt
pretty
{
some
::
<
pp_mode
>
(
ppm
)
{
pretty_print_input
(
sess
,
cfg
,
input
,
ppm
);
ret
;
}
none
::
<
pp_mode
>
{
/* continue */
}
}
let
ls
=
opt_present
(
match
,
~
"ls"
);
let
ls
=
opt_present
(
match
es
,
~
"ls"
);
if
ls
{
alt
input
{
file_input
(
ifile
)
{
...
...
src/rustc/metadata/creader.rs
浏览文件 @
7b2026bf
...
...
@@ -78,10 +78,10 @@ fn warn_if_multiple_versions(diag: span_handler,
if
matches
.len
()
!=
1u
{
diag
.handler
()
.warn
(
fmt!
{
"using multiple versions of crate `%s`"
,
*
name
});
for
matches
.each
|
match
|
{
diag
.span_note
(
match
.span
,
~
"used here"
);
for
matches
.each
|
match
_
|
{
diag
.span_note
(
match
_
.span
,
~
"used here"
);
let
attrs
=
~
[
attr
::
mk_attr
(
attr
::
mk_list_item
(
@~
"link"
,
*
match
.metas
))
attr
::
mk_attr
(
attr
::
mk_list_item
(
@~
"link"
,
*
match
_
.metas
))
];
loader
::
note_linkage_attrs
(
diag
,
attrs
);
}
...
...
src/rustc/metadata/encoder.rs
浏览文件 @
7b2026bf
...
...
@@ -157,11 +157,11 @@ fn encode_class_item_paths(ebml_w: ebml::writer,
}
fn
encode_module_item_paths
(
ebml_w
:
ebml
::
writer
,
ecx
:
@
encode_ctxt
,
module
:
_
mod
,
path
:
~
[
ident
],
module
_
:
_
mod
,
path
:
~
[
ident
],
&
index
:
~
[
entry
<~
str
>
])
{
for
module
.items.each
|
it
|
{
for
module
_
.items.each
|
it
|
{
if
!
reachable
(
ecx
,
it
.id
)
||
!
ast_util
::
is_exported
(
it
.ident
,
module
)
{
again
;
}
!
ast_util
::
is_exported
(
it
.ident
,
module
_
)
{
again
;
}
if
!
ast_util
::
is_item_impl
(
it
)
{
add_to_index
(
ebml_w
,
path
,
index
,
it
.ident
);
}
...
...
src/rustc/metadata/loader.rs
浏览文件 @
7b2026bf
...
...
@@ -106,9 +106,9 @@ fn find_library_crate_aux(cx: ctxt,
cx
.diag
.span_err
(
cx
.span
,
fmt!
{
"multiple matching crates for `%s`"
,
*
crate_name
});
cx
.diag
.handler
()
.note
(
~
"candidates:"
);
for
matches
.each
|
match
|
{
cx
.diag
.handler
()
.note
(
fmt!
{
"path: %s"
,
match
.ident
});
let
attrs
=
decoder
::
get_crate_attributes
(
match
.data
);
for
matches
.each
|
match
_
|
{
cx
.diag
.handler
()
.note
(
fmt!
{
"path: %s"
,
match
_
.ident
});
let
attrs
=
decoder
::
get_crate_attributes
(
match
_
.data
);
note_linkage_attrs
(
cx
.diag
,
attrs
);
}
cx
.diag
.handler
()
.abort_if_errors
();
...
...
src/rustc/middle/check_alt.rs
浏览文件 @
7b2026bf
...
...
@@ -332,13 +332,13 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
pat_box
(
a
)
|
pat_uniq
(
a
)
{
some
(
vec
::
append
(
~
[
a
],
vec
::
tail
(
r
)))
}
pat_lit
(
expr
)
{
let
e_v
=
eval_const_expr
(
tcx
,
expr
);
let
match
=
alt
check
ctor_id
{
let
match
_
=
alt
check
ctor_id
{
val
(
v
)
{
compare_const_vals
(
e_v
,
v
)
==
0
}
range
(
c_lo
,
c_hi
)
{
compare_const_vals
(
c_lo
,
e_v
)
>=
0
&&
compare_const_vals
(
c_hi
,
e_v
)
<=
0
}
single
{
true
}
};
if
match
{
some
(
vec
::
tail
(
r
))
}
else
{
none
}
if
match
_
{
some
(
vec
::
tail
(
r
))
}
else
{
none
}
}
pat_range
(
lo
,
hi
)
{
let
(
c_lo
,
c_hi
)
=
alt
check
ctor_id
{
...
...
@@ -348,9 +348,9 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
};
let
v_lo
=
eval_const_expr
(
tcx
,
lo
),
v_hi
=
eval_const_expr
(
tcx
,
hi
);
let
match
=
compare_const_vals
(
c_lo
,
v_lo
)
>=
0
&&
let
match
_
=
compare_const_vals
(
c_lo
,
v_lo
)
>=
0
&&
compare_const_vals
(
c_hi
,
v_hi
)
<=
0
;
if
match
{
some
(
vec
::
tail
(
r
))
}
else
{
none
}
if
match
_
{
some
(
vec
::
tail
(
r
))
}
else
{
none
}
}
}
}
...
...
src/rustc/middle/resolve3.rs
浏览文件 @
7b2026bf
...
...
@@ -495,8 +495,8 @@ fn unused_import_lint_level(session: session) -> level {
/// Creates a new module in this set of name bindings.
fn
define_module
(
parent_link
:
ParentLink
,
def_id
:
option
<
def_id
>
)
{
if
self
.module_def
==
NoModuleDef
{
let
module
=
@
Module
(
parent_link
,
def_id
);
self
.module_def
=
ModuleDef
(
module
);
let
module
_
=
@
Module
(
parent_link
,
def_id
);
self
.module_def
=
ModuleDef
(
module
_
);
}
}
...
...
@@ -519,7 +519,7 @@ fn define_impl(implementation: @Impl) {
fn
get_module_if_available
()
->
option
<@
Module
>
{
alt
self
.module_def
{
NoModuleDef
{
ret
none
;
}
ModuleDef
(
module
)
{
ret
some
(
module
);
}
ModuleDef
(
module
_
)
{
ret
some
(
module_
);
}
}
}
...
...
@@ -533,8 +533,8 @@ fn get_module() -> @Module {
fail
~
"get_module called on a node with no module definition!"
;
}
ModuleDef
(
module
)
{
ret
module
;
ModuleDef
(
module
_
)
{
ret
module
_
;
}
}
}
...
...
@@ -561,8 +561,8 @@ fn def_for_namespace(namespace: Namespace) -> option<def> {
NoModuleDef
{
ret
none
;
}
ModuleDef
(
module
)
{
alt
module
.def_id
{
ModuleDef
(
module
_
)
{
alt
module
_
.def_id
{
none
{
ret
none
;
}
...
...
@@ -765,8 +765,8 @@ fn build_reduced_graph(this: @Resolver) {
fn
get_module_from_parent
(
reduced_graph_parent
:
ReducedGraphParent
)
->
@
Module
{
alt
reduced_graph_parent
{
ModuleReducedGraphParent
(
module
)
{
ret
module
;
ModuleReducedGraphParent
(
module
_
)
{
ret
module
_
;
}
}
}
...
...
@@ -789,19 +789,19 @@ fn add_child(name: Atom,
// child name directly. Otherwise, we create or reuse an anonymous
// module and add the child to that.
let
mut
module
;
let
mut
module
_
;
alt
reduced_graph_parent
{
ModuleReducedGraphParent
(
parent_module
)
{
module
=
parent_module
;
module
_
=
parent_module
;
}
}
// Add or reuse the child.
let
new_parent
=
ModuleReducedGraphParent
(
module
);
alt
module
.children
.find
(
name
)
{
let
new_parent
=
ModuleReducedGraphParent
(
module
_
);
alt
module
_
.children
.find
(
name
)
{
none
{
let
child
=
@
NameBindings
();
module
.children
.insert
(
name
,
child
);
module
_
.children
.insert
(
name
,
child
);
ret
(
child
,
new_parent
);
}
some
(
child
)
{
...
...
@@ -843,8 +843,8 @@ fn block_needs_anonymous_module(block: blk) -> bool {
fn
get_parent_link
(
parent
:
ReducedGraphParent
,
name
:
Atom
)
->
ParentLink
{
alt
parent
{
ModuleReducedGraphParent
(
module
)
{
ret
ModuleParentLink
(
module
,
name
);
ModuleReducedGraphParent
(
module
_
)
{
ret
ModuleParentLink
(
module
_
,
name
);
}
}
}
...
...
@@ -858,7 +858,7 @@ fn build_reduced_graph_for_item(item: @item,
let
(
name_bindings
,
new_parent
)
=
self
.add_child
(
atom
,
parent
);
alt
item
.node
{
item_mod
(
module
)
{
item_mod
(
module
_
)
{
let
parent_link
=
self
.get_parent_link
(
new_parent
,
atom
);
let
def_id
=
{
crate
:
0
,
node
:
item
.id
};
(
*
name_bindings
)
.define_module
(
parent_link
,
some
(
def_id
));
...
...
@@ -866,7 +866,7 @@ fn build_reduced_graph_for_item(item: @item,
let
new_parent
=
ModuleReducedGraphParent
((
*
name_bindings
)
.get_module
());
visit_mod
(
module
,
item
.span
,
item
.id
,
new_parent
,
visitor
);
visit_mod
(
module
_
,
item
.span
,
item
.id
,
new_parent
,
visitor
);
}
item_foreign_mod
(
foreign_module
)
{
let
parent_link
=
self
.get_parent_link
(
new_parent
,
atom
);
...
...
@@ -1074,7 +1074,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item,
}
// Build up the import directives.
let
module
=
self
.get_module_from_parent
(
parent
);
let
module
_
=
self
.get_module_from_parent
(
parent
);
alt
view_path
.node
{
view_path_simple
(
binding
,
full_path
,
_
)
{
let
target_atom
=
...
...
@@ -1084,7 +1084,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item,
(
*
self
.atom_table
)
.intern
(
source_ident
);
let
subclass
=
@
SingleImport
(
target_atom
,
source_atom
);
self
.build_import_directive
(
module
,
self
.build_import_directive
(
module
_
,
module_path
,
subclass
,
view_path
.span
);
...
...
@@ -1094,14 +1094,14 @@ fn build_reduced_graph_for_view_item(view_item: @view_item,
let
name
=
source_ident
.node.name
;
let
atom
=
(
*
self
.atom_table
)
.intern
(
name
);
let
subclass
=
@
SingleImport
(
atom
,
atom
);
self
.build_import_directive
(
module
,
self
.build_import_directive
(
module
_
,
module_path
,
subclass
,
view_path
.span
);
}
}
view_path_glob
(
_
,
_
)
{
self
.build_import_directive
(
module
,
self
.build_import_directive
(
module
_
,
module_path
,
@
GlobImport
,
view_path
.span
);
...
...
@@ -1111,7 +1111,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item,
}
view_item_export
(
view_paths
)
{
let
module
=
self
.get_module_from_parent
(
parent
);
let
module
_
=
self
.get_module_from_parent
(
parent
);
for
view_paths
.each
|
view_path
|
{
alt
view_path
.node
{
view_path_simple
(
ident
,
full_path
,
ident_id
)
{
...
...
@@ -1130,7 +1130,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item,
}
let
atom
=
(
*
self
.atom_table
)
.intern
(
ident
);
module
.exported_names
.insert
(
atom
,
ident_id
);
module
_
.exported_names
.insert
(
atom
,
ident_id
);
}
view_path_glob
(
*
)
{
...
...
@@ -1162,7 +1162,7 @@ fn build_reduced_graph_for_view_item(view_item: @view_item,
let
atom
=
(
*
self
.atom_table
)
.intern
(
path_list_ident
.node.name
);
let
id
=
path_list_ident
.node.id
;
module
.exported_names
.insert
(
atom
,
id
);
module
_
.exported_names
.insert
(
atom
,
id
);
}
}
}
...
...
@@ -1360,12 +1360,12 @@ fn build_reduced_graph_for_external_crate(root: @Module) {
}
}
}
ModuleDef
(
module
)
{
ModuleDef
(
module
_
)
{
debug!
{
"(building reduced graph for
\
external crate) already created
\
module"
};
module
.def_id
=
some
(
def_id
);
modules
.insert
(
def_id
,
module
);
module
_
.def_id
=
some
(
def_id
);
modules
.insert
(
def_id
,
module
_
);
}
}
}
...
...
@@ -1446,11 +1446,11 @@ trait method '%?'",
self
.build_reduced_graph_for_impls_in_external_module_subtree
(
root
);
}
fn
build_reduced_graph_for_impls_in_external_module_subtree
(
module
:
fn
build_reduced_graph_for_impls_in_external_module_subtree
(
module
_
:
@
Module
)
{
self
.build_reduced_graph_for_impls_in_external_module
(
module
);
self
.build_reduced_graph_for_impls_in_external_module
(
module
_
);
for
module
.children.each
|
_
name
,
child_node
|
{
for
module
_
.children.each
|
_
name
,
child_node
|
{
alt
(
*
child_node
)
.get_module_if_available
()
{
none
{
// Nothing to do.
...
...
@@ -1464,7 +1464,7 @@ fn build_reduced_graph_for_impls_in_external_module_subtree(module:
}
}
fn
build_reduced_graph_for_impls_in_external_module
(
module
:
@
Module
)
{
fn
build_reduced_graph_for_impls_in_external_module
(
module
_
:
@
Module
)
{
// XXX: This is really unfortunate. decoder::each_path can produce
// false positives, since, in the crate metadata, a trait named 'bar'
// in module 'foo' defining a method named 'baz' will result in the
...
...
@@ -1475,14 +1475,14 @@ fn build_reduced_graph_for_impls_in_external_module(module: @Module) {
debug!
{
"(building reduced graph for impls in external crate) looking
\
for impls in `%s` (%?)"
,
self
.module_to_str
(
module
),
copy
module
.def_id
};
self
.module_to_str
(
module
_
),
copy
module
_
.def_id
};
alt
module
.def_id
{
alt
module
_
.def_id
{
none
{
debug!
{
"(building reduced graph for impls in external
\
module) no def ID for `%s`, skipping"
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
ret
;
}
some
(
_
)
{
...
...
@@ -1491,7 +1491,7 @@ fn build_reduced_graph_for_impls_in_external_module(module: @Module) {
}
let
impls_in_module
=
get_impls_for_mod
(
self
.session.cstore
,
get
(
module
.def_id
),
get
(
module
_
.def_id
),
none
);
// Intern def IDs to prevent duplicates.
...
...
@@ -1507,39 +1507,39 @@ fn build_reduced_graph_for_impls_in_external_module(module: @Module) {
added impl `%s` (%?) to `%s`"
,
*
implementation
.ident
,
implementation
.did
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
let
name
=
(
*
self
.atom_table
)
.intern
(
implementation
.ident
);
let
(
name_bindings
,
_
)
=
self
.add_child
(
name
,
ModuleReducedGraphParent
(
module
));
self
.add_child
(
name
,
ModuleReducedGraphParent
(
module
_
));
name_bindings
.impl_defs
+=
~
[
implementation
];
}
}
/// Creates and adds an import directive to the given module.
fn
build_import_directive
(
module
:
@
Module
,
fn
build_import_directive
(
module
_
:
@
Module
,
module_path
:
@
dvec
<
Atom
>
,
subclass
:
@
ImportDirectiveSubclass
,
span
:
span
)
{
let
directive
=
@
ImportDirective
(
module_path
,
subclass
,
span
);
module
.imports
.push
(
directive
);
module
_
.imports
.push
(
directive
);
// Bump the reference count on the name. Or, if this is a glob, set
// the appropriate flag.
alt
*
subclass
{
SingleImport
(
target
,
_
)
{
alt
module
.import_resolutions
.find
(
target
)
{
alt
module
_
.import_resolutions
.find
(
target
)
{
some
(
resolution
)
{
resolution
.outstanding_references
+=
1u
;
}
none
{
let
resolution
=
@
ImportResolution
(
span
);
resolution
.outstanding_references
=
1u
;
module
.import_resolutions
.insert
(
target
,
resolution
);
module
_
.import_resolutions
.insert
(
target
,
resolution
);
}
}
}
...
...
@@ -1547,7 +1547,7 @@ fn build_import_directive(module: @Module,
// Set the glob flag. This tells us that we don't know the
// module's exports ahead of time.
module
.glob_count
+=
1u
;
module
_
.glob_count
+=
1u
;
}
}
...
...
@@ -1596,12 +1596,12 @@ fn resolve_imports() {
* Attempts to resolve imports for the given module and all of its
* submodules.
*/
fn
resolve_imports_for_module_subtree
(
module
:
@
Module
)
{
fn
resolve_imports_for_module_subtree
(
module
_
:
@
Module
)
{
debug!
{
"(resolving imports for module subtree) resolving %s"
,
self
.module_to_str
(
module
)};
self
.resolve_imports_for_module
(
module
);
self
.module_to_str
(
module
_
)};
self
.resolve_imports_for_module
(
module
_
);
for
module
.children.each
|
_
name
,
child_node
|
{
for
module
_
.children.each
|
_
name
,
child_node
|
{
alt
(
*
child_node
)
.get_module_if_available
()
{
none
{
// Nothing to do.
...
...
@@ -1612,25 +1612,25 @@ fn resolve_imports_for_module_subtree(module: @Module) {
}
}
for
module
.anonymous_children.each
|
_
block_id
,
child_module
|
{
for
module
_
.anonymous_children.each
|
_
block_id
,
child_module
|
{
self
.resolve_imports_for_module_subtree
(
child_module
);
}
}
/// Attempts to resolve imports for the given module only.
fn
resolve_imports_for_module
(
module
:
@
Module
)
{
if
(
*
module
)
.all_imports_resolved
()
{
fn
resolve_imports_for_module
(
module
_
:
@
Module
)
{
if
(
*
module
_
)
.all_imports_resolved
()
{
debug!
{
"(resolving imports for module) all imports resolved for
\
%s"
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
ret
;
}
let
import_count
=
module
.imports
.len
();
while
module
.resolved_import_count
<
import_count
{
let
import_index
=
module
.resolved_import_count
;
let
import_directive
=
module
.imports
.get_elt
(
import_index
);
alt
self
.resolve_import_for_module
(
module
,
import_directive
)
{
let
import_count
=
module
_
.imports
.len
();
while
module
_
.resolved_import_count
<
import_count
{
let
import_index
=
module
_
.resolved_import_count
;
let
import_directive
=
module
_
.imports
.get_elt
(
import_index
);
alt
self
.resolve_import_for_module
(
module
_
,
import_directive
)
{
Failed
{
// We presumably emitted an error. Continue.
self
.session
.span_err
(
import_directive
.span
,
...
...
@@ -1645,7 +1645,7 @@ fn resolve_imports_for_module(module: @Module) {
}
}
module
.resolved_import_count
+=
1u
;
module
_
.resolved_import_count
+=
1u
;
}
}
...
...
@@ -1656,7 +1656,7 @@ fn resolve_imports_for_module(module: @Module) {
* currently-unresolved imports, or success if we know the name exists.
* If successful, the resolved bindings are written into the module.
*/
fn
resolve_import_for_module
(
module
:
@
Module
,
fn
resolve_import_for_module
(
module
_
:
@
Module
,
import_directive
:
@
ImportDirective
)
->
ResolveResult
<
()
>
{
...
...
@@ -1666,18 +1666,18 @@ fn resolve_import_for_module(module: @Module,
debug!
{
"(resolving import for module) resolving import `%s::...` in
\
`%s`"
,
*
(
*
self
.atom_table
)
.atoms_to_str
((
*
module_path
)
.get
()),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
// One-level renaming imports of the form `import foo = bar;` are
// handled specially.
if
(
*
module_path
)
.len
()
==
0u
{
resolution_result
=
self
.resolve_one_level_renaming_import
(
module
,
self
.resolve_one_level_renaming_import
(
module
_
,
import_directive
);
}
else
{
// First, resolve the module path for the directive, if necessary.
alt
self
.resolve_module_path_for_import
(
module
,
alt
self
.resolve_module_path_for_import
(
module
_
,
module_path
,
NoXray
,
import_directive
.span
)
{
...
...
@@ -1695,7 +1695,7 @@ fn resolve_import_for_module(module: @Module,
alt
*
import_directive
.subclass
{
SingleImport
(
target
,
source
)
{
resolution_result
=
self
.resolve_single_import
(
module
,
self
.resolve_single_import
(
module
_
,
containing_module
,
target
,
source
);
...
...
@@ -1703,7 +1703,7 @@ fn resolve_import_for_module(module: @Module,
GlobImport
{
let
span
=
import_directive
.span
;
resolution_result
=
self
.resolve_glob_import
(
module
,
self
.resolve_glob_import
(
module
_
,
containing_module
,
span
);
}
...
...
@@ -1731,8 +1731,8 @@ fn resolve_import_for_module(module: @Module,
if
resolution_result
!=
Indeterminate
{
alt
*
import_directive
.subclass
{
GlobImport
{
assert
module
.glob_count
>=
1u
;
module
.glob_count
-=
1u
;
assert
module
_
.glob_count
>=
1u
;
module
_
.glob_count
-=
1u
;
}
SingleImport
(
*
)
{
// Ignore.
...
...
@@ -1743,7 +1743,7 @@ fn resolve_import_for_module(module: @Module,
ret
resolution_result
;
}
fn
resolve_single_import
(
module
:
@
Module
,
containing_module
:
@
Module
,
fn
resolve_single_import
(
module
_
:
@
Module
,
containing_module
:
@
Module
,
target
:
Atom
,
source
:
Atom
)
->
ResolveResult
<
()
>
{
...
...
@@ -1752,7 +1752,7 @@ fn resolve_single_import(module: @Module, containing_module: @Module,
*
(
*
self
.atom_table
)
.atom_to_str
(
target
),
self
.module_to_str
(
containing_module
),
*
(
*
self
.atom_table
)
.atom_to_str
(
source
),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
if
!
self
.name_is_exported
(
containing_module
,
source
)
{
debug!
{
"(resolving single import) name `%s` is unexported"
,
...
...
@@ -1903,8 +1903,8 @@ fn get_import_binding(import_resolution:
}
// We've successfully resolved the import. Write the results in.
assert
module
.import_resolutions
.contains_key
(
target
);
let
import_resolution
=
module
.import_resolutions
.get
(
target
);
assert
module
_
.import_resolutions
.contains_key
(
target
);
let
import_resolution
=
module
_
.import_resolutions
.get
(
target
);
alt
module_result
{
BoundResult
(
target_module
,
name_bindings
)
{
...
...
@@ -1974,7 +1974,7 @@ fn get_import_binding(import_resolution:
* succeeds or bails out (as importing * from an empty module or a module
* that exports nothing is valid).
*/
fn
resolve_glob_import
(
module
:
@
Module
,
fn
resolve_glob_import
(
module
_
:
@
Module
,
containing_module
:
@
Module
,
span
:
span
)
->
ResolveResult
<
()
>
{
...
...
@@ -2007,10 +2007,10 @@ fn resolve_glob_import(module: @Module,
debug!
{
"(resolving glob import) writing module resolution
\
%? into `%s`"
,
is_none
(
target_import_resolution
.module_target
),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
// Here we merge two import resolutions.
alt
module
.import_resolutions
.find
(
atom
)
{
alt
module
_
.import_resolutions
.find
(
atom
)
{
none
{
// Simple: just copy the old import resolution.
let
new_import_resolution
=
...
...
@@ -2024,7 +2024,7 @@ fn resolve_glob_import(module: @Module,
new_import_resolution
.impl_target
=
copy
target_import_resolution
.impl_target
;
module
.import_resolutions
.insert
module
_
.import_resolutions
.insert
(
atom
,
new_import_resolution
);
}
some
(
dest_import_resolution
)
{
...
...
@@ -2082,11 +2082,11 @@ fn resolve_glob_import(module: @Module,
}
let
mut
dest_import_resolution
;
alt
module
.import_resolutions
.find
(
atom
)
{
alt
module
_
.import_resolutions
.find
(
atom
)
{
none
{
// Create a new import resolution from this child.
dest_import_resolution
=
@
ImportResolution
(
span
);
module
.import_resolutions
.insert
module
_
.import_resolutions
.insert
(
atom
,
dest_import_resolution
);
}
some
(
existing_import_resolution
)
{
...
...
@@ -2099,7 +2099,7 @@ fn resolve_glob_import(module: @Module,
to `%s`"
,
*
(
*
self
.atom_table
)
.atom_to_str
(
atom
),
self
.module_to_str
(
containing_module
),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
// Merge the child item into the import resolution.
if
(
*
name_bindings
)
.defined_in_namespace
(
ModuleNS
)
{
...
...
@@ -2128,14 +2128,14 @@ fn resolve_glob_import(module: @Module,
ret
Success
(());
}
fn
resolve_module_path_from_root
(
module
:
@
Module
,
fn
resolve_module_path_from_root
(
module
_
:
@
Module
,
module_path
:
@
dvec
<
Atom
>
,
index
:
uint
,
xray
:
XrayFlag
,
span
:
span
)
->
ResolveResult
<@
Module
>
{
let
mut
search_module
=
module
;
let
mut
search_module
=
module
_
;
let
mut
index
=
index
;
let
module_path_len
=
(
*
module_path
)
.len
();
...
...
@@ -2168,8 +2168,8 @@ fn resolve_module_path_from_root(module: @Module,
atom_to_str
(
name
)});
ret
Failed
;
}
ModuleDef
(
module
)
{
search_module
=
module
;
ModuleDef
(
module
_
)
{
search_module
=
module
_
;
}
}
}
...
...
@@ -2185,7 +2185,7 @@ fn resolve_module_path_from_root(module: @Module,
* Attempts to resolve the module part of an import directive rooted at
* the given module.
*/
fn
resolve_module_path_for_import
(
module
:
@
Module
,
fn
resolve_module_path_for_import
(
module
_
:
@
Module
,
module_path
:
@
dvec
<
Atom
>
,
xray
:
XrayFlag
,
span
:
span
)
...
...
@@ -2197,14 +2197,14 @@ fn resolve_module_path_for_import(module: @Module,
debug!
{
"(resolving module path for import) processing `%s` rooted at
\
`%s`"
,
*
(
*
self
.atom_table
)
.atoms_to_str
((
*
module_path
)
.get
()),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
// The first element of the module path must be in the current scope
// chain.
let
first_element
=
(
*
module_path
)
.get_elt
(
0u
);
let
mut
search_module
;
alt
self
.resolve_module_in_lexical_scope
(
module
,
first_element
)
{
alt
self
.resolve_module_in_lexical_scope
(
module
_
,
first_element
)
{
Failed
{
self
.session
.span_err
(
span
,
~
"unresolved name"
);
ret
Failed
;
...
...
@@ -2226,7 +2226,7 @@ fn resolve_module_path_for_import(module: @Module,
span
);
}
fn
resolve_item_in_lexical_scope
(
module
:
@
Module
,
fn
resolve_item_in_lexical_scope
(
module
_
:
@
Module
,
name
:
Atom
,
namespace
:
Namespace
)
->
ResolveResult
<
Target
>
{
...
...
@@ -2235,16 +2235,16 @@ fn resolve_item_in_lexical_scope(module: @Module,
namespace %? in `%s`"
,
*
(
*
self
.atom_table
)
.atom_to_str
(
name
),
namespace
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
// The current module node is handled specially. First, check for
// its immediate children.
alt
module
.children
.find
(
name
)
{
alt
module
_
.children
.find
(
name
)
{
some
(
name_bindings
)
if
(
*
name_bindings
)
.defined_in_namespace
(
namespace
)
{
ret
Success
(
Target
(
module
,
name_bindings
));
ret
Success
(
Target
(
module
_
,
name_bindings
));
}
some
(
_
)
|
none
{
/* Not found; continue. */
}
}
...
...
@@ -2254,7 +2254,7 @@ fn resolve_item_in_lexical_scope(module: @Module,
// adjacent import statements are processed as though they mutated the
// current scope.
alt
module
.import_resolutions
.find
(
name
)
{
alt
module
_
.import_resolutions
.find
(
name
)
{
none
{
// Not found; continue.
}
...
...
@@ -2275,7 +2275,7 @@ fn resolve_item_in_lexical_scope(module: @Module,
}
// Finally, proceed up the scope chain looking for parent modules.
let
mut
search_module
=
module
;
let
mut
search_module
=
module
_
;
loop
{
// Go to the next parent.
alt
search_module
.parent_link
{
...
...
@@ -2313,10 +2313,10 @@ fn resolve_item_in_lexical_scope(module: @Module,
}
}
fn
resolve_module_in_lexical_scope
(
module
:
@
Module
,
name
:
Atom
)
fn
resolve_module_in_lexical_scope
(
module
_
:
@
Module
,
name
:
Atom
)
->
ResolveResult
<@
Module
>
{
alt
self
.resolve_item_in_lexical_scope
(
module
,
name
,
ModuleNS
)
{
alt
self
.resolve_item_in_lexical_scope
(
module
_
,
name
,
ModuleNS
)
{
Success
(
target
)
{
alt
target
.bindings.module_def
{
NoModuleDef
{
...
...
@@ -2324,8 +2324,8 @@ fn resolve_module_in_lexical_scope(module: @Module, name: Atom)
wasn't actually a module!"
};
ret
Failed
;
}
ModuleDef
(
module
)
{
ret
Success
(
module
);
ModuleDef
(
module
_
)
{
ret
Success
(
module
_
);
}
}
}
...
...
@@ -2342,9 +2342,9 @@ fn resolve_module_in_lexical_scope(module: @Module, name: Atom)
}
}
fn
name_is_exported
(
module
:
@
Module
,
name
:
Atom
)
->
bool
{
ret
module
.exported_names
.size
()
==
0u
||
module
.exported_names
.contains_key
(
name
);
fn
name_is_exported
(
module
_
:
@
Module
,
name
:
Atom
)
->
bool
{
ret
module
_
.exported_names
.size
()
==
0u
||
module
_
.exported_names
.contains_key
(
name
);
}
/**
...
...
@@ -2352,7 +2352,7 @@ fn name_is_exported(module: @Module, name: Atom) -> bool {
* given namespace. If successful, returns the target corresponding to
* the name.
*/
fn
resolve_name_in_module
(
module
:
@
Module
,
fn
resolve_name_in_module
(
module
_
:
@
Module
,
name
:
Atom
,
namespace
:
Namespace
,
xray
:
XrayFlag
)
...
...
@@ -2360,21 +2360,21 @@ fn resolve_name_in_module(module: @Module,
debug!
{
"(resolving name in module) resolving `%s` in `%s`"
,
*
(
*
self
.atom_table
)
.atom_to_str
(
name
),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
if
xray
==
NoXray
&&
!
self
.name_is_exported
(
module
,
name
)
{
if
xray
==
NoXray
&&
!
self
.name_is_exported
(
module
_
,
name
)
{
debug!
{
"(resolving name in module) name `%s` is unexported"
,
*
(
*
self
.atom_table
)
.atom_to_str
(
name
)};
ret
Failed
;
}
// First, check the direct children of the module.
alt
module
.children
.find
(
name
)
{
alt
module
_
.children
.find
(
name
)
{
some
(
name_bindings
)
if
(
*
name_bindings
)
.defined_in_namespace
(
namespace
)
{
debug!
{
"(resolving name in module) found node as child"
};
ret
Success
(
Target
(
module
,
name_bindings
));
ret
Success
(
Target
(
module
_
,
name_bindings
));
}
some
(
_
)
|
none
{
// Continue.
...
...
@@ -2384,13 +2384,13 @@ fn resolve_name_in_module(module: @Module,
// Next, check the module's imports. If the module has a glob, then
// we bail out; we don't know its imports yet.
if
module
.glob_count
>
0u
{
if
module
_
.glob_count
>
0u
{
debug!
{
"(resolving name in module) module has glob; bailing out"
};
ret
Indeterminate
;
}
// Otherwise, we check the list of resolved imports.
alt
module
.import_resolutions
.find
(
name
)
{
alt
module
_
.import_resolutions
.find
(
name
)
{
some
(
import_resolution
)
{
if
import_resolution
.outstanding_references
!=
0u
{
debug!
{
"(resolving name in module) import unresolved;
\
...
...
@@ -2428,7 +2428,7 @@ fn resolve_name_in_module(module: @Module,
* This needs special handling, as, unlike all of the other imports, it
* needs to look in the scope chain for modules and non-modules alike.
*/
fn
resolve_one_level_renaming_import
(
module
:
@
Module
,
fn
resolve_one_level_renaming_import
(
module
_
:
@
Module
,
import_directive
:
@
ImportDirective
)
->
ResolveResult
<
()
>
{
...
...
@@ -2448,7 +2448,7 @@ fn resolve_one_level_renaming_import(module: @Module,
`%s` in `%s`"
,
*
(
*
self
.atom_table
)
.atom_to_str
(
target_name
),
*
(
*
self
.atom_table
)
.atom_to_str
(
source_name
),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
// Find the matching items in the lexical scope chain for every
// namespace. If any of them come back indeterminate, this entire
...
...
@@ -2456,7 +2456,7 @@ fn resolve_one_level_renaming_import(module: @Module,
let
mut
module_result
;
debug!
{
"(resolving one-level naming result) searching for module"
};
alt
self
.resolve_item_in_lexical_scope
(
module
,
alt
self
.resolve_item_in_lexical_scope
(
module
_
,
source_name
,
ModuleNS
)
{
...
...
@@ -2479,7 +2479,7 @@ fn resolve_one_level_renaming_import(module: @Module,
let
mut
value_result
;
debug!
{
"(resolving one-level naming result) searching for value"
};
alt
self
.resolve_item_in_lexical_scope
(
module
,
alt
self
.resolve_item_in_lexical_scope
(
module
_
,
source_name
,
ValueNS
)
{
...
...
@@ -2502,7 +2502,7 @@ fn resolve_one_level_renaming_import(module: @Module,
let
mut
type_result
;
debug!
{
"(resolving one-level naming result) searching for type"
};
alt
self
.resolve_item_in_lexical_scope
(
module
,
alt
self
.resolve_item_in_lexical_scope
(
module
_
,
source_name
,
TypeNS
)
{
...
...
@@ -2542,7 +2542,7 @@ fn resolve_one_level_renaming_import(module: @Module,
let
mut
impl_result
;
debug!
{
"(resolving one-level naming result) searching for impl"
};
alt
self
.resolve_item_in_lexical_scope
(
module
,
alt
self
.resolve_item_in_lexical_scope
(
module
_
,
source_name
,
ImplNS
)
{
...
...
@@ -2573,7 +2573,7 @@ fn resolve_one_level_renaming_import(module: @Module,
}
// Otherwise, proceed and write in the bindings.
alt
module
.import_resolutions
.find
(
target_name
)
{
alt
module
_
.import_resolutions
.find
(
target_name
)
{
none
{
fail
~
"(resolving one-level renaming import) reduced graph
\
construction or glob importing should have created the
\
...
...
@@ -2584,7 +2584,7 @@ fn resolve_one_level_renaming_import(module: @Module,
result %? for `%s` into `%s`"
,
is_none
(
module_result
),
*
(
*
self
.atom_table
)
.atom_to_str
(
target_name
),
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
import_resolution
.module_target
=
module_result
;
import_resolution
.value_target
=
value_result
;
...
...
@@ -2608,16 +2608,16 @@ fn resolve_one_level_renaming_import(module: @Module,
ret
Success
(());
}
fn
report_unresolved_imports
(
module
:
@
Module
)
{
let
index
=
module
.resolved_import_count
;
let
import_count
=
module
.imports
.len
();
fn
report_unresolved_imports
(
module
_
:
@
Module
)
{
let
index
=
module
_
.resolved_import_count
;
let
import_count
=
module
_
.imports
.len
();
if
index
!=
import_count
{
self
.session
.span_err
(
module
.imports
.get_elt
(
index
)
.span
,
self
.session
.span_err
(
module
_
.imports
.get_elt
(
index
)
.span
,
~
"unresolved import"
);
}
// Descend into children and anonymous children.
for
module
.children.each
|
_
name
,
child_node
|
{
for
module
_
.children.each
|
_
name
,
child_node
|
{
alt
(
*
child_node
)
.get_module_if_available
()
{
none
{
// Continue.
...
...
@@ -2628,8 +2628,8 @@ fn report_unresolved_imports(module: @Module) {
}
}
for
module
.anonymous_children.each
|
_
name
,
module
|
{
self
.report_unresolved_imports
(
module
);
for
module
_
.anonymous_children.each
|
_
name
,
module_
|
{
self
.report_unresolved_imports
(
module
_
);
}
}
...
...
@@ -2647,11 +2647,11 @@ fn record_exports() {
self
.record_exports_for_module_subtree
(
root_module
);
}
fn
record_exports_for_module_subtree
(
module
:
@
Module
)
{
fn
record_exports_for_module_subtree
(
module
_
:
@
Module
)
{
// If this isn't a local crate, then bail out. We don't need to record
// exports for local crates.
alt
module
.def_id
{
alt
module
_
.def_id
{
some
(
def_id
)
if
def_id
.crate
==
local_crate
{
// OK. Continue.
}
...
...
@@ -2662,14 +2662,14 @@ fn record_exports_for_module_subtree(module: @Module) {
// Bail out.
debug!
{
"(recording exports for module subtree) not recording
\
exports for `%s`"
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
ret
;
}
}
self
.record_exports_for_module
(
module
);
self
.record_exports_for_module
(
module
_
);
for
module
.children.each
|
_
atom
,
child_name_bindings
|
{
for
module
_
.children.each
|
_
atom
,
child_name_bindings
|
{
alt
(
*
child_name_bindings
)
.get_module_if_available
()
{
none
{
// Nothing to do.
...
...
@@ -2680,13 +2680,13 @@ fn record_exports_for_module_subtree(module: @Module) {
}
}
for
module
.anonymous_children.each
|
_
node_id
,
child_module
|
{
for
module
_
.anonymous_children.each
|
_
node_id
,
child_module
|
{
self
.record_exports_for_module_subtree
(
child_module
);
}
}
fn
record_exports_for_module
(
module
:
@
Module
)
{
for
module
.exported_names.each
|
name
,
node_id
|
{
fn
record_exports_for_module
(
module
_
:
@
Module
)
{
for
module
_
.exported_names.each
|
name
,
node_id
|
{
let
mut
exports
=
~
[];
for
self
.namespaces.each
|
namespace
|
{
// Ignore impl namespaces; they cause the original resolve
...
...
@@ -2696,7 +2696,7 @@ fn record_exports_for_module(module: @Module) {
again
;
}
alt
self
.resolve_definition_of_name_in_module
(
module
,
alt
self
.resolve_definition_of_name_in_module
(
module
_
,
name
,
namespace
,
Xray
)
{
...
...
@@ -2733,11 +2733,11 @@ fn build_impl_scopes() {
self
.build_impl_scopes_for_module_subtree
(
root_module
);
}
fn
build_impl_scopes_for_module_subtree
(
module
:
@
Module
)
{
fn
build_impl_scopes_for_module_subtree
(
module
_
:
@
Module
)
{
// If this isn't a local crate, then bail out. We don't need to
// resolve implementations for external crates.
alt
module
.def_id
{
alt
module
_
.def_id
{
some
(
def_id
)
if
def_id
.crate
==
local_crate
{
// OK. Continue.
}
...
...
@@ -2748,14 +2748,14 @@ fn build_impl_scopes_for_module_subtree(module: @Module) {
// Bail out.
debug!
{
"(building impl scopes for module subtree) not
\
resolving implementations for `%s`"
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
ret
;
}
}
self
.build_impl_scope_for_module
(
module
);
self
.build_impl_scope_for_module
(
module
_
);
for
module
.children.each
|
_
atom
,
child_name_bindings
|
{
for
module
_
.children.each
|
_
atom
,
child_name_bindings
|
{
alt
(
*
child_name_bindings
)
.get_module_if_available
()
{
none
{
// Nothing to do.
...
...
@@ -2766,20 +2766,20 @@ fn build_impl_scopes_for_module_subtree(module: @Module) {
}
}
for
module
.anonymous_children.each
|
_
node_id
,
child_module
|
{
for
module
_
.anonymous_children.each
|
_
node_id
,
child_module
|
{
self
.build_impl_scopes_for_module_subtree
(
child_module
);
}
}
fn
build_impl_scope_for_module
(
module
:
@
Module
)
{
fn
build_impl_scope_for_module
(
module
_
:
@
Module
)
{
let
mut
impl_scope
=
~
[];
debug!
{
"(building impl scope for module) processing module %s (%?)"
,
self
.module_to_str
(
module
),
copy
module
.def_id
};
self
.module_to_str
(
module
_
),
copy
module
_
.def_id
};
// Gather up all direct children implementations in the module.
for
module
.children.each
|
_
impl_name
,
child_name_bindings
|
{
for
module
_
.children.each
|
_
impl_name
,
child_name_bindings
|
{
if
child_name_bindings
.impl_defs
.len
()
>=
1u
{
impl_scope
+=
child_name_bindings
.impl_defs
;
}
...
...
@@ -2790,7 +2790,7 @@ fn build_impl_scope_for_module(module: @Module) {
impl_scope
.len
()};
// Gather up all imports.
for
module
.import_resolutions.each
|
_
impl_name
,
import_resolution
|
{
for
module
_
.import_resolutions.each
|
_
impl_name
,
import_resolution
|
{
for
(
*
import_resolution
.impl_target
)
.each
|
impl_target
|
{
debug!
{
"(building impl scope for module) found impl def"
};
impl_scope
+=
impl_target
.bindings.impl_defs
;
...
...
@@ -2802,7 +2802,7 @@ fn build_impl_scope_for_module(module: @Module) {
// Determine the parent's implementation scope.
let
mut
parent_impl_scopes
;
alt
module
.parent_link
{
alt
module
_
.parent_link
{
NoParentLink
{
parent_impl_scopes
=
@
nil
;
}
...
...
@@ -2816,9 +2816,9 @@ fn build_impl_scope_for_module(module: @Module) {
// it up to the parent.
if
impl_scope
.len
()
>=
1u
{
module
.impl_scopes
=
@
cons
(
@
impl_scope
,
parent_impl_scopes
);
module
_
.impl_scopes
=
@
cons
(
@
impl_scope
,
parent_impl_scopes
);
}
else
{
module
.impl_scopes
=
parent_impl_scopes
;
module
_
.impl_scopes
=
parent_impl_scopes
;
}
}
...
...
@@ -2863,8 +2863,8 @@ fn with_scope(name: option<Atom>, f: fn()) {
*
(
*
self
.atom_table
)
.atom_to_str
(
name
),
self
.module_to_str
(
orig_module
)};
}
some
(
module
)
{
self
.current_module
=
module
;
some
(
module
_
)
{
self
.current_module
=
module
_
;
}
}
}
...
...
@@ -3129,10 +3129,10 @@ fn resolve_item(item: @item, visitor: ResolveVisitor) {
visitor
);
}
item_mod
(
module
)
{
item_mod
(
module
_
)
{
let
atom
=
(
*
self
.atom_table
)
.intern
(
item
.ident
);
do
self
.with_scope
(
some
(
atom
))
{
self
.resolve_module
(
module
,
item
.span
,
item
.ident
,
self
.resolve_module
(
module
_
,
item
.span
,
item
.ident
,
item
.id
,
visitor
);
}
}
...
...
@@ -3537,14 +3537,14 @@ fn resolve_implementation(id: node_id,
}
}
fn
resolve_module
(
module
:
_
mod
,
span
:
span
,
_
name
:
ident
,
id
:
node_id
,
fn
resolve_module
(
module
_
:
_
mod
,
span
:
span
,
_
name
:
ident
,
id
:
node_id
,
visitor
:
ResolveVisitor
)
{
// Write the implementations in scope into the module metadata.
debug!
{
"(resolving module) resolving module ID %d"
,
id
};
self
.impl_map
.insert
(
id
,
self
.current_module.impl_scopes
);
visit_mod
(
module
,
span
,
id
,
(),
visitor
);
visit_mod
(
module
_
,
span
,
id
,
(),
visitor
);
}
fn
resolve_local
(
local
:
@
local
,
visitor
:
ResolveVisitor
)
{
...
...
@@ -4501,11 +4501,11 @@ fn check_for_unused_imports_if_necessary() {
self
.check_for_unused_imports_in_module_subtree
(
root_module
);
}
fn
check_for_unused_imports_in_module_subtree
(
module
:
@
Module
)
{
fn
check_for_unused_imports_in_module_subtree
(
module
_
:
@
Module
)
{
// If this isn't a local crate, then bail out. We don't need to check
// for unused imports in external crates.
alt
module
.def_id
{
alt
module
_
.def_id
{
some
(
def_id
)
if
def_id
.crate
==
local_crate
{
// OK. Continue.
}
...
...
@@ -4516,14 +4516,14 @@ fn check_for_unused_imports_in_module_subtree(module: @Module) {
// Bail out.
debug!
{
"(checking for unused imports in module subtree) not
\
checking for unused imports for `%s`"
,
self
.module_to_str
(
module
)};
self
.module_to_str
(
module
_
)};
ret
;
}
}
self
.check_for_unused_imports_in_module
(
module
);
self
.check_for_unused_imports_in_module
(
module
_
);
for
module
.children.each
|
_
atom
,
child_name_bindings
|
{
for
module
_
.children.each
|
_
atom
,
child_name_bindings
|
{
alt
(
*
child_name_bindings
)
.get_module_if_available
()
{
none
{
// Nothing to do.
...
...
@@ -4535,13 +4535,13 @@ fn check_for_unused_imports_in_module_subtree(module: @Module) {
}
}
for
module
.anonymous_children.each
|
_
node_id
,
child_module
|
{
for
module
_
.anonymous_children.each
|
_
node_id
,
child_module
|
{
self
.check_for_unused_imports_in_module_subtree
(
child_module
);
}
}
fn
check_for_unused_imports_in_module
(
module
:
@
Module
)
{
for
module
.import_resolutions.each
|
_
impl_name
,
import_resolution
|
{
fn
check_for_unused_imports_in_module
(
module
_
:
@
Module
)
{
for
module
_
.import_resolutions.each
|
_
impl_name
,
import_resolution
|
{
if
!
import_resolution
.used
{
alt
self
.unused_import_lint_level
{
warn
{
...
...
@@ -4570,21 +4570,21 @@ fn check_for_unused_imports_in_module(module: @Module) {
//
/// A somewhat inefficient routine to print out the name of a module.
fn
module_to_str
(
module
:
@
Module
)
->
~
str
{
fn
module_to_str
(
module
_
:
@
Module
)
->
~
str
{
let
atoms
=
dvec
();
let
mut
current_module
=
module
;
let
mut
current_module
=
module
_
;
loop
{
alt
current_module
.parent_link
{
NoParentLink
{
break
;
}
ModuleParentLink
(
module
,
name
)
{
ModuleParentLink
(
module
_
,
name
)
{
atoms
.push
(
name
);
current_module
=
module
;
current_module
=
module
_
;
}
BlockParentLink
(
module
,
node_id
)
{
BlockParentLink
(
module
_
,
node_id
)
{
atoms
.push
((
*
self
.atom_table
)
.intern
(
@~
"<opaque>"
));
current_module
=
module
;
current_module
=
module
_
;
}
}
}
...
...
@@ -4610,16 +4610,16 @@ fn module_to_str(module: @Module) -> ~str {
ret
string
;
}
fn
dump_module
(
module
:
@
Module
)
{
debug!
{
"Dump of module `%s`:"
,
self
.module_to_str
(
module
)};
fn
dump_module
(
module
_
:
@
Module
)
{
debug!
{
"Dump of module `%s`:"
,
self
.module_to_str
(
module
_
)};
debug!
{
"Children:"
};
for
module
.children.each
|
name
,
_
child
|
{
for
module
_
.children.each
|
name
,
_
child
|
{
debug!
{
"* %s"
,
*
(
*
self
.atom_table
)
.atom_to_str
(
name
)};
}
debug!
{
"Import resolutions:"
};
for
module
.import_resolutions.each
|
name
,
import_resolution
|
{
for
module
_
.import_resolutions.each
|
name
,
import_resolution
|
{
let
mut
module_repr
;
alt
(
*
import_resolution
)
.target_for_namespace
(
ModuleNS
)
{
none
{
module_repr
=
~
""
;
}
...
...
src/rustc/middle/trans/alt.rs
浏览文件 @
7b2026bf
...
...
@@ -93,9 +93,9 @@ fn assoc(key: ast::ident, list: bind_map) -> option<ValueRef> {
data
:
@
{
bodycx
:
block
,
guard
:
option
<@
ast
::
expr
>
,
id_map
:
pat_id_map
}};
type
match
=
~
[
match_branch
];
type
match
_
=
~
[
match_branch
];
fn
has_nested_bindings
(
m
:
match
,
col
:
uint
)
->
bool
{
fn
has_nested_bindings
(
m
:
match
_
,
col
:
uint
)
->
bool
{
for
vec
::
each
(
m
)
|
br
|
{
alt
br
.pats
[
col
]
.node
{
ast
::
pat_ident
(
_
,
some
(
_
))
{
ret
true
;
}
...
...
@@ -105,7 +105,7 @@ fn has_nested_bindings(m: match, col: uint) -> bool {
ret
false
;
}
fn
expand_nested_bindings
(
m
:
match
,
col
:
uint
,
val
:
ValueRef
)
->
match
{
fn
expand_nested_bindings
(
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
)
->
match_
{
let
mut
result
=
~
[];
for
vec
::
each
(
m
)
|
br
|
{
alt
br
.pats
[
col
]
.node
{
...
...
@@ -129,8 +129,8 @@ fn expand_nested_bindings(m: match, col: uint, val: ValueRef) -> match {
type
enter_pat
=
fn
(
@
ast
::
pat
)
->
option
<~
[
@
ast
::
pat
]
>
;
fn
enter_match
(
dm
:
DefMap
,
m
:
match
,
col
:
uint
,
val
:
ValueRef
,
e
:
enter_pat
)
->
match
{
fn
enter_match
(
dm
:
DefMap
,
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
,
e
:
enter_pat
)
->
match
_
{
let
mut
result
=
~
[];
for
vec
::
each
(
m
)
|
br
|
{
alt
e
(
br
.pats
[
col
])
{
...
...
@@ -154,7 +154,7 @@ fn enter_match(dm: DefMap, m: match, col: uint, val: ValueRef,
ret
result
;
}
fn
enter_default
(
dm
:
DefMap
,
m
:
match
,
col
:
uint
,
val
:
ValueRef
)
->
match
{
fn
enter_default
(
dm
:
DefMap
,
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
)
->
match_
{
do
enter_match
(
dm
,
m
,
col
,
val
)
|
p
|
{
alt
p
.node
{
ast
::
pat_wild
|
ast
::
pat_rec
(
_
,
_
)
|
ast
::
pat_tup
(
_
)
{
some
(
~
[])
}
...
...
@@ -166,8 +166,8 @@ fn enter_default(dm: DefMap, m: match, col: uint, val: ValueRef) -> match {
}
}
fn
enter_opt
(
tcx
:
ty
::
ctxt
,
m
:
match
,
opt
:
opt
,
col
:
uint
,
variant_size
:
uint
,
val
:
ValueRef
)
->
match
{
fn
enter_opt
(
tcx
:
ty
::
ctxt
,
m
:
match
_
,
opt
:
opt
,
col
:
uint
,
variant_size
:
uint
,
val
:
ValueRef
)
->
match
_
{
let
dummy
=
@
{
id
:
0
,
node
:
ast
::
pat_wild
,
span
:
dummy_sp
()};
do
enter_match
(
tcx
.def_map
,
m
,
col
,
val
)
|
p
|
{
alt
p
.node
{
...
...
@@ -192,8 +192,8 @@ fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint,
}
}
fn
enter_rec
(
dm
:
DefMap
,
m
:
match
,
col
:
uint
,
fields
:
~
[
ast
::
ident
],
val
:
ValueRef
)
->
match
{
fn
enter_rec
(
dm
:
DefMap
,
m
:
match
_
,
col
:
uint
,
fields
:
~
[
ast
::
ident
],
val
:
ValueRef
)
->
match
_
{
let
dummy
=
@
{
id
:
0
,
node
:
ast
::
pat_wild
,
span
:
dummy_sp
()};
do
enter_match
(
dm
,
m
,
col
,
val
)
|
p
|
{
alt
p
.node
{
...
...
@@ -213,8 +213,8 @@ fn enter_rec(dm: DefMap, m: match, col: uint, fields: ~[ast::ident],
}
}
fn
enter_tup
(
dm
:
DefMap
,
m
:
match
,
col
:
uint
,
val
:
ValueRef
,
n_elts
:
uint
)
->
match
{
fn
enter_tup
(
dm
:
DefMap
,
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
,
n_elts
:
uint
)
->
match
_
{
let
dummy
=
@
{
id
:
0
,
node
:
ast
::
pat_wild
,
span
:
dummy_sp
()};
do
enter_match
(
dm
,
m
,
col
,
val
)
|
p
|
{
alt
p
.node
{
...
...
@@ -224,7 +224,7 @@ fn enter_tup(dm: DefMap, m: match, col: uint, val: ValueRef,
}
}
fn
enter_box
(
dm
:
DefMap
,
m
:
match
,
col
:
uint
,
val
:
ValueRef
)
->
match
{
fn
enter_box
(
dm
:
DefMap
,
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
)
->
match_
{
let
dummy
=
@
{
id
:
0
,
node
:
ast
::
pat_wild
,
span
:
dummy_sp
()};
do
enter_match
(
dm
,
m
,
col
,
val
)
|
p
|
{
alt
p
.node
{
...
...
@@ -234,7 +234,7 @@ fn enter_box(dm: DefMap, m: match, col: uint, val: ValueRef) -> match {
}
}
fn
enter_uniq
(
dm
:
DefMap
,
m
:
match
,
col
:
uint
,
val
:
ValueRef
)
->
match
{
fn
enter_uniq
(
dm
:
DefMap
,
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
)
->
match_
{
let
dummy
=
@
{
id
:
0
,
node
:
ast
::
pat_wild
,
span
:
dummy_sp
()};
do
enter_match
(
dm
,
m
,
col
,
val
)
|
p
|
{
alt
p
.node
{
...
...
@@ -244,7 +244,7 @@ fn enter_uniq(dm: DefMap, m: match, col: uint, val: ValueRef) -> match {
}
}
fn
get_options
(
ccx
:
@
crate_ctxt
,
m
:
match
,
col
:
uint
)
->
~
[
opt
]
{
fn
get_options
(
ccx
:
@
crate_ctxt
,
m
:
match
_
,
col
:
uint
)
->
~
[
opt
]
{
fn
add_to_set
(
tcx
:
ty
::
ctxt
,
&&
set
:
dvec
<
opt
>
,
val
:
opt
)
{
if
set
.any
(|
l
|
opt_eq
(
tcx
,
l
,
val
))
{
ret
;}
set
.push
(
val
);
...
...
@@ -294,7 +294,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
ret
{
vals
:
args
,
bcx
:
bcx
};
}
fn
collect_record_fields
(
m
:
match
,
col
:
uint
)
->
~
[
ast
::
ident
]
{
fn
collect_record_fields
(
m
:
match
_
,
col
:
uint
)
->
~
[
ast
::
ident
]
{
let
mut
fields
:
~
[
ast
::
ident
]
=
~
[];
for
vec
::
each
(
m
)
|
br
|
{
alt
br
.pats
[
col
]
.node
{
...
...
@@ -311,7 +311,7 @@ fn collect_record_fields(m: match, col: uint) -> ~[ast::ident] {
ret
fields
;
}
fn
root_pats_as_necessary
(
bcx
:
block
,
m
:
match
,
col
:
uint
,
val
:
ValueRef
)
{
fn
root_pats_as_necessary
(
bcx
:
block
,
m
:
match
_
,
col
:
uint
,
val
:
ValueRef
)
{
for
vec
::
each
(
m
)
|
br
|
{
let
pat_id
=
br
.pats
[
col
]
.id
;
...
...
@@ -331,21 +331,21 @@ fn root_pats_as_necessary(bcx: block, m: match, col: uint, val: ValueRef) {
}
}
fn
any_box_pat
(
m
:
match
,
col
:
uint
)
->
bool
{
fn
any_box_pat
(
m
:
match
_
,
col
:
uint
)
->
bool
{
for
vec
::
each
(
m
)
|
br
|
{
alt
br
.pats
[
col
]
.node
{
ast
::
pat_box
(
_
)
{
ret
true
;
}
_
{
}
}
}
ret
false
;
}
fn
any_uniq_pat
(
m
:
match
,
col
:
uint
)
->
bool
{
fn
any_uniq_pat
(
m
:
match
_
,
col
:
uint
)
->
bool
{
for
vec
::
each
(
m
)
|
br
|
{
alt
br
.pats
[
col
]
.node
{
ast
::
pat_uniq
(
_
)
{
ret
true
;
}
_
{
}
}
}
ret
false
;
}
fn
any_tup_pat
(
m
:
match
,
col
:
uint
)
->
bool
{
fn
any_tup_pat
(
m
:
match
_
,
col
:
uint
)
->
bool
{
for
vec
::
each
(
m
)
|
br
|
{
alt
br
.pats
[
col
]
.node
{
ast
::
pat_tup
(
_
)
{
ret
true
;
}
_
{
}
}
}
...
...
@@ -355,7 +355,7 @@ fn any_tup_pat(m: match, col: uint) -> bool {
type
exit_node
=
{
bound
:
bind_map
,
from
:
BasicBlockRef
,
to
:
BasicBlockRef
};
type
mk_fail
=
fn
@
()
->
BasicBlockRef
;
fn
pick_col
(
m
:
match
)
->
uint
{
fn
pick_col
(
m
:
match
_
)
->
uint
{
fn
score
(
p
:
@
ast
::
pat
)
->
uint
{
alt
p
.node
{
ast
::
pat_lit
(
_
)
|
ast
::
pat_enum
(
_
,
_
)
|
ast
::
pat_range
(
_
,
_
)
{
1u
}
...
...
@@ -383,7 +383,7 @@ fn score(p: @ast::pat) -> uint {
ret
best_col
;
}
fn
compile_submatch
(
bcx
:
block
,
m
:
match
,
vals
:
~
[
ValueRef
],
fn
compile_submatch
(
bcx
:
block
,
m
:
match
_
,
vals
:
~
[
ValueRef
],
chk
:
option
<
mk_fail
>
,
&
exits
:
~
[
exit_node
])
{
/*
For an empty match, a fall-through case must exist
...
...
@@ -651,7 +651,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
mode
:
ast
::
alt_mode
,
dest
:
dest
)
->
block
{
let
_
icx
=
scope_cx
.insn_ctxt
(
~
"alt::trans_alt_inner"
);
let
bcx
=
scope_cx
,
tcx
=
bcx
.tcx
();
let
mut
bodies
=
~
[],
match
=
~
[];
let
mut
bodies
=
~
[],
match
es
=
~
[];
let
{
bcx
,
val
,
_
}
=
trans_temp_expr
(
bcx
,
expr
);
if
bcx
.unreachable
{
ret
bcx
;
}
...
...
@@ -661,7 +661,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
let
id_map
=
pat_util
::
pat_id_map
(
tcx
.def_map
,
a
.pats
[
0
]);
vec
::
push
(
bodies
,
body
);
for
vec
::
each
(
a
.pats
)
|
p
|
{
vec
::
push
(
match
,
@
{
pats
:
~
[
p
],
vec
::
push
(
match
es
,
@
{
pats
:
~
[
p
],
bound
:
~
[],
data
:
@
{
bodycx
:
body
,
guard
:
a
.guard
,
id_map
:
id_map
}});
...
...
@@ -698,7 +698,7 @@ fn mk_fail(bcx: block, sp: span, msg: ~str,
};
let
mut
exit_map
=
~
[];
let
spilled
=
spill_if_immediate
(
bcx
,
val
,
t
);
compile_submatch
(
bcx
,
match
,
~
[
spilled
],
mk_fail
,
exit_map
);
compile_submatch
(
bcx
,
match
es
,
~
[
spilled
],
mk_fail
,
exit_map
);
let
mut
arm_cxs
=
~
[],
arm_dests
=
~
[],
i
=
0u
;
for
vec
::
each
(
arms
)
|
a
|
{
...
...
src/rustc/middle/typeck/coherence.rs
浏览文件 @
7b2026bf
...
...
@@ -363,10 +363,10 @@ fn check_privileged_scopes(crate: @crate) {
visit_crate
(
*
crate
,
(),
mk_vt
(
@
{
visit_item
:
|
item
,
_
context
,
visitor
|
{
alt
item
.node
{
item_mod
(
module
)
{
item_mod
(
module
_
)
{
// First, gather up all privileged types.
let
privileged_types
=
self
.gather_privileged_types
(
module
.items
);
self
.gather_privileged_types
(
module
_
.items
);
for
privileged_types
.each
|
privileged_type
|
{
debug!
{
"(checking privileged scopes) entering
\
privileged scope of %d:%d"
,
...
...
@@ -377,7 +377,7 @@ fn check_privileged_scopes(crate: @crate) {
}
// Then visit the module items.
visit_mod
(
module
,
item
.span
,
item
.id
,
(),
visitor
);
visit_mod
(
module
_
,
item
.span
,
item
.id
,
(),
visitor
);
// Finally, remove privileged types from the map.
for
privileged_types
.each
|
privileged_type
|
{
...
...
src/rustdoc/config.rs
浏览文件 @
7b2026bf
...
...
@@ -101,11 +101,11 @@ fn parse_config_(
let
args
=
vec
::
tail
(
args
);
let
opts
=
vec
::
unzip
(
opts
())
.first
();
alt
getopts
::
getopts
(
args
,
opts
)
{
result
::
ok
(
match
)
{
if
vec
::
len
(
match
.free
)
==
1u
{
let
input_crate
=
vec
::
head
(
match
.free
);
config_from_opts
(
input_crate
,
match
,
program_output
)
}
else
if
vec
::
is_empty
(
match
.free
)
{
result
::
ok
(
match
es
)
{
if
vec
::
len
(
match
es
.free
)
==
1u
{
let
input_crate
=
vec
::
head
(
match
es
.free
);
config_from_opts
(
input_crate
,
match
es
,
program_output
)
}
else
if
vec
::
is_empty
(
match
es
.free
)
{
result
::
err
(
~
"no crates specified"
)
}
else
{
result
::
err
(
~
"multiple crates specified"
)
...
...
@@ -119,14 +119,14 @@ fn parse_config_(
fn
config_from_opts
(
input_crate
:
~
str
,
match
:
getopts
::
matches
,
match
es
:
getopts
::
matches
,
program_output
:
program_output
)
->
result
<
config
,
~
str
>
{
let
config
=
default_config
(
input_crate
);
let
result
=
result
::
ok
(
config
);
let
result
=
do
result
::
chain
(
result
)
|
config
|
{
let
output_dir
=
getopts
::
opt_maybe_str
(
match
,
opt_output_dir
());
let
output_dir
=
getopts
::
opt_maybe_str
(
match
es
,
opt_output_dir
());
result
::
ok
({
output_dir
:
option
::
get_default
(
output_dir
,
config
.output_dir
)
with
config
...
...
@@ -134,7 +134,7 @@ fn config_from_opts(
};
let
result
=
do
result
::
chain
(
result
)
|
config
|
{
let
output_format
=
getopts
::
opt_maybe_str
(
match
,
opt_output_format
());
match
es
,
opt_output_format
());
do
option
::
map_default
(
output_format
,
result
::
ok
(
config
))
|
output_format
|
{
do
result
::
chain
(
parse_output_format
(
output_format
))
...
...
@@ -148,7 +148,8 @@ fn config_from_opts(
}
};
let
result
=
do
result
::
chain
(
result
)
|
config
|
{
let
output_style
=
getopts
::
opt_maybe_str
(
match
,
opt_output_style
());
let
output_style
=
getopts
::
opt_maybe_str
(
matches
,
opt_output_style
());
do
option
::
map_default
(
output_style
,
result
::
ok
(
config
))
|
output_style
|
{
do
result
::
chain
(
parse_output_style
(
output_style
))
...
...
@@ -161,7 +162,7 @@ fn config_from_opts(
}
};
let
result
=
do
result
::
chain
(
result
)
|
config
|
{
let
pandoc_cmd
=
getopts
::
opt_maybe_str
(
match
,
opt_pandoc_cmd
());
let
pandoc_cmd
=
getopts
::
opt_maybe_str
(
match
es
,
opt_pandoc_cmd
());
let
pandoc_cmd
=
maybe_find_pandoc
(
config
,
pandoc_cmd
,
program_output
);
do
result
::
chain
(
pandoc_cmd
)
|
pandoc_cmd
|
{
...
...
src/rustdoc/extract.rs
浏览文件 @
7b2026bf
...
...
@@ -52,11 +52,11 @@ fn mk_itemdoc(id: ast::node_id, name: ast::ident) -> doc::itemdoc {
fn
moddoc_from_mod
(
itemdoc
:
doc
::
itemdoc
,
module
:
ast
::
_
mod
module
_
:
ast
::
_
mod
)
->
doc
::
moddoc
{
doc
::
moddoc_
({
item
:
itemdoc
,
items
:
do
vec
::
filter_map
(
module
.items
)
|
item
|
{
items
:
do
vec
::
filter_map
(
module
_
.items
)
|
item
|
{
let
itemdoc
=
mk_itemdoc
(
item
.id
,
item
.ident
);
alt
item
.node
{
ast
::
item_mod
(
m
)
{
...
...
@@ -110,11 +110,11 @@ fn moddoc_from_mod(
fn
nmoddoc_from_mod
(
itemdoc
:
doc
::
itemdoc
,
module
:
ast
::
foreign_mod
module
_
:
ast
::
foreign_mod
)
->
doc
::
nmoddoc
{
{
item
:
itemdoc
,
fns
:
do
vec
::
map
(
module
.items
)
|
item
|
{
fns
:
do
vec
::
map
(
module
_
.items
)
|
item
|
{
let
itemdoc
=
mk_itemdoc
(
item
.id
,
item
.ident
);
alt
item
.node
{
ast
::
foreign_item_fn
(
_
,
_
)
{
...
...
src/test/compile-fail/attr-bad-crate-attr.rc
浏览文件 @
7b2026bf
// error-pattern: expected `mod`
// error-pattern: expected `mod
ule
`
#[attr = "val"];
#[attr = "val"] // Unterminated
src/test/run-pass/keyword-changes-2012-07-31.rs
0 → 100644
浏览文件 @
7b2026bf
// ret -> return
// mod -> module
// alt -> match
fn
main
()
{
}
mod
foo
{
}
fn
bar
()
->
int
{
match
0
{
_
{
0
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录