Introduce 'return', 'match' and 'module' as synonyms
This commit is contained in:
parent
7d18369804
commit
7b2026bf21
@ -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 matches = 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(matches, ~"test");
|
||||
let G = opt_present(matches, ~"G");
|
||||
let g = opt_present(matches, ~"g");
|
||||
let help = opt_present(matches, ~"h") || opt_present(matches, ~"help");
|
||||
let len = vec::len(matches.free);
|
||||
|
||||
let is_install = len > 1u && match.free[1] == ~"install";
|
||||
let is_uninstall = len > 1u && match.free[1] == ~"uninstall";
|
||||
let is_install = len > 1u && matches.free[1] == ~"install";
|
||||
let is_uninstall = len > 1u && matches.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: matches.free, help: help}
|
||||
}
|
||||
|
||||
fn configure(opts: options) -> cargo {
|
||||
|
@ -41,29 +41,29 @@ fn parse_config(args: ~[~str]) -> config {
|
||||
|
||||
assert (vec::is_not_empty(args));
|
||||
let args_ = vec::tail(args);
|
||||
let match =
|
||||
let matches =
|
||||
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(matches, ~"compile-lib-path"),
|
||||
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
|
||||
rustc_path: getopts::opt_str(matches, ~"rustc-path"),
|
||||
src_base: getopts::opt_str(matches, ~"src-base"),
|
||||
build_base: getopts::opt_str(matches, ~"build-base"),
|
||||
aux_base: getopts::opt_str(matches, ~"aux-base"),
|
||||
stage_id: getopts::opt_str(matches, ~"stage-id"),
|
||||
mode: str_mode(getopts::opt_str(matches, ~"mode")),
|
||||
run_ignored: getopts::opt_present(matches, ~"ignored"),
|
||||
filter:
|
||||
if vec::len(match.free) > 0u {
|
||||
option::some(match.free[0])
|
||||
if vec::len(matches.free) > 0u {
|
||||
option::some(matches.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(matches, ~"logfile"),
|
||||
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
|
||||
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
|
||||
verbose: getopts::opt_present(matches, ~"verbose")};
|
||||
}
|
||||
|
||||
fn log_config(config: config) {
|
||||
|
@ -97,7 +97,7 @@ impl private_methods<A> for dvec<A> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn return(-data: ~[mut A]) {
|
||||
fn give_back(-data: ~[mut A]) {
|
||||
unsafe {
|
||||
self.data <- data;
|
||||
}
|
||||
@ -120,7 +120,7 @@ impl extensions<A> for dvec<A> {
|
||||
*/
|
||||
#[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 @@ impl extensions<A> for dvec<A> {
|
||||
unchecked {
|
||||
do self.borrow |v| {
|
||||
let l = v.len();
|
||||
self.return(v);
|
||||
self.give_back(v);
|
||||
l
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ impl extensions<A> for dvec<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 @@ impl extensions<A> for dvec<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 @@ impl extensions<A:copy> for dvec<A> {
|
||||
unchecked {
|
||||
do self.borrow |v| {
|
||||
let w = vec::from_mut(copy v);
|
||||
self.return(v);
|
||||
self.give_back(v);
|
||||
w
|
||||
}
|
||||
}
|
||||
|
@ -192,18 +192,18 @@ mod tests {
|
||||
|
||||
#[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]
|
||||
|
@ -68,19 +68,19 @@ type opt_res = either<test_opts, ~str>;
|
||||
fn parse_opts(args: ~[~str]) -> opt_res {
|
||||
let args_ = vec::tail(args);
|
||||
let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")];
|
||||
let match =
|
||||
let matches =
|
||||
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(matches.free) > 0u {
|
||||
option::some(matches.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(matches, ~"ignored");
|
||||
let logfile = getopts::opt_maybe_str(matches, ~"logfile");
|
||||
|
||||
let test_opts = {filter: filter, run_ignored: run_ignored,
|
||||
logfile: logfile};
|
||||
|
@ -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_};
|
||||
}
|
||||
|
||||
|
||||
|
@ -789,7 +789,7 @@ class parser {
|
||||
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 @@ class parser {
|
||||
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 @@ class parser {
|
||||
}
|
||||
|
||||
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 @@ class parser {
|
||||
} 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 @@ class parser {
|
||||
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 @@ class parser {
|
||||
// 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] = ~[];
|
||||
|
@ -327,11 +327,11 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
|
||||
~"fail", ~"false", ~"fn", ~"for",
|
||||
~"if", ~"iface", ~"impl", ~"import",
|
||||
~"let", ~"log", ~"loop",
|
||||
~"mod", ~"mut",
|
||||
~"match", ~"mod", ~"module", ~"mut",
|
||||
~"new",
|
||||
~"owned",
|
||||
~"pure",
|
||||
~"ret",
|
||||
~"ret", ~"return",
|
||||
~"struct",
|
||||
~"true", ~"trait", ~"type",
|
||||
~"unchecked", ~"unsafe",
|
||||
|
@ -408,19 +408,19 @@ fn host_triple() -> ~str {
|
||||
};
|
||||
}
|
||||
|
||||
fn build_session_options(match: getopts::matches,
|
||||
fn build_session_options(matches: getopts::matches,
|
||||
demitter: diagnostic::emitter) -> @session::options {
|
||||
let crate_type = if opt_present(match, ~"lib") {
|
||||
let crate_type = if opt_present(matches, ~"lib") {
|
||||
session::lib_crate
|
||||
} else if opt_present(match, ~"bin") {
|
||||
} else if opt_present(matches, ~"bin") {
|
||||
session::bin_crate
|
||||
} else {
|
||||
session::unknown_crate
|
||||
};
|
||||
let static = opt_present(match, ~"static");
|
||||
let static = opt_present(matches, ~"static");
|
||||
|
||||
let parse_only = opt_present(match, ~"parse-only");
|
||||
let no_trans = opt_present(match, ~"no-trans");
|
||||
let parse_only = opt_present(matches, ~"parse-only");
|
||||
let no_trans = opt_present(matches, ~"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(matches, level_short),
|
||||
getopts::opt_strs(matches, 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(matches, ~"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(matches, ~"S") &&
|
||||
opt_present(matches, ~"emit-llvm") {
|
||||
link::output_type_llvm_assembly
|
||||
} else if opt_present(match, ~"S") {
|
||||
} else if opt_present(matches, ~"S") {
|
||||
link::output_type_assembly
|
||||
} else if opt_present(match, ~"c") {
|
||||
} else if opt_present(matches, ~"c") {
|
||||
link::output_type_object
|
||||
} else if opt_present(match, ~"emit-llvm") {
|
||||
} else if opt_present(matches, ~"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(matches, ~"xg");
|
||||
let debuginfo = opt_present(matches, ~"g") || extra_debuginfo;
|
||||
let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot");
|
||||
let target_opt = getopts::opt_maybe_str(matches, ~"target");
|
||||
let save_temps = getopts::opt_present(matches, ~"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(matches, ~"O") {
|
||||
if opt_present(matches, ~"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(matches, ~"opt-level") {
|
||||
alt getopts::opt_str(matches, ~"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(matches, ~"L");
|
||||
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"));
|
||||
let test = opt_present(matches, ~"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 matches =
|
||||
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(matches, 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 @@ mod test {
|
||||
// another --cfg test
|
||||
#[test]
|
||||
fn test_switch_implies_cfg_test_unless_cfg_test() {
|
||||
let match =
|
||||
let matches =
|
||||
alt getopts::getopts(~[~"--test", ~"--cfg=test"], opts()) {
|
||||
ok(m) { m }
|
||||
err(f) {
|
||||
@ -743,7 +743,7 @@ mod test {
|
||||
getopts::fail_str(f);
|
||||
}
|
||||
};
|
||||
let sessopts = build_session_options(match, diagnostic::emit);
|
||||
let sessopts = build_session_options(matches, 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");
|
||||
|
@ -128,7 +128,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
|
||||
|
||||
if vec::len(args) == 0u { usage(binary); ret; }
|
||||
|
||||
let match =
|
||||
let matches =
|
||||
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(matches, ~"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(matches, ~"W"),
|
||||
getopts::opt_strs(matches, ~"warn"));
|
||||
if lint_flags.contains(~"help") {
|
||||
describe_warnings();
|
||||
ret;
|
||||
}
|
||||
|
||||
if getopts::opt_strs(match, ~"Z").contains(~"help") {
|
||||
if getopts::opt_strs(matches, ~"Z").contains(~"help") {
|
||||
describe_debug_flags();
|
||||
ret;
|
||||
}
|
||||
|
||||
if opt_present(match, ~"v") || opt_present(match, ~"version") {
|
||||
if opt_present(matches, ~"v") || opt_present(matches, ~"version") {
|
||||
version(binary);
|
||||
ret;
|
||||
}
|
||||
let input = alt vec::len(match.free) {
|
||||
let input = alt vec::len(matches.free) {
|
||||
0u { early_error(demitter, ~"no input filename given") }
|
||||
1u {
|
||||
let ifile = match.free[0];
|
||||
let ifile = matches.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(matches, 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(matches, ~"out-dir");
|
||||
let ofile = getopts::opt_maybe_str(matches, ~"o");
|
||||
let cfg = build_configuration(sess, binary, input);
|
||||
let pretty =
|
||||
option::map(getopts::opt_default(match, ~"pretty",
|
||||
option::map(getopts::opt_default(matches, ~"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(matches, ~"ls");
|
||||
if ls {
|
||||
alt input {
|
||||
file_input(ifile) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -495,8 +495,8 @@ class NameBindings {
|
||||
/// 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 @@ class NameBindings {
|
||||
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 @@ class NameBindings {
|
||||
fail
|
||||
~"get_module called on a node with no module definition!";
|
||||
}
|
||||
ModuleDef(module) {
|
||||
ret module;
|
||||
ModuleDef(module_) {
|
||||
ret module_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -561,8 +561,8 @@ class NameBindings {
|
||||
NoModuleDef {
|
||||
ret none;
|
||||
}
|
||||
ModuleDef(module) {
|
||||
alt module.def_id {
|
||||
ModuleDef(module_) {
|
||||
alt module_.def_id {
|
||||
none {
|
||||
ret none;
|
||||
}
|
||||
@ -765,8 +765,8 @@ class 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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
|
||||
// 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 @@ class Resolver {
|
||||
(*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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
* 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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
module.resolved_import_count += 1u;
|
||||
module_.resolved_import_count += 1u;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1656,7 +1656,7 @@ class Resolver {
|
||||
* 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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
*(*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 @@ class Resolver {
|
||||
}
|
||||
|
||||
// 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 @@ class Resolver {
|
||||
* 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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
atom_to_str(name)});
|
||||
ret Failed;
|
||||
}
|
||||
ModuleDef(module) {
|
||||
search_module = module;
|
||||
ModuleDef(module_) {
|
||||
search_module = module_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2185,7 +2185,7 @@ class Resolver {
|
||||
* 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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
}
|
||||
|
||||
// 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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
wasn't actually a module!"};
|
||||
ret Failed;
|
||||
}
|
||||
ModuleDef(module) {
|
||||
ret Success(module);
|
||||
ModuleDef(module_) {
|
||||
ret Success(module_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2342,9 +2342,9 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
* 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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
* 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 @@ class Resolver {
|
||||
`%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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
|
||||
// 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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
|
||||
// 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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
*(*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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
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 @@ class Resolver {
|
||||
// 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 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class Resolver {
|
||||
//
|
||||
|
||||
/// 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 @@ class Resolver {
|
||||
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 = ~""; }
|
||||
|
@ -93,9 +93,9 @@ type match_branch =
|
||||
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 pick_col(m: match) -> 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 = ~[], matches = ~[];
|
||||
|
||||
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(matches, @{pats: ~[p],
|
||||
bound: ~[],
|
||||
data: @{bodycx: body, guard: a.guard,
|
||||
id_map: id_map}});
|
||||
@ -698,7 +698,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
|
||||
};
|
||||
let mut exit_map = ~[];
|
||||
let spilled = spill_if_immediate(bcx, val, t);
|
||||
compile_submatch(bcx, match, ~[spilled], mk_fail, exit_map);
|
||||
compile_submatch(bcx, matches, ~[spilled], mk_fail, exit_map);
|
||||
|
||||
let mut arm_cxs = ~[], arm_dests = ~[], i = 0u;
|
||||
for vec::each(arms) |a| {
|
||||
|
@ -363,10 +363,10 @@ class CoherenceChecker {
|
||||
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 @@ class CoherenceChecker {
|
||||
}
|
||||
|
||||
// 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| {
|
||||
|
@ -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(matches) {
|
||||
if vec::len(matches.free) == 1u {
|
||||
let input_crate = vec::head(matches.free);
|
||||
config_from_opts(input_crate, matches, program_output)
|
||||
} else if vec::is_empty(matches.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,
|
||||
matches: 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(matches, 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());
|
||||
matches, 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(matches, opt_pandoc_cmd());
|
||||
let pandoc_cmd = maybe_find_pandoc(
|
||||
config, pandoc_cmd, program_output);
|
||||
do result::chain(pandoc_cmd) |pandoc_cmd| {
|
||||
|
@ -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(_, _) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: expected `mod`
|
||||
// error-pattern: expected `module`
|
||||
|
||||
#[attr = "val"];
|
||||
#[attr = "val"] // Unterminated
|
||||
|
15
src/test/run-pass/keyword-changes-2012-07-31.rs
Normal file
15
src/test/run-pass/keyword-changes-2012-07-31.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// ret -> return
|
||||
// mod -> module
|
||||
// alt -> match
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
mod foo {
|
||||
}
|
||||
|
||||
fn bar() -> int {
|
||||
match 0 {
|
||||
_ { 0 }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user