Skip to content

Commit da5cd85

Browse files
committed
---
yaml --- r: 4989 b: refs/heads/master c: 03119fe h: refs/heads/master i: 4987: df929e1 v: v3
1 parent 41b4082 commit da5cd85

35 files changed

+404
-317
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: 652332f9d44d0c3eb36c220a88ef37f7f875206f
2+
refs/heads/master: 03119fe269de56e737562a9ee8d1bc47a9013eb4

trunk/src/comp/back/link.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
299299
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
300300
attr::require_unique_names(sess, linkage_metas);
301301
for meta: @ast::meta_item in linkage_metas {
302-
if attr::get_meta_item_name(meta) == "name" {
302+
if attr::get_meta_item_name(meta) == ~"name" {
303303
alt attr::get_meta_item_value_str(meta) {
304304
some(v) { name = some(v); }
305305
none. { cmh_items += [meta]; }
306306
}
307-
} else if attr::get_meta_item_name(meta) == "vers" {
307+
} else if attr::get_meta_item_name(meta) == ~"vers" {
308308
alt attr::get_meta_item_value_str(meta) {
309309
some(v) { vers = some(v); }
310310
none. { cmh_items += [meta]; }
@@ -334,11 +334,11 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
334334
let m = m_;
335335
alt m.node {
336336
ast::meta_name_value(key, value) {
337-
sha.input_str(len_and_str(istr::from_estr(key)));
337+
sha.input_str(len_and_str(key));
338338
sha.input_str(len_and_str_lit(value));
339339
}
340340
ast::meta_word(name) {
341-
sha.input_str(len_and_str(istr::from_estr(name)));
341+
sha.input_str(len_and_str(name));
342342
}
343343
ast::meta_list(_, _) {
344344
// FIXME (#607): Implement this

trunk/src/comp/driver/rustc.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ fn default_configuration(sess: session::session, argv0: str, input: str) ->
5555
let mk = attr::mk_name_value_item_str;
5656

5757
ret [ // Target bindings.
58-
mk("target_os", istr::to_estr(std::os::target_os())),
59-
mk("target_arch", "x86"),
60-
mk("target_libc", libc),
58+
mk(~"target_os", istr::to_estr(std::os::target_os())),
59+
mk(~"target_arch", "x86"),
60+
mk(~"target_libc", libc),
6161
// Build bindings.
62-
mk("build_compiler", argv0), mk("build_input", input)];
62+
mk(~"build_compiler", argv0), mk(~"build_input", input)];
6363
}
6464

6565
fn build_configuration(sess: session::session, argv0: str, input: str) ->
@@ -71,9 +71,9 @@ fn build_configuration(sess: session::session, argv0: str, input: str) ->
7171
// If the user wants a test runner, then add the test cfg
7272
let gen_cfg =
7373
{
74-
if sess.get_opts().test && !attr::contains_name(user_cfg, "test")
75-
{
76-
[attr::mk_word_item("test")]
74+
if sess.get_opts().test
75+
&& !attr::contains_name(user_cfg, ~"test") {
76+
[attr::mk_word_item(~"test")]
7777
} else { [] }
7878
};
7979
ret user_cfg + gen_cfg + default_cfg;
@@ -84,7 +84,9 @@ fn parse_cfgspecs(cfgspecs: &[str]) -> ast::crate_cfg {
8484
// FIXME: It would be nice to use the parser to parse all varieties of
8585
// meta_item here. At the moment we just support the meta_word variant.
8686
let words = [];
87-
for s: str in cfgspecs { words += [attr::mk_word_item(s)]; }
87+
for s: str in cfgspecs {
88+
words += [attr::mk_word_item(istr::from_estr(s))];
89+
}
8890
ret words;
8991
}
9092

@@ -655,7 +657,7 @@ mod test {
655657
let sessopts = build_session_options("whatever", match, "whatever");
656658
let sess = build_session(sessopts);
657659
let cfg = build_configuration(sess, "whatever", "whatever");
658-
assert (attr::contains_name(cfg, "test"));
660+
assert (attr::contains_name(cfg, ~"test"));
659661
}
660662

661663
// When the user supplies --test and --cfg test, don't implicitly add
@@ -669,7 +671,7 @@ mod test {
669671
let sessopts = build_session_options("whatever", match, "whatever");
670672
let sess = build_session(sessopts);
671673
let cfg = build_configuration(sess, "whatever", "whatever");
672-
let test_items = attr::find_meta_items_by_name(cfg, "test");
674+
let test_items = attr::find_meta_items_by_name(cfg, ~"test");
673675
assert (vec::len(test_items) == 1u);
674676
}
675677
}

trunk/src/comp/front/attr.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import std::vec;
44
import std::str;
5+
import std::istr;
56
import std::map;
67
import std::option;
78
import syntax::ast;
@@ -32,7 +33,7 @@ export mk_attr;
3233
// linkage
3334
fn find_linkage_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] {
3435
let metas: [@ast::meta_item] = [];
35-
for attr: ast::attribute in find_attrs_by_name(attrs, "link") {
36+
for attr: ast::attribute in find_attrs_by_name(attrs, ~"link") {
3637
alt attr.node.value.node {
3738
ast::meta_list(_, items) { metas += items; }
3839
_ { log "ignoring link attribute that has incorrect type"; }
@@ -163,11 +164,11 @@ fn sort_meta_items(items: &[@ast::meta_item]) -> [@ast::meta_item] {
163164
ret v2;
164165
}
165166

166-
fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) ->
167+
fn remove_meta_items_by_name(items: &[@ast::meta_item], name: &istr) ->
167168
[@ast::meta_item] {
168169

169170
let filter =
170-
bind fn (item: &@ast::meta_item, name: str) ->
171+
bind fn (item: &@ast::meta_item, name: &istr) ->
171172
option::t<@ast::meta_item> {
172173
if get_meta_item_name(item) != name {
173174
option::some(item)
@@ -178,12 +179,13 @@ fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) ->
178179
}
179180

180181
fn require_unique_names(sess: &session::session, metas: &[@ast::meta_item]) {
181-
let map = map::mk_hashmap::<str, ()>(str::hash, str::eq);
182+
let map = map::new_str_hash();
182183
for meta: @ast::meta_item in metas {
183184
let name = get_meta_item_name(meta);
184185
if map.contains_key(name) {
185186
sess.span_fatal(meta.span,
186-
#fmt["duplicate meta item `%s`", name]);
187+
#fmt["duplicate meta item `%s`",
188+
istr::to_estr(name)]);
187189
}
188190
map.insert(name, ());
189191
}

trunk/src/comp/front/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn native_item_in_cfg(cfg: &ast::crate_cfg, item: &@ast::native_item) ->
9494
fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool {
9595

9696
// The "cfg" attributes on the item
97-
let item_cfg_attrs = attr::find_attrs_by_name(attrs, "cfg");
97+
let item_cfg_attrs = attr::find_attrs_by_name(attrs, ~"cfg");
9898
let item_has_cfg_attrs = vec::len(item_cfg_attrs) > 0u;
9999
if !item_has_cfg_attrs { ret true; }
100100

@@ -108,7 +108,7 @@ fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool {
108108
[@ast::meta_item] {
109109
alt cfg_item.node {
110110
ast::meta_list(name, items) {
111-
assert (name == "cfg");
111+
assert (name == ~"cfg");
112112
inner_items + items
113113
}
114114
_ { inner_items }

trunk/src/comp/front/test.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn fold_mod(_cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold) ->
6464
fn nomain(item: &@ast::item) -> option::t<@ast::item> {
6565
alt item.node {
6666
ast::item_fn(f, _) {
67-
if item.ident == "main" {
67+
if item.ident == ~"main" {
6868
option::none
6969
} else { option::some(item) }
7070
}
@@ -107,7 +107,7 @@ fn fold_item(cx: &test_ctxt, i: &@ast::item, fld: fold::ast_fold) ->
107107

108108
fn is_test_fn(i: &@ast::item) -> bool {
109109
let has_test_attr =
110-
vec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u;
110+
vec::len(attr::find_attrs_by_name(i.attrs, ~"test")) > 0u;
111111

112112
fn has_test_signature(i: &@ast::item) -> bool {
113113
alt i.node {
@@ -125,7 +125,7 @@ fn is_test_fn(i: &@ast::item) -> bool {
125125
}
126126

127127
fn is_ignored(i: &@ast::item) -> bool {
128-
attr::contains_name(attr::attr_metas(i.attrs), "ignore")
128+
attr::contains_name(attr::attr_metas(i.attrs), ~"ignore")
129129
}
130130

131131
fn add_test_module(cx: &test_ctxt, m: &ast::_mod) -> ast::_mod {
@@ -160,7 +160,7 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item {
160160
let testmod: ast::_mod = {view_items: [], items: [mainfn, testsfn]};
161161
let item_ = ast::item_mod(testmod);
162162
let item: ast::item =
163-
{ident: "__test",
163+
{ident: ~"__test",
164164
attrs: [],
165165
id: cx.next_node_id(),
166166
node: item_,
@@ -198,7 +198,7 @@ fn mk_tests(cx: &test_ctxt) -> @ast::item {
198198

199199
let item_ = ast::item_fn(fn_, []);
200200
let item: ast::item =
201-
{ident: "tests",
201+
{ident: ~"tests",
202202
attrs: [],
203203
id: cx.next_node_id(),
204204
node: item_,
@@ -219,7 +219,7 @@ fn empty_fn_ty() -> ast::ty {
219219
fn mk_test_desc_vec_ty(cx: &test_ctxt) -> @ast::ty {
220220
let test_desc_ty_path: ast::path =
221221
nospan({global: false,
222-
idents: ["std", "test", "test_desc"],
222+
idents: [~"std", ~"test", ~"test_desc"],
223223
types: []});
224224

225225
let test_desc_ty: ast::ty =
@@ -256,7 +256,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
256256
span: dummy_sp()};
257257

258258
let name_field: ast::field =
259-
nospan({mut: ast::imm, ident: "name", expr: @name_expr});
259+
nospan({mut: ast::imm, ident: ~"name", expr: @name_expr});
260260

261261
let fn_path: ast::path = nospan({global: false, idents: path, types: []});
262262

@@ -266,7 +266,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
266266
span: dummy_sp()};
267267

268268
let fn_field: ast::field =
269-
nospan({mut: ast::imm, ident: "fn", expr: @fn_expr});
269+
nospan({mut: ast::imm, ident: ~"fn", expr: @fn_expr});
270270

271271
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
272272

@@ -276,7 +276,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
276276
span: dummy_sp()};
277277

278278
let ignore_field: ast::field =
279-
nospan({mut: ast::imm, ident: "ignore", expr: @ignore_expr});
279+
nospan({mut: ast::imm, ident: ~"ignore", expr: @ignore_expr});
280280

281281
let desc_rec_: ast::expr_ =
282282
ast::expr_rec([name_field, fn_field, ignore_field], option::none);
@@ -291,7 +291,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
291291
let args_ty: ast::ty = nospan(ast::ty_vec(args_mt));
292292

293293
let args_arg: ast::arg =
294-
{mode: ast::val, ty: @args_ty, ident: "args", id: cx.next_node_id()};
294+
{mode: ast::val, ty: @args_ty, ident: ~"args", id: cx.next_node_id()};
295295

296296
let ret_ty = nospan(ast::ty_nil);
297297

@@ -314,7 +314,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
314314

315315
let item_ = ast::item_fn(fn_, []);
316316
let item: ast::item =
317-
{ident: "main",
317+
{ident: ~"main",
318318
attrs: [],
319319
id: cx.next_node_id(),
320320
node: item_,
@@ -326,7 +326,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
326326

327327
// Get the args passed to main so we can pass the to test_main
328328
let args_path: ast::path =
329-
nospan({global: false, idents: ["args"], types: []});
329+
nospan({global: false, idents: [~"args"], types: []});
330330

331331
let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
332332

@@ -335,7 +335,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
335335

336336
// Call __test::test to generate the vector of test_descs
337337
let test_path: ast::path =
338-
nospan({global: false, idents: ["tests"], types: []});
338+
nospan({global: false, idents: [~"tests"], types: []});
339339

340340
let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
341341

@@ -350,7 +350,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
350350
// Call std::test::test_main
351351
let test_main_path: ast::path =
352352
nospan({global: false,
353-
idents: ["std", "test", "test_main"],
353+
idents: [~"std", ~"test", ~"test_main"],
354354
types: []});
355355

356356
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);

trunk/src/comp/metadata/creader.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn visit_item(e: env, i: &@ast::item) {
7070
let cstore = e.sess.get_cstore();
7171
if !cstore::add_used_library(cstore, m.native_name) { ret; }
7272
for a: ast::attribute in
73-
attr::find_attrs_by_name(i.attrs, "link_args") {
73+
attr::find_attrs_by_name(i.attrs, ~"link_args") {
7474
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
7575
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
7676
none. {/* fallthrough */ }
@@ -128,15 +128,15 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
128128
// is using the wrong type of meta item
129129
let crate_name =
130130
{
131-
let name_items = attr::find_meta_items_by_name(metas, "name");
131+
let name_items = attr::find_meta_items_by_name(metas, ~"name");
132132
alt vec::last(name_items) {
133133
some(i) {
134134
alt attr::get_meta_item_value_str(i) {
135135
some(n) { n }
136-
_ { ident }
136+
_ { istr::to_estr(ident) }
137137
}
138138
}
139-
none. { ident }
139+
none. { istr::to_estr(ident) }
140140
}
141141
};
142142

@@ -219,14 +219,15 @@ fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
219219
alt find_library_crate(sess, ident, metas, library_search_paths) {
220220
some(t) { ret t; }
221221
none. {
222-
sess.span_fatal(span, #fmt["can't find crate for '%s'", ident]);
222+
sess.span_fatal(span, #fmt["can't find crate for '%s'",
223+
istr::to_estr(ident)]);
223224
}
224225
}
225226
}
226227

227-
fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
228+
fn resolve_crate(e: env, ident: &ast::ident, metas: [@ast::meta_item],
228229
span: span) -> ast::crate_num {
229-
if !e.crate_cache.contains_key(istr::from_estr(ident)) {
230+
if !e.crate_cache.contains_key(ident) {
230231
let cinfo =
231232
load_library_crate(e.sess, span, ident, metas,
232233
e.library_search_paths);
@@ -236,19 +237,20 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
236237

237238
// Claim this crate number and cache it
238239
let cnum = e.next_crate_num;
239-
e.crate_cache.insert(istr::from_estr(ident), cnum);
240+
e.crate_cache.insert(ident, cnum);
240241
e.next_crate_num += 1;
241242

242243
// Now resolve the crates referenced by this crate
243244
let cnum_map = resolve_crate_deps(e, cdata);
244245

245-
let cmeta = {name: ident, data: cdata, cnum_map: cnum_map};
246+
let cmeta = {name: istr::to_estr(ident),
247+
data: cdata, cnum_map: cnum_map};
246248

247249
let cstore = e.sess.get_cstore();
248250
cstore::set_crate_data(cstore, cnum, cmeta);
249251
cstore::add_used_crate_file(cstore, cfilename);
250252
ret cnum;
251-
} else { ret e.crate_cache.get(istr::from_estr(ident)); }
253+
} else { ret e.crate_cache.get(ident); }
252254
}
253255

254256
// Go through the crate metadata and load any crates that it references
@@ -271,7 +273,9 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
271273
// This is a new one so we've got to load it
272274
// FIXME: Need better error reporting than just a bogus span
273275
let fake_span = ast_util::dummy_sp();
274-
let local_cnum = resolve_crate(e, cname, [], fake_span);
276+
let local_cnum = resolve_crate(e,
277+
istr::from_estr(cname),
278+
[], fake_span);
275279
cnum_map.insert(extrn_cnum, local_cnum);
276280
}
277281
}

trunk/src/comp/metadata/decoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
153153
fn eq_item(data: &[u8], s: str) -> bool {
154154
ret str::eq(str::unsafe_from_bytes(data), s);
155155
}
156-
let s = str::connect(path, "::");
156+
let s = istr::to_estr(istr::connect(path, ~"::"));
157157
let md = ebml::new_doc(data);
158158
let paths = ebml::get_doc(md, tag_paths);
159159
let eqer = bind eq_item(_, s);
@@ -302,14 +302,14 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] {
302302
for each meta_item_doc: ebml::doc in
303303
ebml::tagged_docs(md, tag_meta_item_word) {
304304
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
305-
let n = str::unsafe_from_bytes(ebml::doc_data(nd));
305+
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
306306
items += [attr::mk_word_item(n)];
307307
}
308308
for each meta_item_doc: ebml::doc in
309309
ebml::tagged_docs(md, tag_meta_item_name_value) {
310310
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
311311
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
312-
let n = str::unsafe_from_bytes(ebml::doc_data(nd));
312+
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
313313
let v = str::unsafe_from_bytes(ebml::doc_data(vd));
314314
// FIXME (#611): Should be able to decode meta_name_value variants,
315315
// but currently they can't be encoded
@@ -318,7 +318,7 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] {
318318
for each meta_item_doc: ebml::doc in
319319
ebml::tagged_docs(md, tag_meta_item_list) {
320320
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
321-
let n = str::unsafe_from_bytes(ebml::doc_data(nd));
321+
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
322322
let subitems = get_meta_items(meta_item_doc);
323323
items += [attr::mk_list_item(n, subitems)];
324324
}

0 commit comments

Comments
 (0)