Skip to content

Commit 03676b7

Browse files
committed
---
yaml --- r: 6755 b: refs/heads/master c: dbfa1b5 h: refs/heads/master i: 6753: 6f3bcfc 6751: 271d840 v: v3
1 parent d70f359 commit 03676b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1062
-612
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 7d786318a1b0f9315164716b46306d68e3b9560f
2+
refs/heads/master: dbfa1b56894c06dd1556cb00d16d8208447db3b8

trunk/mk/stage0.mk

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,13 @@ $(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_RUNTIME): \
1313
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
1414
$(Q)touch $@
1515

16-
## FIXME temporary hack for snapshot transition
17-
CORELIB_DUMMY :=$(call CFG_LIB_NAME,core-dummy)
18-
STDLIB_DUMMY :=$(call CFG_LIB_NAME,std-dummy)
19-
2016
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_CORELIB): \
2117
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
2218
$(Q)touch $@
23-
$(foreach target,$(CFG_TARGET_TRIPLES),\
24-
$(shell touch $(CFG_HOST_TRIPLE)/stage0/lib/rustc/$(target)/lib/$(CORELIB_DUMMY)))
2519

2620
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_STDLIB): \
2721
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
2822
$(Q)touch $@
29-
$(foreach target,$(CFG_TARGET_TRIPLES),\
30-
$(shell touch $(CFG_HOST_TRIPLE)/stage0/lib/rustc/$(target)/lib/$(STDLIB_DUMMY)))
3123

3224
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_RUSTLLVM): \
3325
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)

trunk/mk/tests.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ tidy:
9393
$(STDLIB_INPUTS) \
9494
$(COMPILETEST_CRATE) \
9595
$(COMPILETEST_INPUTS) \
96+
$(CARGO_CRATE) \
97+
$(CARGO_INPUTS) \
9698
| xargs -n 10 python $(S)src/etc/tidy.py
9799
$(Q)echo \
98100
$(ALL_TEST_INPUTS) \

trunk/src/cargo/cargo.rs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import rustc::syntax::parse::parser;
66
import std::fs;
77
import std::generic_os;
88
import std::io;
9+
import std::json;
910
import option;
1011
import option::{none, some};
1112
import std::os;
@@ -154,13 +155,15 @@ fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
154155
name = str::slice(name, 0u, ri as uint);
155156
}
156157
log #fmt["Installing: %s", name];
157-
let old = vec::map({|x| str::slice(x, 2u, str::byte_len(x))}, fs::list_dir("."));
158+
let old = fs::list_dir(".");
158159
run::run_program("rustc", [name + ".rc"]);
159-
let new = vec::map({|x| str::slice(x, 2u, str::byte_len(x))}, fs::list_dir("."));
160-
let created = vec::filter::<str>({ |n| !vec::member::<str>(n, old) }, new);
160+
let new = fs::list_dir(".");
161+
let created =
162+
vec::filter::<str>(new, { |n| !vec::member::<str>(n, old) });
163+
let exec_suffix = os::exec_suffix();
161164
for ct: str in created {
162-
if (os::exec_suffix() != "" && str::ends_with(ct, os::exec_suffix())) ||
163-
(os::exec_suffix() == "" && !str::starts_with(ct, "lib")) {
165+
if (exec_suffix != "" && str::ends_with(ct, exec_suffix)) ||
166+
(exec_suffix == "" && !str::starts_with(ct, "lib")) {
164167
log #fmt[" bin: %s", ct];
165168
// FIXME: need libstd fs::copy or something
166169
run::run_program("cp", [ct, c.bindir]);
@@ -178,7 +181,8 @@ fn install_source(c: cargo, path: str) {
178181

179182
log #fmt["contents: %s", str::connect(contents, ", ")];
180183

181-
let cratefiles = vec::filter::<str>({ |n| str::ends_with(n, ".rc") }, contents);
184+
let cratefiles =
185+
vec::filter::<str>(contents, { |n| str::ends_with(n, ".rc") });
182186

183187
if vec::is_empty(cratefiles) {
184188
fail "This doesn't look like a rust package (no .rc files).";
@@ -206,6 +210,36 @@ fn install_file(c: cargo, wd: str, _path: str) {
206210
install_source(c, wd);
207211
}
208212

213+
fn install_resolved(c: cargo, wd: str, key: str) {
214+
fs::remove_dir(wd);
215+
let u = "https://rust-package-index.appspot.com/pkg/" + key;
216+
let p = run::program_output("curl", [u]);
217+
if p.status != 0 {
218+
fail #fmt["Fetch of %s failed: %s", u, p.err];
219+
}
220+
let j = json::from_str(p.out);
221+
alt j {
222+
some (json::dict(_j)) {
223+
alt _j.find("install") {
224+
some (json::string(g)) {
225+
log #fmt["Resolved: %s -> %s", key, g];
226+
cmd_install(c, ["cargo", "install", g]);
227+
}
228+
_ { fail #fmt["Bogus install: '%s'", p.out]; }
229+
}
230+
}
231+
_ { fail #fmt["Bad json: '%s'", p.out]; }
232+
}
233+
}
234+
235+
fn install_uuid(c: cargo, wd: str, uuid: str) {
236+
install_resolved(c, wd, "by-uuid/" + uuid);
237+
}
238+
239+
fn install_named(c: cargo, wd: str, name: str) {
240+
install_resolved(c, wd, "by-name/" + name);
241+
}
242+
209243
fn cmd_install(c: cargo, argv: [str]) {
210244
// cargo install <pkg>
211245
if vec::len(argv) < 3u {
@@ -226,6 +260,11 @@ fn cmd_install(c: cargo, argv: [str]) {
226260
} else if str::starts_with(argv[2], "file:") {
227261
let path = rest(argv[2], 5u);
228262
install_file(c, wd, path);
263+
} else if str::starts_with(argv[2], "uuid:") {
264+
let uuid = rest(argv[2], 5u);
265+
install_uuid(c, wd, uuid);
266+
} else {
267+
install_named(c, wd, argv[2]);
229268
}
230269
}
231270

trunk/src/comp/back/rpath.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn get_sysroot_absolute_rt_lib(sess: session::session) -> fs::path {
4747
}
4848

4949
fn rpaths_to_flags(rpaths: [str]) -> [str] {
50-
vec::map({ |rpath| #fmt("-Wl,-rpath,%s",rpath)}, rpaths)
50+
vec::map(rpaths, { |rpath| #fmt("-Wl,-rpath,%s",rpath)})
5151
}
5252

5353
fn get_rpaths(os: session::os, cwd: fs::path, sysroot: fs::path,
@@ -96,7 +96,7 @@ fn get_rpaths_relative_to_output(os: session::os,
9696
cwd: fs::path,
9797
output: fs::path,
9898
libs: [fs::path]) -> [str] {
99-
vec::map(bind get_rpath_relative_to_output(os, cwd, output, _), libs)
99+
vec::map(libs, bind get_rpath_relative_to_output(os, cwd, output, _))
100100
}
101101

102102
fn get_rpath_relative_to_output(os: session::os,
@@ -150,7 +150,7 @@ fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path {
150150
}
151151

152152
fn get_absolute_rpaths(cwd: fs::path, libs: [fs::path]) -> [str] {
153-
vec::map(bind get_absolute_rpath(cwd, _), libs)
153+
vec::map(libs, bind get_absolute_rpath(cwd, _))
154154
}
155155

156156
fn get_absolute_rpath(cwd: fs::path, &&lib: fs::path) -> str {

trunk/src/comp/driver/rustc.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
162162
bind middle::ast_map::map_crate(*crate));
163163
time(time_passes, "external crate/lib resolution",
164164
bind creader::read_crates(sess, *crate));
165-
let {def_map: def_map, ext_map: ext_map} =
165+
let {def_map, ext_map, exp_map, impl_map} =
166166
time(time_passes, "resolution",
167167
bind resolve::resolve_crate(sess, ast_map, crate));
168168
let freevars =
@@ -171,7 +171,8 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
171171
time(time_passes, "const checking",
172172
bind middle::check_const::check_crate(sess, crate));
173173
let ty_cx = ty::mk_ctxt(sess, def_map, ext_map, ast_map, freevars);
174-
time(time_passes, "typechecking", bind typeck::check_crate(ty_cx, crate));
174+
let method_map = time(time_passes, "typechecking",
175+
bind typeck::check_crate(ty_cx, impl_map, crate));
175176
time(time_passes, "block-use checking",
176177
bind middle::block_use::check_crate(ty_cx, crate));
177178
time(time_passes, "function usage",
@@ -189,16 +190,17 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
189190
let last_uses = time(time_passes, "last use finding",
190191
bind last_use::find_last_uses(crate, def_map, ref_map, ty_cx));
191192
time(time_passes, "kind checking",
192-
bind kind::check_crate(ty_cx, last_uses, crate));
193+
bind kind::check_crate(ty_cx, method_map, last_uses, crate));
193194
if sess.get_opts().no_trans { ret; }
194195

195196
let outputs = build_output_filenames(input, outdir, output, sess);
196197

197198
let (llmod, link_meta) =
198199
time(time_passes, "translation",
199200
bind trans::trans_crate(sess, crate, ty_cx,
200-
outputs.obj_filename, ast_map,
201-
mut_map, copy_map, last_uses));
201+
outputs.obj_filename, exp_map, ast_map,
202+
mut_map, copy_map, last_uses,
203+
method_map));
202204
time(time_passes, "LLVM passes",
203205
bind link::write::run_passes(sess, llmod, outputs.obj_filename));
204206

@@ -267,11 +269,11 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
267269
ppm_typed. {
268270
crate = syntax::ext::expand::expand_crate(sess, crate);
269271
let amap = middle::ast_map::map_crate(*crate);
270-
let {def_map: def_map, ext_map: ext_map} =
272+
let {def_map, ext_map, impl_map, _} =
271273
resolve::resolve_crate(sess, amap, crate);
272274
let freevars = freevars::annotate_freevars(def_map, crate);
273275
let ty_cx = ty::mk_ctxt(sess, def_map, ext_map, amap, freevars);
274-
typeck::check_crate(ty_cx, crate);
276+
typeck::check_crate(ty_cx, impl_map, crate);
275277
ann = {pre: ann_paren_for_expr, post: bind ann_typed_post(ty_cx, _)};
276278
}
277279
ppm_identified. {
@@ -648,10 +650,9 @@ fn main(args: [str]) {
648650
let ofile = getopts::opt_maybe_str(match, "o");
649651
let cfg = build_configuration(sess, binary, ifile);
650652
let pretty =
651-
option::map::<str,
652-
pp_mode>(bind parse_pretty(sess, _),
653-
getopts::opt_default(match, "pretty",
654-
"normal"));
653+
option::map(getopts::opt_default(match, "pretty",
654+
"normal"),
655+
bind parse_pretty(sess, _));
655656
alt pretty {
656657
some::<pp_mode>(ppm) { pretty_print_input(sess, cfg, ifile, ppm); ret; }
657658
none::<pp_mode>. {/* continue */ }

trunk/src/comp/front/attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn find_attrs_by_name(attrs: [ast::attribute], name: ast::ident) ->
5050
option::some(a)
5151
} else { option::none }
5252
}(_, name);
53-
ret vec::filter_map(filter, attrs);
53+
ret vec::filter_map(attrs, filter);
5454
}
5555

5656
fn get_attr_name(attr: ast::attribute) -> ast::ident {
@@ -66,7 +66,7 @@ fn find_meta_items_by_name(metas: [@ast::meta_item], name: ast::ident) ->
6666
option::some(m)
6767
} else { option::none }
6868
}(_, name);
69-
ret vec::filter_map(filter, metas);
69+
ret vec::filter_map(metas, filter);
7070
}
7171

7272
fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident {
@@ -186,7 +186,7 @@ fn remove_meta_items_by_name(items: [@ast::meta_item], name: str) ->
186186
} else { option::none }
187187
}(_, name);
188188

189-
ret vec::filter_map(filter, items);
189+
ret vec::filter_map(items, filter);
190190
}
191191

192192
fn require_unique_names(sess: session::session, metas: [@ast::meta_item]) {

trunk/src/comp/front/config.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ fn filter_item(cfg: ast::crate_cfg, &&item: @ast::item) ->
2929
fn fold_mod(cfg: ast::crate_cfg, m: ast::_mod, fld: fold::ast_fold) ->
3030
ast::_mod {
3131
let filter = bind filter_item(cfg, _);
32-
let filtered_items = vec::filter_map(filter, m.items);
33-
ret {view_items: vec::map(fld.fold_view_item, m.view_items),
34-
items: vec::map(fld.fold_item, filtered_items)};
32+
let filtered_items = vec::filter_map(m.items, filter);
33+
ret {view_items: vec::map(m.view_items, fld.fold_view_item),
34+
items: vec::map(filtered_items, fld.fold_item)};
3535
}
3636

3737
fn filter_native_item(cfg: ast::crate_cfg, &&item: @ast::native_item) ->
@@ -44,8 +44,8 @@ fn filter_native_item(cfg: ast::crate_cfg, &&item: @ast::native_item) ->
4444
fn fold_native_mod(cfg: ast::crate_cfg, nm: ast::native_mod,
4545
fld: fold::ast_fold) -> ast::native_mod {
4646
let filter = bind filter_native_item(cfg, _);
47-
let filtered_items = vec::filter_map(filter, nm.items);
48-
ret {view_items: vec::map(fld.fold_view_item, nm.view_items),
47+
let filtered_items = vec::filter_map(nm.items, filter);
48+
ret {view_items: vec::map(nm.view_items, fld.fold_view_item),
4949
items: filtered_items};
5050
}
5151

@@ -69,10 +69,10 @@ fn filter_stmt(cfg: ast::crate_cfg, &&stmt: @ast::stmt) ->
6969
fn fold_block(cfg: ast::crate_cfg, b: ast::blk_, fld: fold::ast_fold) ->
7070
ast::blk_ {
7171
let filter = bind filter_stmt(cfg, _);
72-
let filtered_stmts = vec::filter_map(filter, b.stmts);
72+
let filtered_stmts = vec::filter_map(b.stmts, filter);
7373
ret {view_items: b.view_items,
74-
stmts: vec::map(fld.fold_stmt, filtered_stmts),
75-
expr: option::map(fld.fold_expr, b.expr),
74+
stmts: vec::map(filtered_stmts, fld.fold_stmt),
75+
expr: option::map(b.expr, fld.fold_expr),
7676
id: b.id,
7777
rules: b.rules};
7878
}
@@ -99,8 +99,8 @@ fn metas_in_cfg(cfg: ast::crate_cfg, metas: [@ast::meta_item]) -> bool {
9999
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
100100
// so we can match against them. This is the list of configurations for
101101
// which the item is valid
102-
let cfg_metas = vec::concat(vec::filter_map(
103-
{|&&i| attr::get_meta_item_list(i)}, cfg_metas));
102+
let cfg_metas = vec::concat(vec::filter_map(cfg_metas,
103+
{|&&i| attr::get_meta_item_list(i)}));
104104

105105
let has_cfg_metas = vec::len(cfg_metas) > 0u;
106106
if !has_cfg_metas { ret true; }

trunk/src/comp/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
6161
}
6262

6363
let mod_nomain =
64-
{view_items: m.view_items, items: vec::filter_map(nomain, m.items)};
64+
{view_items: m.view_items, items: vec::filter_map(m.items, nomain)};
6565
ret fold::noop_fold_mod(mod_nomain, fld);
6666
}
6767

@@ -126,8 +126,8 @@ fn is_test_fn(i: @ast::item) -> bool {
126126
fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
127127
let ignoreattrs = attr::find_attrs_by_name(i.attrs, "ignore");
128128
let ignoreitems = attr::attr_metas(ignoreattrs);
129-
let cfg_metas = vec::concat(vec::filter_map(
130-
{|&&i| attr::get_meta_item_list(i)}, ignoreitems));
129+
let cfg_metas = vec::concat(vec::filter_map(ignoreitems,
130+
{|&&i| attr::get_meta_item_list(i)}));
131131
ret if vec::is_not_empty(ignoreitems) {
132132
config::metas_in_cfg(cx.crate.node.config, cfg_metas)
133133
} else {

trunk/src/comp/metadata/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ const tag_items_data_item_inlineness: uint = 0x27u;
6666

6767
const tag_crate_hash: uint = 0x28u;
6868

69+
const tag_mod_impl: uint = 0x30u;
70+
71+
const tag_impl_method: uint = 0x31u;
72+
6973
// djb's cdb hashes.
7074
fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
7175

trunk/src/comp/metadata/csearch.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,33 @@ fn get_type_param_count(cstore: cstore::cstore, def: ast::def_id) -> uint {
2323

2424
fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num,
2525
path: [ast::ident]) -> [ast::def] {
26-
let cdata = cstore::get_crate_data(cstore, cnum).data;
27-
ret decoder::lookup_defs(cdata, cnum, path);
26+
let result = [];
27+
for (c, data, def) in resolve_path(cstore, cnum, path) {
28+
result += [decoder::lookup_def(c, data, def)];
29+
}
30+
ret result;
31+
}
32+
33+
fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
34+
path: [ast::ident]) ->
35+
[(ast::crate_num, @[u8], ast::def_id)] {
36+
let cm = cstore::get_crate_data(cstore, cnum);
37+
log #fmt("resolve_path %s in crates[%d]:%s",
38+
str::connect(path, "::"), cnum, cm.name);
39+
let result = [];
40+
for def in decoder::resolve_path(path, cm.data) {
41+
if def.crate == ast::local_crate {
42+
result += [(cnum, cm.data, def)];
43+
} else {
44+
if cm.cnum_map.contains_key(def.crate) {
45+
// This reexport is itself a reexport from anther crate
46+
let next_cnum = cm.cnum_map.get(def.crate);
47+
let next_cm_data = cstore::get_crate_data(cstore, next_cnum);
48+
result += [(next_cnum, next_cm_data.data, def)];
49+
}
50+
}
51+
}
52+
ret result;
2853
}
2954

3055
fn get_tag_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {

trunk/src/comp/metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn get_dep_hashes(cstore: cstore) -> [str] {
140140
log #fmt(" hash[%s]: %s", x.name, x.hash);
141141
}
142142
fn mapper(ch: crate_hash) -> str { ret ch.hash; }
143-
ret vec::map(mapper, sorted);
143+
ret vec::map(sorted, mapper);
144144
}
145145
// Local Variables:
146146
// mode: rust

trunk/src/comp/metadata/decoder.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export get_tag_variants;
1515
export get_type;
1616
export get_type_param_count;
1717
export get_type_param_kinds;
18-
export lookup_defs;
18+
export lookup_def;
19+
export resolve_path;
1920
export get_crate_attributes;
2021
export list_crate_metadata;
2122
export crate_dep;
@@ -158,14 +159,7 @@ fn resolve_path(path: [ast::ident], data: @[u8]) -> [ast::def_id] {
158159
ret result;
159160
}
160161

161-
// Crate metadata queries
162-
fn lookup_defs(data: @[u8], cnum: ast::crate_num, path: [ast::ident]) ->
163-
[ast::def] {
164-
ret vec::map(bind lookup_def(cnum, data, _), resolve_path(path, data));
165-
}
166-
167-
168-
// FIXME doesn't yet handle re-exported externals
162+
// FIXME doesn't yet handle renamed re-exported externals
169163
fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
170164
ast::def {
171165
let item = lookup_item(did_.node, data);

0 commit comments

Comments
 (0)